支持状态计算&修复若干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>
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
/// </summary>
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;

View File

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

View File

@ -17,17 +17,17 @@ namespace VPet_Simulator.Core
/// <summary>
/// 宠物名字
/// </summary>
[Line(name:"name")]
[Line(name: "name")]
public string Name;
/// <summary>
/// 金钱
/// </summary>
[Line(Type = LPSConvert.ConvertType.ToFloat, Name ="money")] public double Money;
[Line(Type = LPSConvert.ConvertType.ToFloat, Name = "money")] public double Money;
/// <summary>
/// 经验值
/// </summary>
[Line(name:"exp")] public int Exp;
[Line(type: LPSConvert.ConvertType.ToFloat, name: "exp")] public double Exp;
/// <summary>
/// 等级
/// </summary>
@ -116,15 +116,20 @@ namespace VPet_Simulator.Core
[Line(Type = LPSConvert.ConvertType.ToFloat)]
private double likability;
private int cleantick = 10;
/// <summary>
/// 清除变化
/// </summary>
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
/// </summary>
Ill
}
[Line(name:"mode")]
[Line(name: "mode")]
public ModeType Mode = ModeType.Nomal;
/// <summary>
/// 计算宠物当前状态
@ -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");
}
/// <summary>
/// 当前正在的状态

View File

@ -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;

View File

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

View File

@ -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;
@ -578,12 +578,6 @@ 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);
}
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)
{
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;
@ -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;
}
}
}