From ee8bb6994200e743556e92accd42f7630f9f4024 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 20 Jan 2023 20:40:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E8=AF=AF=E8=A7=A6=E5=8F=91=E9=95=BF=E6=8C=89=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 -- VPet-Simulator.Core/Display/Main.xaml.cs | 14 +++++++++----- VPet-Simulator.Core/Display/MainDisplay.cs | 21 +++++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2cebc0c..fede48d 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,6 @@ ![ss4](README.assets/ss4.gif)![ss4](README.assets/ss8.gif) - - ##### 爬墙 ![ss7](README.assets/ss7.gif) diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index f354b91..90481fa 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -57,7 +57,7 @@ namespace VPet_Simulator.Core var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, Core.Save.Mode); PetGrid.Child = ig.This; ig.Run(DisplayNomal); - + EventTimer.Elapsed += EventTimer_Elapsed; MoveTimer.Elapsed += MoveTimer_Elapsed; @@ -72,9 +72,11 @@ namespace VPet_Simulator.Core } public Action DefaultClickAction; bool isPress = false; + long presstime; private void MainGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { isPress = true; + CountNomal = 0; if (DisplayType != GraphCore.GraphType.Default) {//不是nomal! 可能会卡timer,所有全部timer清空下 MoveTimer.Stop(); @@ -84,14 +86,16 @@ namespace VPet_Simulator.Core } Task.Run(() => { - Thread.Sleep(Core.Controller.PressLength); + var pth = DateTime.Now.Ticks; + presstime = pth; + Thread.Sleep(Core.Controller.PressLength); Point mp = default; Dispatcher.BeginInvoke(new Action(() => mp = Mouse.GetPosition(MainGrid))).Wait(); - if (isPress) + if (isPress && presstime == pth) {//历遍长按事件 var act = Core.TouchEvent.FirstOrDefault(x => x.IsPress == true && x.Touch(mp)); if (act != null) - Dispatcher.BeginInvoke(act.DoAction); + Dispatcher.Invoke(act.DoAction); } else {//历遍点击事件 @@ -107,7 +111,7 @@ namespace VPet_Simulator.Core private void MainGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { isPress = false; - if (rasetype != int.MinValue) + if (DisplayType.ToString().StartsWith("Raised")) { MainGrid.MouseMove -= MainGrid_MouseMove; rasetype = -1; diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index 4101763..f3c1148 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -55,6 +55,10 @@ namespace VPet_Simulator.Core /// public void DisplayTouchHead() { + if (Core.Save.Strength <= 50) + return; + Core.Save.StrengthChange(-1); + Core.Save.FeelingChange(1); if (DisplayType == GraphCore.GraphType.Touch_Head_B_Loop) if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) { @@ -78,6 +82,7 @@ namespace VPet_Simulator.Core public void DisplayBoring() { looptimes = 0; + CountNomal = 0; Display(Core.Graph.FindGraph(GraphCore.GraphType.Boring_A_Start, Core.Save.Mode), DisplayBoringing); } /// @@ -97,6 +102,7 @@ namespace VPet_Simulator.Core public void DisplaySquat() { looptimes = 0; + CountNomal = 0; Display(Core.Graph.FindGraph(GraphCore.GraphType.Squat_A_Start, Core.Save.Mode), DisplaySquating); } /// @@ -181,6 +187,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio) { walklength = 0; + CountNomal = 0; Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => { MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedWalk, 0); @@ -239,7 +246,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio) { walklength = 0; - + CountNomal = 0; Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => { MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedWalk, 0); @@ -356,6 +363,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceLeft() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 300 * Core.Controller.ZoomRatio) { walklength = 0; + CountNomal = 0; Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置 Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => { @@ -408,7 +416,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceLeft() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio) { walklength = 0; - + CountNomal = 0; Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置 Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => @@ -452,7 +460,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 400 * Core.Controller.ZoomRatio) { walklength = 0; - + CountNomal = 0; Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置 Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => @@ -506,7 +514,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio) { walklength = 0; - + CountNomal = 0; Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置 Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => @@ -550,6 +558,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceUp() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio) { walklength = 0; + CountNomal = 0; Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置 MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedClimbTop, 0); @@ -600,7 +609,7 @@ namespace VPet_Simulator.Core if (Core.Controller.GetWindowsDistanceUp() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio) { walklength = 0; - + CountNomal = 0; Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置 MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedClimbTop, 0); @@ -657,7 +666,7 @@ namespace VPet_Simulator.Core /// 动画 /// 结束操作 public void Display(IGraph graph, Action EndAction = null) - { + { //if(graph.GraphType == GraphType.Climb_Up_Left) //{ // Dispatcher.Invoke(() => Say(graph.GraphType.ToString()));