diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index ded9898..6ff8099 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -97,7 +97,7 @@ namespace VPet_Simulator.Core /// public void DisplayTouchHead() { - if (Core.Controller.EnableFunction && Core.Save.Strength <= DistanceMin) + if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < 100) { Core.Save.StrengthChange(-1); Core.Save.FeelingChange(1); @@ -105,12 +105,12 @@ namespace VPet_Simulator.Core if (DisplayType == GraphType.Touch_Head_A_Start) return; if (DisplayType == GraphType.Touch_Head_B_Loop) - if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) + if (Dispatcher.Invoke(() => PetGrid.Tag) is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) { ig.IsContinue = true; return; } - else if (PetGrid2.Child is IGraph ig2 && ig2.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) + else if (Dispatcher.Invoke(() => PetGrid2.Tag) is IGraph ig2 && ig2.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) { ig2.IsContinue = true; return; @@ -126,7 +126,7 @@ namespace VPet_Simulator.Core /// public void DisplayTouchBody() { - if (Core.Controller.EnableFunction && Core.Save.Strength <= DistanceMin) + if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < 100) { Core.Save.StrengthChange(-1); Core.Save.FeelingChange(1); @@ -134,12 +134,12 @@ namespace VPet_Simulator.Core if (DisplayType == GraphType.Touch_Body_A_Start) return; if (DisplayType == GraphType.Touch_Body_B_Loop) - if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Body_B_Loop) + if (Dispatcher.Invoke(() => PetGrid.Tag) is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Body_B_Loop) { ig.IsContinue = true; return; } - else if (PetGrid2.Child is IGraph ig2 && ig2.GraphType == GraphCore.GraphType.Touch_Body_B_Loop) + else if (Dispatcher.Invoke(() => PetGrid2.Tag) is IGraph ig2 && ig2.GraphType == GraphCore.GraphType.Touch_Body_B_Loop) { ig2.IsContinue = true; return; @@ -278,16 +278,6 @@ namespace VPet_Simulator.Core MainGrid.MouseMove -= MainGrid_MouseWave; rasetype = 0; DisplayRaising(); - //if (((IGraph)PetGrid.Child).GraphType == GraphCore.GraphType.Touch_Head_B_Loop) - //{ - // ((IGraph)PetGrid.Child).IsContinue = true; - // return; - //} - //Display(GraphCore.GraphType.Raised_Dynamic, () => - // Display(GraphCore.GraphType.Touch_Head_B_Loop, () => - // Display(GraphCore.GraphType.Touch_Head_C_End, () => - // Display(GraphCore.GraphType.Default - //)))); } int rasetype = int.MinValue; int walklength = 0; @@ -1121,7 +1111,7 @@ namespace VPet_Simulator.Core PetGrid.Visibility = Visibility.Hidden; PetGrid2.Visibility = Visibility.Visible; //PetGrid2.Tag = graph; - }); + }); } else { @@ -1132,7 +1122,7 @@ namespace VPet_Simulator.Core PetGrid2.Visibility = Visibility.Hidden; PetGrid.Visibility = Visibility.Visible; //PetGrid.Tag = graph; - }); + }); } petgridcrlf = !petgridcrlf; GC.Collect(); diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index baa633c..3c2e60e 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -56,56 +56,66 @@ namespace VPet_Simulator.Core Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type)); } - private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + /// + /// 根据消耗计算相关数据 + /// + /// 过去时间倍率 + public void FunctionSpend(double TimePass) { Core.Save.CleanChange(); + //饮食等乱七八糟的消耗 + if (Core.Save.StrengthFood >= 50) + { + Core.Save.StrengthChange(TimePass); + if (Core.Save.StrengthFood >= 75) + Core.Save.Health += Function.Rnd.Next(0, 1) * TimePass; + } + else if (Core.Save.StrengthFood <= 25) + { + Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass; + } + //if (Core.GameSave.Strength <= 40) + //{ + // Core.GameSave.Health -= Function.Rnd.Next(0, 1); + //} + Core.Save.StrengthChangeFood(-TimePass); + //感受提升好感度 + if (Core.Save.Feeling >= 75) + { + if (Core.Save.Feeling >= 90) + { + Core.Save.Likability += TimePass; + } + Core.Save.Exp+= TimePass; + Core.Save.Health += TimePass; + } + else if (Core.Save.Feeling <= 25) + { + Core.Save.Likability -= TimePass; + } + if (Core.Save.StrengthDrink <= 25) + { + Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass; + } + else if (Core.Save.StrengthDrink >= 75) + Core.Save.Health += Function.Rnd.Next(0, 1) * TimePass; + var newmod = Core.Save.CalMode(); + if (Core.Save.Mode != newmod) + { + //TODO:切换逻辑 + + Core.Save.Mode = newmod; + } + } + + private void EventTimer_Elapsed(object sender, ElapsedEventArgs e) + { //所有Handle TimeHandle?.Invoke(this); if (Core.Controller.EnableFunction) { - //饮食等乱七八糟的消耗 - if (Core.Save.StrengthFood >= 50) - { - Core.Save.StrengthChange(1); - if (Core.Save.StrengthFood >= 75) - Core.Save.Health += Function.Rnd.Next(0, 1); - } - else if (Core.Save.StrengthFood <= 25) - { - Core.Save.Health -= Function.Rnd.Next(0, 1); - } - //if (Core.GameSave.Strength <= 40) - //{ - // Core.GameSave.Health -= Function.Rnd.Next(0, 1); - //} - Core.Save.StrengthChangeFood(-1); - if (Core.Save.Feeling >= 75) - { - if (Core.Save.Feeling >= 90) - { - Core.Save.Likability++; - } - Core.Save.Exp++; - Core.Save.Health++; - } - else if (Core.Save.Feeling <= 25) - { - Core.Save.Likability--; - } - if (Core.Save.StrengthDrink <= 25) - { - Core.Save.Health -= Function.Rnd.Next(0, 1); - } - else if (Core.Save.StrengthDrink >= 75) - Core.Save.Health += Function.Rnd.Next(0, 1); - var newmod = Core.Save.CalMode(); - if (Core.Save.Mode != newmod) - { - //TODO:切换逻辑 - - Core.Save.Mode = newmod; - } + FunctionSpend(0.015); } else { diff --git a/VPet-Simulator.Core/Handle/GameSave.cs b/VPet-Simulator.Core/Handle/GameSave.cs index 4d656d3..db45318 100644 --- a/VPet-Simulator.Core/Handle/GameSave.cs +++ b/VPet-Simulator.Core/Handle/GameSave.cs @@ -17,17 +17,17 @@ namespace VPet_Simulator.Core /// /// 宠物名字 /// - [Line(name:"name")] + [Line(name: "name")] public string Name; /// /// 金钱 /// - [Line(Type = LPSConvert.ConvertType.ToFloat, Name ="money")] public double Money; + [Line(Type = LPSConvert.ConvertType.ToFloat, Name = "money")] public double Money; /// /// 经验值 /// - [Line(name:"exp")] public int Exp; + [Line(type: LPSConvert.ConvertType.ToFloat, name: "exp")] public double Exp; /// /// 等级 /// @@ -116,18 +116,23 @@ namespace VPet_Simulator.Core [Line(Type = LPSConvert.ConvertType.ToFloat)] private double likability; + private int cleantick = 10; /// /// 清除变化 /// - public void CleanChange() + public void CleanChange(bool force = false) { - ChangeStrength = 0; - ChangeFeeling = 0; - ChangeStrengthDrink = 0; - ChangeStrengthFood = 0; + if(--cleantick <= 0 || force) + { + ChangeStrength /= 2; + ChangeFeeling /= 2; + ChangeStrengthDrink /= 2; + ChangeStrengthFood /= 2; + cleantick = 10; + } } - + /// /// 宠物状态模式 /// @@ -150,7 +155,7 @@ namespace VPet_Simulator.Core /// Ill } - [Line(name:"mode")] + [Line(name: "mode")] public ModeType Mode = ModeType.Nomal; /// /// 计算宠物当前状态 @@ -232,7 +237,7 @@ namespace VPet_Simulator.Core //save.SetFloat("feeling", Feeling); //save.SetFloat("health", Health); //save.SetFloat("Likability", Likability); - return LPSConvert.SerializeObject(this,"vpet"); + return LPSConvert.SerializeObject(this, "vpet"); } /// /// 当前正在的状态 diff --git a/VPet-Simulator.Windows/Function/MWController.cs b/VPet-Simulator.Windows/Function/MWController.cs index 8523e84..88ce707 100644 --- a/VPet-Simulator.Windows/Function/MWController.cs +++ b/VPet-Simulator.Windows/Function/MWController.cs @@ -63,7 +63,7 @@ namespace VPet_Simulator.Windows public int PressLength => mw.Set.PressLength; - public bool EnableFunction => false;//mw.Set.EnableFunction; + public bool EnableFunction => mw.Set.EnableFunction; public int InteractionCycle => mw.Set.InteractionCycle; diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index 6b74e04..8c7f7a4 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -280,14 +280,13 @@ - + ToolTip="启用数据计算,桌宠会有状态变化,需要按时投喂等. 如果嫌麻烦可以关掉" Checked="CalFunctionBox_Checked" /> diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index 23b4364..c4c7576 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -56,7 +56,7 @@ namespace VPet_Simulator.Windows //this.Width = 400 * Math.Sqrt(ZoomSlider.Value); //this.Height = 450 * Math.Sqrt(ZoomSlider.Value); - sDesktopAlignment.IsChecked = mw.Set.EnableFunction; + CalFunctionBox.IsChecked = mw.Set.EnableFunction; CalSlider.Value = mw.Set.LogicInterval; InteractionSlider.Value = mw.Set.InteractionCycle; MoveEventBox.IsChecked = mw.Set.AllowMove; @@ -267,7 +267,7 @@ namespace VPet_Simulator.Windows GameHave.Text = mod.Content.Trim('\n'); ButtonAllow.Visibility = mod.SuccessLoad || mw.Set.IsPassMOD(mod.Name) ? Visibility.Collapsed : Visibility.Visible; - + foreach (var mainplug in mw.Plugins) { if (mainplug.PluginName == mod.Name) @@ -577,13 +577,7 @@ namespace VPet_Simulator.Windows { Process.Start("https://www.exlb.net/SendKeys"); } - #endregion - private void sDesktopAlignment_Checked_1(object sender, RoutedEventArgs e) - { - if (!AllowChange) - return; - MessageBoxX.Show("由于没做完,暂不支持数据计算\n敬请期待后续更新", "没做完!", MessageBoxButton.OK, MessageBoxIcon.Warning); - } + #endregion private void CalSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { @@ -748,12 +742,12 @@ namespace VPet_Simulator.Windows private void ButtonSetting_MouseDown(object sender, MouseButtonEventArgs e) { - foreach(var mainplug in mw.Plugins) + foreach (var mainplug in mw.Plugins) { - if(mainplug.PluginName == mod.Name) + if (mainplug.PluginName == mod.Name) { mainplug.Setting(); - return; + return; } } } @@ -794,5 +788,12 @@ namespace VPet_Simulator.Windows mw.Set.StartRecordPoint = new Point(mw.Left, mw.Top); AllowChange = true; } + + private void CalFunctionBox_Checked(object sender, RoutedEventArgs e) + { + if (!AllowChange) + return; + mw.Set.EnableFunction = CalFunctionBox.IsChecked.Value; + } } }