Skip to content

Commit

Permalink
忘了
Browse files Browse the repository at this point in the history
  • Loading branch information
justaLoli committed Sep 9, 2023
1 parent 7f90048 commit 44a5728
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
8 changes: 4 additions & 4 deletions VPet-Mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@
</button>
</subviews>
</customView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Sog-FZ-g1c">
<rect key="frame" x="-7" y="133" width="314" height="32"/>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ukD-a3-v9P">
<rect key="frame" x="107" y="133" width="88" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="" bezelStyle="rounded" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="W1z-ed-fCV">
<buttonCell key="cell" type="push" title="一键爬行" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="cDG-C2-g0b">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="onButtonClicked:" target="XfG-lQ-9wD" id="aqc-m4-J0v"/>
<action selector="onButtonClicked:" target="XfG-lQ-9wD" id="lal-XQ-kJW"/>
</connections>
</button>
</subviews>
Expand Down
25 changes: 20 additions & 5 deletions VPet-Mac/VPet-autoaction-move.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ class VPetAutoMoveHandler{
func startAutoMove(){
if(moveStarted){return;}
moveStarted = true;
self.VPET.autoActionHendler.autoActionStarted = true;
generateMove();
}
func stopWindowMove(){
moveStarted = false;
self.VPET.autoActionHendler.autoActionStarted = false;
//终止当前可能存在的动画的方法
NSAnimationContext.runAnimationGroup({ (context) in
context.duration = 0.0
Expand All @@ -217,8 +219,6 @@ class VPetAutoMoveHandler{
}
func stopAutoMove(){
//被用户交互阻止。
if(!moveStarted){return;}
//TODO
stopWindowMove();
moveStarted = false;
let pl = self.VPET.generatePlayListC(graphtype: .Move, modetype: self.VPET.VPetStatus, title: self.playingKeyword!)
Expand Down Expand Up @@ -276,7 +276,21 @@ class VPetAutoMoveHandler{
func animateWindow(startPos:Vector,endPos:Vector,duration:CGFloat,direction:MoveDirections) {
if(!moveStarted){return;}
//动画播放
playingKeyword = directionKeyword[direction]!.randomElement()!
if direction == .WalkLeft{
switch VPET.VPetStatus{
case .Happy:playingKeyword = "walk.left.faster";break;
default:playingKeyword = "walk.left"
}
}
else if direction == .WalkRight{
switch VPET.VPetStatus{
case .Happy:playingKeyword = "walk.right.faster";break;
default:playingKeyword = "walk.right"
}
}
else{
playingKeyword = directionKeyword[direction]!.randomElement()!
}
let pl = VPET.generatePlayListAB(graphtype: .Move, modetype: VPET.VPetStatus, title: playingKeyword!)

VPET.animeplayer.interruptAndSetPlayList(pl);
Expand Down Expand Up @@ -311,9 +325,10 @@ class VPetAutoMoveHandler{
}
self.VPET.VPetGraphTypeStack.removeLast();

//是否接着移动
//多么优秀的抽签方式
let iscontinue = [true,true,true,false,false].randomElement()!
// let iscontinue = true;
// let iscontinue = [true,true,true,false,false].randomElement()!
let iscontinue = true;
if(iscontinue){
self.generateMove()
}
Expand Down
7 changes: 4 additions & 3 deletions VPet-Mac/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ViewController: NSViewController {
func initButton(){
for subv in self.view.subviews{
if let button = subv as? NSButton{
// if(button.title == ""){continue;}
// if(button.title == "一键爬行"){continue;}
button.isHidden = true
}
}
Expand Down Expand Up @@ -113,15 +113,16 @@ class ViewController: NSViewController {
VPET.workAndSleepHandler.endplayFromCurrentActionTitle();
VPET.updateAnimation();
}
if(sender.title == ""){
if(sender.title == "一键爬行"){
guard let windowController = self.view.window?.windowController as? WindowController else{
return;
}
guard let VPET = windowController.VPET else{
return;
}
VPET.autoActionHendler.movehandler!.generateMove()
VPET.autoActionHendler.movehandler!.startAutoMove()
}

}


Expand Down

0 comments on commit 44a5728

Please sign in to comment.