mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
新增状态等数值运算
This commit is contained in:
parent
ee8bb69942
commit
5aea3e0d74
@ -22,17 +22,48 @@ namespace VPet_Simulator.Core
|
||||
//所有Handle
|
||||
TimeHandle?.Invoke(this);
|
||||
|
||||
//TODO:饮食等乱七八糟的消耗
|
||||
//饮食等乱七八糟的消耗
|
||||
if (Core.Save.StrengthFood >= 50)
|
||||
{
|
||||
Core.Save.StrengthChange(1);
|
||||
}
|
||||
else if (Core.Save.StrengthFood <= 25)
|
||||
{
|
||||
Core.Save.Health -= Function.Rnd.Next(0, 1);
|
||||
}
|
||||
if (Core.Save.Strength <= 40)
|
||||
{
|
||||
Core.Save.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);
|
||||
}
|
||||
|
||||
|
||||
//UIHandle
|
||||
Dispatcher.Invoke(() => TimeUIHandle.Invoke(this));
|
||||
|
||||
if (DisplayType == GraphCore.GraphType.Default)
|
||||
switch (-1)//Function.Rnd.Next(10))
|
||||
if (DisplayType == GraphCore.GraphType.Default && !isPress)
|
||||
switch (Function.Rnd.Next(Math.Max(20, 200 - CountNomal)))
|
||||
{
|
||||
case 0:
|
||||
//随机向右
|
||||
case 7:
|
||||
//随机向右
|
||||
DisplayWalk_Left();
|
||||
break;
|
||||
case 1:
|
||||
@ -48,6 +79,7 @@ namespace VPet_Simulator.Core
|
||||
DisplayClimb_Right_DOWN();
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
DisplayWalk_Right();
|
||||
break;
|
||||
case 10:
|
||||
@ -57,9 +89,11 @@ namespace VPet_Simulator.Core
|
||||
DisplayClimb_Top_Left();
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
DisplayBoring();
|
||||
break;
|
||||
case 16:
|
||||
case 18:
|
||||
case 17:
|
||||
DisplaySquat();
|
||||
break;
|
||||
default:
|
||||
|
@ -26,7 +26,21 @@ namespace VPet_Simulator.Core
|
||||
InitializeComponent();
|
||||
EndTimer.Elapsed += EndTimer_Elapsed;
|
||||
ShowTimer.Elapsed += ShowTimer_Elapsed;
|
||||
CloseTimer.Elapsed += CloseTimer_Elapsed;
|
||||
}
|
||||
|
||||
private void CloseTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (Dispatcher.Invoke(() => Opacity) <= 0.05)
|
||||
{
|
||||
Dispatcher.Invoke(() => this.Visibility = Visibility.Collapsed);
|
||||
EndAction?.Invoke();
|
||||
}else
|
||||
{
|
||||
Dispatcher.Invoke(() => Opacity -= 0.02);
|
||||
}
|
||||
}
|
||||
|
||||
List<char> outputtext;
|
||||
private void ShowTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
@ -45,13 +59,14 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
if (--timeleft <= 0)
|
||||
{
|
||||
Dispatcher.Invoke(() => this.Visibility = Visibility.Collapsed);
|
||||
EndAction?.Invoke();
|
||||
EndTimer.Stop();
|
||||
CloseTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public Timer EndTimer = new Timer() { Interval = 100 };
|
||||
public Timer ShowTimer = new Timer() { Interval = 20 };
|
||||
public Timer CloseTimer = new Timer() { Interval = 10 };
|
||||
int timeleft;
|
||||
public void Show(string name, string text)
|
||||
{
|
||||
@ -59,13 +74,16 @@ namespace VPet_Simulator.Core
|
||||
outputtext = text.ToList();
|
||||
LName.Content = name;
|
||||
timeleft = text.Length + 5;
|
||||
ShowTimer.Start(); EndTimer.Stop();
|
||||
ShowTimer.Start(); EndTimer.Stop(); CloseTimer.Stop();
|
||||
this.Visibility = Visibility.Visible;
|
||||
Opacity = 1;
|
||||
}
|
||||
|
||||
private void Border_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
EndTimer.Stop();
|
||||
CloseTimer.Stop();
|
||||
this.Opacity = 1;
|
||||
}
|
||||
|
||||
private void Border_MouseLeave(object sender, MouseEventArgs e)
|
||||
@ -76,7 +94,7 @@ namespace VPet_Simulator.Core
|
||||
|
||||
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EndTimer.Stop(); ShowTimer.Stop();
|
||||
EndTimer.Stop(); ShowTimer.Stop();CloseTimer.Close();
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
EndAction?.Invoke();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Border x:Name="BdrPanel" VerticalAlignment="Bottom" Margin="0,0,0,55" TextBlock.FontSize="24"
|
||||
Visibility="Collapsed" TextElement.FontSize="24" BorderBrush="{DynamicResource DARKPrimaryDarker}"
|
||||
TextElement.FontSize="24" BorderBrush="{DynamicResource DARKPrimaryDarker}"
|
||||
BorderThickness="1" Background="{DynamicResource DARKPrimaryText}" CornerRadius="5"
|
||||
MouseLeave="MenuPanel_MouseLeave">
|
||||
<Grid Margin="15">
|
||||
@ -56,7 +56,7 @@
|
||||
Foreground="{DynamicResource ProgressBarForeground}"
|
||||
pu:ProgressBarHelper.IsPercentVisible="True"
|
||||
pu:ProgressBarHelper.GeneratingPercentText="PgbExperience_GeneratingPercentText" />
|
||||
<TextBlock x:Name="tExp" Grid.Row="3" Grid.Column="4" HorizontalAlignment="Right" Text="x1倍"
|
||||
<TextBlock x:Name="tExp" Grid.Row="3" Grid.Column="4" HorizontalAlignment="Right" Text="x1.0"
|
||||
Foreground="{DynamicResource DARKPrimary}" />
|
||||
<TextBlock Grid.Row="4" Text="体力" VerticalAlignment="Center" />
|
||||
<ProgressBar x:Name="pStrength" Grid.Row="4" Grid.Column="2" Value="40" FontSize="20" Height="20"
|
||||
@ -64,7 +64,7 @@
|
||||
Foreground="{DynamicResource ProgressBarForeground}"
|
||||
pu:ProgressBarHelper.IsPercentVisible="True"
|
||||
pu:ProgressBarHelper.GeneratingPercentText="PgbStrength_GeneratingPercentText" />
|
||||
<TextBlock x:Name="tStrength" Grid.Row="4" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
|
||||
<TextBlock x:Name="tStrength" Grid.Row="4" Grid.Column="4" HorizontalAlignment="Right" Text="+1/t"
|
||||
Foreground="{DynamicResource DARKPrimary}" />
|
||||
<TextBlock Grid.Row="5" Text="心情" VerticalAlignment="Center" />
|
||||
<ProgressBar x:Name="pFeeling" Grid.Row="5" Grid.Column="2" Value="60" FontSize="20" Height="20"
|
||||
@ -72,7 +72,7 @@
|
||||
Foreground="{DynamicResource ProgressBarForeground}"
|
||||
pu:ProgressBarHelper.IsPercentVisible="True"
|
||||
pu:ProgressBarHelper.GeneratingPercentText="PgbSpirit_GeneratingPercentText" />
|
||||
<TextBlock x:Name="tFeeling" Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
|
||||
<TextBlock x:Name="tFeeling" Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Text="+1/t"
|
||||
Foreground="{DynamicResource DARKPrimary}" />
|
||||
<TextBlock Grid.Row="6" Text="饱腹度" VerticalAlignment="Center" />
|
||||
<ProgressBar x:Name="pStrengthFood" Grid.Row="6" Grid.Column="2" Value="80" FontSize="20" Height="20"
|
||||
@ -80,7 +80,7 @@
|
||||
Foreground="{DynamicResource ProgressBarForeground}"
|
||||
pu:ProgressBarHelper.IsPercentVisible="True"
|
||||
pu:ProgressBarHelper.GeneratingPercentText="PgbHunger_GeneratingPercentText" />
|
||||
<TextBlock x:Name="tStrengthFood" Grid.Row="6" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
|
||||
<TextBlock x:Name="tStrengthFood" Grid.Row="6" Grid.Column="4" HorizontalAlignment="Right" Text="+1/t"
|
||||
Foreground="{DynamicResource DARKPrimary}" />
|
||||
<TextBlock Grid.Row="7" Text="口渴度" VerticalAlignment="Center" />
|
||||
<ProgressBar x:Name="pStrengthDrink" Grid.Row="7" Grid.Column="2" Value="20" FontSize="20" Height="20"
|
||||
@ -88,7 +88,7 @@
|
||||
Foreground="{DynamicResource ProgressBarForeground}"
|
||||
pu:ProgressBarHelper.IsPercentVisible="True"
|
||||
pu:ProgressBarHelper.GeneratingPercentText="PgbThirsty_GeneratingPercentText" />
|
||||
<TextBlock x:Name="tStrengthDrink" Grid.Row="7" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
|
||||
<TextBlock x:Name="tStrengthDrink" Grid.Row="7" Grid.Column="4" HorizontalAlignment="Right" Text="+1/t"
|
||||
Foreground="{DynamicResource DARKPrimary}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
@ -61,6 +61,10 @@ namespace VPet_Simulator.Core
|
||||
pFeeling.Value = m.Core.Save.Feeling;
|
||||
pStrengthFood.Value = m.Core.Save.StrengthFood;
|
||||
pStrengthDrink.Value = m.Core.Save.StrengthDrink;
|
||||
tStrength.Text = $"{m.Core.Save.ChangeStrength:f1}/t";
|
||||
tFeeling.Text = $"{m.Core.Save.ChangeFeeling:f1}/t";
|
||||
tStrengthDrink.Text = $"{m.Core.Save.ChangeStrengthDrink:f1}/t";
|
||||
tStrengthFood.Text = $"{m.Core.Save.ChangeStrengthFood:f1}/t";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace VPet_Simulator.Core
|
||||
|
||||
public GraphCore.GraphType GraphType { get; private set; }
|
||||
|
||||
private Action endwilldo;
|
||||
//private Action endwilldo;
|
||||
int nowid;
|
||||
/// <summary>
|
||||
/// 新建 PNG 动画
|
||||
@ -184,7 +184,8 @@ namespace VPet_Simulator.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.endwilldo = () => parent.Dispatcher.Invoke(Hidden);
|
||||
//parent.endwilldo = () => parent.Dispatcher.Invoke(Hidden);
|
||||
//parent.Dispatcher.Invoke(Hidden);
|
||||
if (parent.DoEndAction)
|
||||
EndAction?.Invoke();//运行结束动画时事件
|
||||
|
||||
@ -221,11 +222,11 @@ namespace VPet_Simulator.Core
|
||||
/// </summary>
|
||||
public void Run(Action EndAction = null)
|
||||
{
|
||||
if(endwilldo != null && nowid != Animations.Count)
|
||||
{
|
||||
endwilldo.Invoke();
|
||||
endwilldo = null;
|
||||
}
|
||||
//if(endwilldo != null && nowid != Animations.Count)
|
||||
//{
|
||||
// endwilldo.Invoke();
|
||||
// endwilldo = null;
|
||||
//}
|
||||
nowid = 0;
|
||||
PlayState = true;
|
||||
DoEndAction = true;
|
||||
|
@ -17,7 +17,7 @@ namespace VPet_Simulator.Core
|
||||
/// 宠物名字
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 金钱
|
||||
/// </summary>
|
||||
@ -44,11 +44,29 @@ namespace VPet_Simulator.Core
|
||||
|
||||
private double strength;
|
||||
/// <summary>
|
||||
/// 变化 体力
|
||||
/// </summary>
|
||||
public double ChangeStrength = 0;
|
||||
public void StrengthChange(double value)
|
||||
{
|
||||
ChangeStrength += value;
|
||||
Strength += value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 饱腹度
|
||||
/// </summary>
|
||||
public double StrengthFood { get => strengthFood; set => strengthFood = Math.Min(100, Math.Max(0, value)); }
|
||||
|
||||
private double strengthFood;
|
||||
public void StrengthChangeFood(double value)
|
||||
{
|
||||
ChangeStrengthFood += value;
|
||||
StrengthFood += value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 变化 食物
|
||||
/// </summary>
|
||||
public double ChangeStrengthFood = 0;
|
||||
/// <summary>
|
||||
/// 口渴度
|
||||
/// </summary>
|
||||
@ -56,12 +74,30 @@ namespace VPet_Simulator.Core
|
||||
|
||||
private double strengthDrink;
|
||||
/// <summary>
|
||||
/// 变化 口渴度
|
||||
/// </summary>
|
||||
public double ChangeStrengthDrink = 0;
|
||||
public void StrengthChangeDrink(double value)
|
||||
{
|
||||
ChangeStrengthDrink += value;
|
||||
StrengthDrink += value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 心情
|
||||
/// </summary>
|
||||
public double Feeling { get => feeling; set => feeling = Math.Min(100, Math.Max(0, value)); }
|
||||
|
||||
private double feeling;
|
||||
/// <summary>
|
||||
/// 变化 心情
|
||||
/// </summary>
|
||||
public double ChangeFeeling = 0;
|
||||
public void FeelingChange(double value)
|
||||
{
|
||||
ChangeFeeling += value;
|
||||
Feeling += value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 健康(生病)(隐藏)
|
||||
/// </summary>
|
||||
public double Health { get => health; set => health = Math.Min(100, Math.Max(0, value)); }
|
||||
@ -73,6 +109,19 @@ namespace VPet_Simulator.Core
|
||||
public double Likability { get => likability; set => likability = Math.Min(90 + Level * 10, Math.Max(0, value)); }
|
||||
|
||||
private double likability;
|
||||
|
||||
/// <summary>
|
||||
/// 清除变化
|
||||
/// </summary>
|
||||
public void CleanChange()
|
||||
{
|
||||
ChangeStrength = 0;
|
||||
ChangeFeeling = 0;
|
||||
ChangeStrengthDrink = 0;
|
||||
ChangeStrengthFood = 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 宠物状态模式
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user