支持状态计算&修复若干BUG

This commit is contained in:
ZouJin 2023-05-10 13:13:34 +10:00
parent 15f51fc439
commit e6e6e53dd5
6 changed files with 93 additions and 88 deletions

View File

@ -97,7 +97,7 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
public void DisplayTouchHead() 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.StrengthChange(-1);
Core.Save.FeelingChange(1); Core.Save.FeelingChange(1);
@ -105,12 +105,12 @@ namespace VPet_Simulator.Core
if (DisplayType == GraphType.Touch_Head_A_Start) if (DisplayType == GraphType.Touch_Head_A_Start)
return; return;
if (DisplayType == GraphType.Touch_Head_B_Loop) 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; ig.IsContinue = true;
return; 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; ig2.IsContinue = true;
return; return;
@ -126,7 +126,7 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
public void DisplayTouchBody() 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.StrengthChange(-1);
Core.Save.FeelingChange(1); Core.Save.FeelingChange(1);
@ -134,12 +134,12 @@ namespace VPet_Simulator.Core
if (DisplayType == GraphType.Touch_Body_A_Start) if (DisplayType == GraphType.Touch_Body_A_Start)
return; return;
if (DisplayType == GraphType.Touch_Body_B_Loop) 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; ig.IsContinue = true;
return; 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; ig2.IsContinue = true;
return; return;
@ -278,16 +278,6 @@ namespace VPet_Simulator.Core
MainGrid.MouseMove -= MainGrid_MouseWave; MainGrid.MouseMove -= MainGrid_MouseWave;
rasetype = 0; rasetype = 0;
DisplayRaising(); 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 rasetype = int.MinValue;
int walklength = 0; int walklength = 0;

View File

@ -56,49 +56,49 @@ namespace VPet_Simulator.Core
Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type)); Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type));
} }
private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) /// <summary>
/// 根据消耗计算相关数据
/// </summary>
/// <param name="TimePass">过去时间倍率</param>
public void FunctionSpend(double TimePass)
{ {
Core.Save.CleanChange(); Core.Save.CleanChange();
//所有Handle
TimeHandle?.Invoke(this);
if (Core.Controller.EnableFunction)
{
//饮食等乱七八糟的消耗 //饮食等乱七八糟的消耗
if (Core.Save.StrengthFood >= 50) if (Core.Save.StrengthFood >= 50)
{ {
Core.Save.StrengthChange(1); Core.Save.StrengthChange(TimePass);
if (Core.Save.StrengthFood >= 75) if (Core.Save.StrengthFood >= 75)
Core.Save.Health += Function.Rnd.Next(0, 1); Core.Save.Health += Function.Rnd.Next(0, 1) * TimePass;
} }
else if (Core.Save.StrengthFood <= 25) else if (Core.Save.StrengthFood <= 25)
{ {
Core.Save.Health -= Function.Rnd.Next(0, 1); Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass;
} }
//if (Core.GameSave.Strength <= 40) //if (Core.GameSave.Strength <= 40)
//{ //{
// Core.GameSave.Health -= Function.Rnd.Next(0, 1); // Core.GameSave.Health -= Function.Rnd.Next(0, 1);
//} //}
Core.Save.StrengthChangeFood(-1); Core.Save.StrengthChangeFood(-TimePass);
//感受提升好感度
if (Core.Save.Feeling >= 75) if (Core.Save.Feeling >= 75)
{ {
if (Core.Save.Feeling >= 90) if (Core.Save.Feeling >= 90)
{ {
Core.Save.Likability++; Core.Save.Likability += TimePass;
} }
Core.Save.Exp++; Core.Save.Exp+= TimePass;
Core.Save.Health++; Core.Save.Health += TimePass;
} }
else if (Core.Save.Feeling <= 25) else if (Core.Save.Feeling <= 25)
{ {
Core.Save.Likability--; Core.Save.Likability -= TimePass;
} }
if (Core.Save.StrengthDrink <= 25) if (Core.Save.StrengthDrink <= 25)
{ {
Core.Save.Health -= Function.Rnd.Next(0, 1); Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass;
} }
else if (Core.Save.StrengthDrink >= 75) else if (Core.Save.StrengthDrink >= 75)
Core.Save.Health += Function.Rnd.Next(0, 1); Core.Save.Health += Function.Rnd.Next(0, 1) * TimePass;
var newmod = Core.Save.CalMode(); var newmod = Core.Save.CalMode();
if (Core.Save.Mode != newmod) if (Core.Save.Mode != newmod)
{ {
@ -107,6 +107,16 @@ namespace VPet_Simulator.Core
Core.Save.Mode = newmod; Core.Save.Mode = newmod;
} }
} }
private void EventTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//所有Handle
TimeHandle?.Invoke(this);
if (Core.Controller.EnableFunction)
{
FunctionSpend(0.015);
}
else else
{ {
Core.Save.Mode = GameSave.ModeType.Happy; Core.Save.Mode = GameSave.ModeType.Happy;

View File

@ -17,17 +17,17 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 宠物名字 /// 宠物名字
/// </summary> /// </summary>
[Line(name:"name")] [Line(name: "name")]
public string Name; public string Name;
/// <summary> /// <summary>
/// 金钱 /// 金钱
/// </summary> /// </summary>
[Line(Type = LPSConvert.ConvertType.ToFloat, Name ="money")] public double Money; [Line(Type = LPSConvert.ConvertType.ToFloat, Name = "money")] public double Money;
/// <summary> /// <summary>
/// 经验值 /// 经验值
/// </summary> /// </summary>
[Line(name:"exp")] public int Exp; [Line(type: LPSConvert.ConvertType.ToFloat, name: "exp")] public double Exp;
/// <summary> /// <summary>
/// 等级 /// 等级
/// </summary> /// </summary>
@ -116,15 +116,20 @@ namespace VPet_Simulator.Core
[Line(Type = LPSConvert.ConvertType.ToFloat)] [Line(Type = LPSConvert.ConvertType.ToFloat)]
private double likability; private double likability;
private int cleantick = 10;
/// <summary> /// <summary>
/// 清除变化 /// 清除变化
/// </summary> /// </summary>
public void CleanChange() public void CleanChange(bool force = false)
{ {
ChangeStrength = 0; if(--cleantick <= 0 || force)
ChangeFeeling = 0; {
ChangeStrengthDrink = 0; ChangeStrength /= 2;
ChangeStrengthFood = 0; ChangeFeeling /= 2;
ChangeStrengthDrink /= 2;
ChangeStrengthFood /= 2;
cleantick = 10;
}
} }
@ -150,7 +155,7 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
Ill Ill
} }
[Line(name:"mode")] [Line(name: "mode")]
public ModeType Mode = ModeType.Nomal; public ModeType Mode = ModeType.Nomal;
/// <summary> /// <summary>
/// 计算宠物当前状态 /// 计算宠物当前状态
@ -232,7 +237,7 @@ namespace VPet_Simulator.Core
//save.SetFloat("feeling", Feeling); //save.SetFloat("feeling", Feeling);
//save.SetFloat("health", Health); //save.SetFloat("health", Health);
//save.SetFloat("Likability", Likability); //save.SetFloat("Likability", Likability);
return LPSConvert.SerializeObject(this,"vpet"); return LPSConvert.SerializeObject(this, "vpet");
} }
/// <summary> /// <summary>
/// 当前正在的状态 /// 当前正在的状态

View File

@ -63,7 +63,7 @@ namespace VPet_Simulator.Windows
public int PressLength => mw.Set.PressLength; 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; public int InteractionCycle => mw.Set.InteractionCycle;

View File

@ -280,14 +280,13 @@
<RowDefinition Height="35" /> <RowDefinition Height="35" />
<RowDefinition Height="35" /> <RowDefinition Height="35" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<pu:Switch x:Name="sDesktopAlignment" BorderBrush="{DynamicResource PrimaryDark}" <pu:Switch x:Name="CalFunctionBox" BorderBrush="{DynamicResource PrimaryDark}"
Grid.Column="2" CheckedBackground="{DynamicResource Primary}" Grid.Column="2" CheckedBackground="{DynamicResource Primary}"
CheckedBorderBrush="{DynamicResource Primary}" Background="Transparent" CheckedBorderBrush="{DynamicResource Primary}" Background="Transparent"
BoxWidth="35" BoxHeight="18" ToggleSize="14" ToggleShadowColor="{x:Null}" BoxWidth="35" BoxHeight="18" ToggleSize="14" ToggleShadowColor="{x:Null}"
ToggleBrush="{DynamicResource PrimaryDark}" ToggleBrush="{DynamicResource PrimaryDark}"
CheckedToggleBrush="{DynamicResource DARKPrimaryText}" Margin="10,0,0,0" CheckedToggleBrush="{DynamicResource DARKPrimaryText}" Margin="10,0,0,0"
ToolTip="启用数据计算,桌宠会有状态变化,需要按时投喂等.&#13;如果嫌麻烦可以关掉" ToolTip="启用数据计算,桌宠会有状态变化,需要按时投喂等.&#13;如果嫌麻烦可以关掉" Checked="CalFunctionBox_Checked" />
Checked="sDesktopAlignment_Checked_1" />
<Grid Grid.Column="2" Grid.Row="3"> <Grid Grid.Column="2" Grid.Row="3">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />

View File

@ -56,7 +56,7 @@ namespace VPet_Simulator.Windows
//this.Width = 400 * Math.Sqrt(ZoomSlider.Value); //this.Width = 400 * Math.Sqrt(ZoomSlider.Value);
//this.Height = 450 * 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; CalSlider.Value = mw.Set.LogicInterval;
InteractionSlider.Value = mw.Set.InteractionCycle; InteractionSlider.Value = mw.Set.InteractionCycle;
MoveEventBox.IsChecked = mw.Set.AllowMove; MoveEventBox.IsChecked = mw.Set.AllowMove;
@ -578,12 +578,6 @@ namespace VPet_Simulator.Windows
Process.Start("https://www.exlb.net/SendKeys"); Process.Start("https://www.exlb.net/SendKeys");
} }
#endregion #endregion
private void sDesktopAlignment_Checked_1(object sender, RoutedEventArgs e)
{
if (!AllowChange)
return;
MessageBoxX.Show("由于没做完,暂不支持数据计算\n敬请期待后续更新", "没做完!", MessageBoxButton.OK, MessageBoxIcon.Warning);
}
private void CalSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) private void CalSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{ {
@ -748,9 +742,9 @@ namespace VPet_Simulator.Windows
private void ButtonSetting_MouseDown(object sender, MouseButtonEventArgs e) 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(); mainplug.Setting();
return; return;
@ -794,5 +788,12 @@ namespace VPet_Simulator.Windows
mw.Set.StartRecordPoint = new Point(mw.Left, mw.Top); mw.Set.StartRecordPoint = new Point(mw.Left, mw.Top);
AllowChange = true; AllowChange = true;
} }
private void CalFunctionBox_Checked(object sender, RoutedEventArgs e)
{
if (!AllowChange)
return;
mw.Set.EnableFunction = CalFunctionBox.IsChecked.Value;
}
} }
} }