新版本存档(等级提高属性/等级上限等)

等级提高后, 一些属性的上限也会提高
转/精英化 相关的的参数
This commit is contained in:
ZouJin 2024-03-12 01:35:52 +08:00
parent 26f927f668
commit 838b4c9382
17 changed files with 495 additions and 403 deletions

View File

@ -38,16 +38,16 @@ namespace VPet_Simulator.Core
/// </summary>
Visibility Visibility { get; set; }
/// <summary>
/// 该消息框的UIElement
/// 该消息框的Control
/// </summary>
UIElement This { get; }
Control This { get; }
}
/// <summary>
/// MessageBar.xaml 的交互逻辑
/// </summary>
public partial class MessageBar : UserControl, IDisposable, IMassageBar
{
public UIElement This => this;
public Control This => this;
Main m;
public MessageBar(Main m)
{

View File

@ -18,7 +18,7 @@
<Border x:Name="BdrPanel" Margin="0,0,0,55" VerticalAlignment="Bottom" x:FieldModifier="public"
Background="{DynamicResource DARKPrimaryText}" BorderBrush="{DynamicResource DARKPrimaryDarker}"
BorderThickness="1" CornerRadius="5" MouseLeave="MenuPanel_MouseLeave" TextBlock.FontSize="24"
TextElement.FontSize="24" Visibility="Collapsed" Cursor="">
TextElement.FontSize="24" Visibility="Collapsed" Cursor="" d:Visibility="Visible">
<Grid Margin="15" x:Name="gdPanel" x:FieldModifier="public">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -37,7 +37,7 @@
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<TextBlock x:Name="Tlv" Grid.ColumnSpan="3" VerticalAlignment="Center"
<TextBlock x:Name="Tlv" Grid.ColumnSpan="3" VerticalAlignment="Center" x:FieldModifier="public"
Foreground="{DynamicResource DARKPrimary}" Text="Lv 14" />
<Button Grid.Column="2" Grid.ColumnSpan="3" HorizontalAlignment="Right" VerticalAlignment="Center"
Background="Transparent" Click="MenuPanel_Click" Content="{ll:Str 详细}" Cursor="Hand"

View File

@ -15,6 +15,7 @@ using static VPet_Simulator.Core.GraphHelper;
using System.ComponentModel;
using System.Reflection;
using static VPet_Simulator.Core.Main;
using static System.Net.Mime.MediaTypeNames;
namespace VPet_Simulator.Core
{
@ -150,6 +151,9 @@ namespace VPet_Simulator.Core
Work wwork;
Work wstudy;
Work wplay;
/// <summary>
/// 工作检测
/// </summary>
public Func<Work, bool> WorkCheck;
public void StartWork(Work work)
{
@ -185,6 +189,7 @@ namespace VPet_Simulator.Core
if (BdrPanel.Visibility == Visibility.Visible)
{
Tlv.Text = "Lv " + m.Core.Save.Level.ToString();
tExp.Text = "x" + m.Core.Save.ExpBonus.ToString("f2");
tMoney.Text = "$ " + m.Core.Save.Money.ToString("N2");
if (m.Core.Controller.EnableFunction)
{
@ -197,35 +202,38 @@ namespace VPet_Simulator.Core
tfun.Visibility = Visibility.Visible;
}
var max = m.Core.Save.LevelUpNeed();
if (max > pExp.Minimum)
{
pExp.Maximum = max;
}
pExp.Value = 0;
pExp.Maximum = max;
if (m.Core.Save.Exp < 0)
{
pExp.Minimum = m.Core.Save.Exp;
}
else
{
var bl = m.Core.Save.Level - 2;
if (bl <= 0)
pExp.Minimum = 0;
else
pExp.Minimum = (int)(Math.Pow((bl) * 10, 2));
pExp.Minimum = 0;
}
if (max < pExp.Minimum)
{
pExp.Maximum = max;
}
pExp.Value = m.Core.Save.Exp;
pStrengthFood.Value = 0;
pStrengthDrink.Value = 0;
pStrength.Value = 0;
pFeeling.Value = 0;
pStrengthFood.Maximum = m.Core.Save.StrengthMax;
pStrengthDrink.Maximum = m.Core.Save.StrengthMax;
pStrength.Maximum = m.Core.Save.StrengthMax;
pFeeling.Maximum = m.Core.Save.FeelingMax;
pStrength.Value = m.Core.Save.Strength;
pFeeling.Value = m.Core.Save.Feeling;
pStrengthFood.Value = m.Core.Save.StrengthFood;
pStrengthDrink.Value = m.Core.Save.StrengthDrink;
pStrengthFoodMax.Value = Math.Min(100, m.Core.Save.StrengthFood + m.Core.Save.StoreStrengthFood);
pStrengthDrinkMax.Value = Math.Min(100, m.Core.Save.StrengthDrink + m.Core.Save.StoreStrengthDrink);
pStrengthFoodMax.Value = Math.Min(100, (m.Core.Save.StrengthFood + m.Core.Save.StoreStrengthFood) / m.Core.Save.StrengthMax * 100);
pStrengthDrinkMax.Value = Math.Min(100, (m.Core.Save.StrengthDrink + m.Core.Save.StoreStrengthDrink) / m.Core.Save.StrengthMax * 100);
if (Math.Abs(m.Core.Save.ChangeStrength) > 1)
tStrength.Text = $"{m.Core.Save.ChangeStrength:f1}/t";
@ -368,28 +376,28 @@ namespace VPet_Simulator.Core
private void PgbStrength_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
{
e.Text = $"{e.Value:f2} / 100";
e.Text = $"{e.Value:f2} / {pStrength.Maximum:f0}";
}
private void PgbSpirit_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
{
var progressBar = (ProgressBar)sender;
progressBar.Foreground = GetForeground(e.Value);
e.Text = $"{e.Value:f2} / 100";
progressBar.Foreground = GetForeground(e.Value / pFeeling.Maximum);
e.Text = $"{e.Value:f2} / {pFeeling.Maximum:f0}";
}
private void PgbHunger_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
{
var progressBar = (ProgressBar)sender;
progressBar.Foreground = GetForeground(e.Value);
e.Text = $"{e.Value:f2} / 100";
progressBar.Foreground = GetForeground(e.Value / pStrength.Maximum);
e.Text = $"{e.Value:f2} / {pStrength.Maximum:f0}";
}
private void PgbThirsty_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
{
var progressBar = (ProgressBar)sender;
progressBar.Foreground = GetForeground(e.Value);
e.Text = $"{e.Value:f2} / 100";
progressBar.Foreground = GetForeground(e.Value / pStrength.Maximum);
e.Text = $"{e.Value:f2} / {pStrength.Maximum:f0}";
//if (e.Value <= 20)
//{
// tHearth.Visibility = Visibility.Visible;
@ -398,11 +406,11 @@ namespace VPet_Simulator.Core
private Brush GetForeground(double value)
{
if (value >= 80)
if (value >= .8)
{
return FindResource("SuccessProgressBarForeground") as Brush;
}
else if (value >= 50)
else if (value >= .3)
{
return FindResource("WarningProgressBarForeground") as Brush;
}
@ -411,10 +419,16 @@ namespace VPet_Simulator.Core
return FindResource("DangerProgressBarForeground") as Brush;
}
}
/// <summary>
/// MenuPanel显示事件
/// </summary>
public event Action EventMenuPanelShow;
private void MenuPanel_MouseEnter(object sender, MouseEventArgs e)
{
BdrPanel.Visibility = Visibility.Visible;
M_TimeUIHandle(m);
EventMenuPanelShow?.Invoke();
}
private void MenuPanel_MouseLeave(object sender, MouseEventArgs e)

View File

@ -39,7 +39,7 @@ namespace VPet_Simulator.Core
/// </summary>
public double Strength { get => strength; set => strength = Math.Min(StrengthMax, Math.Max(0, value)); }
public double StrengthMax { get;} = 100;
public double StrengthMax { get; } = 100;
[Line(Type = LPSConvert.ConvertType.ToFloat, IgnoreCase = true)]
protected double strength { get; set; }
@ -263,6 +263,10 @@ namespace VPet_Simulator.Core
public double LikabilityMax => 90 + Level * 10;
public double FeelingMax => 100;
public double ExpBonus => 1;
/// <summary>
/// 计算宠物当前状态
/// </summary>
@ -283,12 +287,13 @@ namespace VPet_Simulator.Core
}
}
//然后判断是高兴还是普通
realhel = 90 - (Likability >= 80 ? 20 : (Likability >= 40 ? 10 : 0));
if (Feeling >= realhel)
double realfel = .90 - (Likability >= 80 ? .20 : (Likability >= 40 ? .10 : 0));
double felps = Feeling / FeelingMax;
if (felps >= realfel)
{
return ModeType.Happy;
}
else if (Feeling <= realhel / 2)
else if (felps <= realfel / 2)
{
return ModeType.PoorCondition;
}

View File

@ -23,6 +23,10 @@ namespace VPet_Simulator.Core
/// </summary>
double Exp { get; set; }
/// <summary>
/// 经验值加成
/// </summary>
double ExpBonus { get; }
/// <summary>
/// 等级
/// </summary>
int Level { get; }
@ -38,7 +42,7 @@ namespace VPet_Simulator.Core
/// <summary>
/// 最大体力值
/// </summary>
double StrengthMax { get;}
double StrengthMax { get; }
/// <summary>
/// 待补充的体力,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
@ -94,7 +98,10 @@ namespace VPet_Simulator.Core
/// 心情
/// </summary>
double Feeling { get; set; }
/// <summary>
/// 心情最大值
/// </summary>
double FeelingMax { get; }
/// <summary>
/// 待补充的心情,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
@ -112,7 +119,7 @@ namespace VPet_Simulator.Core
/// <summary>
/// 好感度(隐藏)(最大值)
/// </summary>
double LikabilityMax { get;}
double LikabilityMax { get; }
/// <summary>
/// 清除变化

View File

@ -23,10 +23,10 @@
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LinePutScript" Version="1.11.2" />
<PackageReference Include="LinePutScript" Version="1.11.3" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Panuon.WPF" Version="1.0.4" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.5" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.6" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">

View File

@ -52,7 +52,7 @@ namespace VPet_Simulator.Windows.Interface
/// <returns>是否超模</returns>
public static bool IsOverLoad(this Work work)
{//判断这个工作是否超模
if (work.LevelLimit > 1000)
if (work.LevelLimit > 100)
return true;
if (work.FinishBonus < 0)
return true;

View File

@ -0,0 +1,381 @@
using LinePutScript.Converter;
using LinePutScript;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.IGameSave;
namespace VPet_Simulator.Windows.Interface;
/// <summary>
/// 游戏存档 桌宠桌面端订制版本
/// </summary>
public class GameSave_VPet : IGameSave
{
/// <summary>
/// 宠物名字
/// </summary>
[Line(name: "name")]
public string Name { get; set; }
/// <summary>
/// 金钱
/// </summary>
[Line(Type = LPSConvert.ConvertType.ToFloat, Name = "money")]
public double Money { get; set; }
double exp { get; set; }
/// <summary>
/// 等级
/// </summary>
[Line]
public int Level { get; set; } = 1;
/// <summary>
/// 等级上限
/// </summary>
[Line]
public int LevelMax { get; set; } = 0;
/// <summary>
/// 经验值
/// </summary>
[Line(type: LPSConvert.ConvertType.ToFloat, name: "exp")]
public double Exp
{
get => exp;
set
{
int lun = LevelUpNeed();
while (value >= lun)
{
value -= lun;
LikabilityMax += 10;
if (Level++ > 1000 + LevelMax * 100)
{
LevelMax++;
Level = 100 * LevelMax;
}
lun = LevelUpNeed();
}
exp = value;
}
}
/// <summary>
/// 升级所需经验值
/// </summary>
public int LevelUpNeed() => (int)(Math.Pow((Level) * 10, 2) - Math.Pow((Level - 1) * 10, 2));
/// <summary>
/// 体力 0-100
/// </summary>
public double Strength { get => strength; set => strength = Math.Min(StrengthMax, Math.Max(0, value)); }
public double StrengthMax => 100 + (int)Math.Sqrt(Level) * 4;
[Line(Type = LPSConvert.ConvertType.ToFloat, IgnoreCase = true)]
protected double strength { get; set; }
/// <summary>
/// 待补充的体力,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat, IgnoreCase = true)]
public double StoreStrength { get; set; }
/// <summary>
/// 变化 体力
/// </summary>
public double ChangeStrength { get; set; } = 0;
public void StrengthChange(double value)
{
ChangeStrength += value;
Strength += value;
}
/// <summary>
/// 饱腹度
/// </summary>
public double StrengthFood
{
get => strengthFood; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthFood = 0;
}
else
strengthFood = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double strengthFood { get; set; }
/// <summary>
/// 待补充的饱腹度,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreStrengthFood { get; set; }
public void StrengthChangeFood(double value)
{
ChangeStrengthFood += value;
StrengthFood += value;
}
/// <summary>
/// 变化 食物
/// </summary>
public double ChangeStrengthFood { get; set; } = 0;
/// <summary>
/// 口渴度
/// </summary>
public double StrengthDrink
{
get => strengthDrink; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthDrink = 0;
}
else
strengthDrink = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double strengthDrink { get; set; }
/// <summary>
/// 待补充的口渴度,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreStrengthDrink { get; set; }
/// <summary>
/// 变化 口渴度
/// </summary>
public double ChangeStrengthDrink { get; set; } = 0;
public void StrengthChangeDrink(double value)
{
ChangeStrengthDrink += value;
StrengthDrink += value;
}
/// <summary>
/// 心情
/// </summary>
public double Feeling
{
get => feeling; set
{
value = Math.Min(FeelingMax, value);
if (value <= 0)
{
Health += value / 2;
Likability += value / 2;
feeling = 0;
}
else
feeling = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double feeling { get; set; }
/// <summary>
/// 待补充的心情,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreFeeling { get; set; }
/// <summary>
/// 变化 心情
/// </summary>
public double ChangeFeeling { get; set; } = 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)); }
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double health { get; set; }
/// <summary>
/// 好感度(隐藏)(累加值)
/// </summary>
public double Likability
{
get => likability; set
{
var max = LikabilityMax;
value = Math.Max(0, value);
if (value > max)
{
likability = max;
Health += value - max;
}
else
likability = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double likability { get; set; }
/// <summary>
/// 清除变化
/// </summary>
public void CleanChange()
{
ChangeStrength /= 2;
ChangeFeeling /= 2;
ChangeStrengthDrink /= 2;
ChangeStrengthFood /= 2;
}
/// <summary>
/// 取回被储存的体力
/// </summary>
public void StoreTake()
{
const int t = 10;
var s = StoreFeeling / t;
StoreFeeling -= s;
if (Math.Abs(StoreFeeling) < 1)
StoreFeeling = 0;
else
FeelingChange(s);
s = StoreStrength / t;
StoreStrength -= s;
if (Math.Abs(StoreStrength) < 1)
StoreStrength = 0;
else
StrengthChange(s);
s = StoreStrengthDrink / t;
StoreStrengthDrink -= s;
if (Math.Abs(StoreStrengthDrink) < 1)
StoreStrengthDrink = 0;
else
StrengthChangeDrink(s);
s = StoreStrengthFood / t;
StoreStrengthFood -= s;
if (Math.Abs(StoreStrengthFood) < 1)
StoreStrengthFood = 0;
else
StrengthChangeFood(s);
}
/// <summary>
/// 吃食物
/// </summary>
/// <param name="food">食物类</param>
public void EatFood(IFood food)
{
Exp += food.Exp;
var tmp = food.Strength / 2;
StrengthChange(tmp);
StoreStrength += tmp;
tmp = food.StrengthFood / 2;
StrengthChangeFood(tmp);
StoreStrengthFood += tmp;
tmp = food.StrengthDrink / 2;
StrengthChangeDrink(tmp);
StoreStrengthDrink += tmp;
tmp = food.Feeling / 2;
FeelingChange(tmp);
StoreFeeling += tmp;
Health += food.Health;
Likability += food.Likability;
}
/// <summary>
/// 宠物当前状态
/// </summary>
[Line(name: "mode")]
public ModeType Mode { get; set; } = ModeType.Nomal;
public double LikabilityMax { get; set; } = 100;
public double FeelingMax => 100 + (int)Math.Sqrt(Level) * 2;
/// <summary>
/// 经验值加成 TODO
/// </summary>
public double ExpBonus { get; set; } = 1;
/// <summary>
/// 计算宠物当前状态
/// </summary>
public ModeType CalMode()
{
int realhel = 60 - (Feeling / FeelingMax >= 80 ? 12 : 0) - (Likability >= 80 ? 12 : (Likability >= 40 ? 6 : 0));
//先从最次的开始
if (Health <= realhel)
{
//可以确认从状态不佳和生病二选一
if (Health <= realhel / 2)
{//生病
return ModeType.Ill;
}
else
{
return ModeType.PoorCondition;
}
}
//然后判断是高兴还是普通
double realfel = .90 - (Likability >= 80 ? .20 : (Likability >= 40 ? .10 : 0));
double felps = Feeling / FeelingMax;
if (felps >= realfel)
{
return ModeType.Happy;
}
else if (felps <= realfel / 2)
{
return ModeType.PoorCondition;
}
return ModeType.Nomal;
}
/// <summary>
/// 新游戏
/// </summary>
public GameSave_VPet(string name)
{
Name = name;
Money = 100;
Exp = 0;
Strength = 100;
StrengthFood = 100;
StrengthDrink = 100;
Feeling = 60;
Health = 100;
Likability = 0;
Mode = CalMode();
}
/// <summary>
/// 读档
/// </summary>
public GameSave_VPet()
{
}
/// <summary>
/// 读档
/// </summary>
public static GameSave_VPet Load(ILine data) => LPSConvert.DeserializeObject<GameSave_VPet>(data);
/// <summary>
/// 存档
/// </summary>
/// <returns>存档行</returns>
public Line ToLine()
{
//Line save = new Line("vpet", Name);
//save.SetFloat("money", Money);
//save.SetInt("exp", Exp);
//save.SetFloat("strength", Strength);
//save.SetFloat("strengthdrink", StrengthDrink);
//save.SetFloat("strengthfood", StrengthFood);
//save.SetFloat("feeling", Feeling);
//save.SetFloat("health", Health);
//save.SetFloat("Likability", Likability);
return LPSConvert.SerializeObject(this, "vpet");
}
}

View File

@ -26,10 +26,10 @@ namespace VPet_Simulator.Windows.Interface
/// </summary>
public GameSave_v2(string petname)
{
GameSave = new GameSave(petname);
GameSave = new GameSave_VPet(petname);
Statistics = new Statistics();
}
protected void load(ILPS lps, Statistics oldStatistics = null, IGameSave oldGameSave = null, ILPS olddata = null)
protected void load(ILPS lps, Statistics oldStatistics = null, GameSave_VPet oldGameSave = null, ILPS olddata = null)
{
if (lps.FindLine("statistics") == null)
{//尝试从老存档加载
@ -44,7 +44,7 @@ namespace VPet_Simulator.Windows.Interface
long hash;
if (vpet != null)
{
GameSave = Core.GameSave.Load(vpet);
GameSave = GameSave_VPet.Load(vpet);
hash = vpet.GetInt64("hash");
if (vpet.Remove("hash"))
{
@ -114,7 +114,7 @@ namespace VPet_Simulator.Windows.Interface
/// <param name="oldStatistics">老统计</param>
/// <param name="oldGameSave">老存档</param>
/// <param name="olddata">老数据</param>
public GameSave_v2(ILPS lps, Statistics oldStatistics = null, IGameSave oldGameSave = null, ILPS olddata = null)
public GameSave_v2(ILPS lps, Statistics oldStatistics = null, GameSave_VPet oldGameSave = null, ILPS olddata = null)
{
load(lps, oldStatistics, oldGameSave, olddata);
}
@ -135,7 +135,7 @@ namespace VPet_Simulator.Windows.Interface
/// <summary>
/// 游戏存档
/// </summary>
public IGameSave GameSave;
public GameSave_VPet GameSave;
/// <summary>
/// 统计
/// </summary>

View File

@ -16,9 +16,9 @@
<ProjectReference Include="..\VPet-Simulator.Core\VPet-Simulator.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LinePutScript" Version="1.11.2" />
<PackageReference Include="LinePutScript" Version="1.11.3" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Panuon.WPF" Version="1.0.4" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.5" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.6" />
</ItemGroup>
</Project>

View File

@ -1,346 +0,0 @@
using LinePutScript.Converter;
using LinePutScript;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.IGameSave;
namespace VPet_Simulator.Windows.Interface;
/// <summary>
/// 游戏存档 桌宠桌面端订制版本
/// </summary>
public class VpetSave : IGameSave
{
/// <summary>
/// 宠物名字
/// </summary>
[Line(name: "name")]
public string Name { get; set; }
/// <summary>
/// 金钱
/// </summary>
[Line(Type = LPSConvert.ConvertType.ToFloat, Name = "money")]
public double Money { get; set; }
/// <summary>
/// 经验值
/// </summary>
[Line(type: LPSConvert.ConvertType.ToFloat, name: "exp")] public double Exp { get; set; }
/// <summary>
/// 等级
/// </summary>
public int Level => Exp < 0 ? 1 : (int)(Math.Sqrt(Exp) / 10) + 1;
/// <summary>
/// 升级所需经验值
/// </summary>
/// <returns></returns>
public int LevelUpNeed() => (int)(Math.Pow((Level) * 10, 2));
/// <summary>
/// 体力 0-100
/// </summary>
public double Strength { get => strength; set => strength = Math.Min(StrengthMax, Math.Max(0, value)); }
public double StrengthMax { get; } = 100;
[Line(Type = LPSConvert.ConvertType.ToFloat, IgnoreCase = true)]
protected double strength { get; set; }
/// <summary>
/// 待补充的体力,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat, IgnoreCase = true)]
public double StoreStrength { get; set; }
/// <summary>
/// 变化 体力
/// </summary>
public double ChangeStrength { get; set; } = 0;
public void StrengthChange(double value)
{
ChangeStrength += value;
Strength += value;
}
/// <summary>
/// 饱腹度
/// </summary>
public double StrengthFood
{
get => strengthFood; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthFood = 0;
}
else
strengthFood = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double strengthFood { get; set; }
/// <summary>
/// 待补充的饱腹度,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreStrengthFood { get; set; }
public void StrengthChangeFood(double value)
{
ChangeStrengthFood += value;
StrengthFood += value;
}
/// <summary>
/// 变化 食物
/// </summary>
public double ChangeStrengthFood { get; set; } = 0;
/// <summary>
/// 口渴度
/// </summary>
public double StrengthDrink
{
get => strengthDrink; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthDrink = 0;
}
else
strengthDrink = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double strengthDrink { get; set; }
/// <summary>
/// 待补充的口渴度,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreStrengthDrink { get; set; }
/// <summary>
/// 变化 口渴度
/// </summary>
public double ChangeStrengthDrink { get; set; } = 0;
public void StrengthChangeDrink(double value)
{
ChangeStrengthDrink += value;
StrengthDrink += value;
}
/// <summary>
/// 心情
/// </summary>
public double Feeling
{
get => feeling; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value / 2;
Likability += value / 2;
feeling = 0;
}
else
feeling = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double feeling { get; set; }
/// <summary>
/// 待补充的心情,随着时间缓慢加给桌宠
/// </summary>//让游戏更有游戏性
[Line(Type = LPSConvert.ConvertType.ToFloat)]
public double StoreFeeling { get; set; }
/// <summary>
/// 变化 心情
/// </summary>
public double ChangeFeeling { get; set; } = 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)); }
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double health { get; set; }
/// <summary>
/// 好感度(隐藏)(累加值)
/// </summary>
public double Likability
{
get => likability; set
{
var max = LikabilityMax;
value = Math.Max(0, value);
if (value > max)
{
likability = max;
Health += value - max;
}
else
likability = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)]
protected double likability { get; set; }
/// <summary>
/// 清除变化
/// </summary>
public void CleanChange()
{
ChangeStrength /= 2;
ChangeFeeling /= 2;
ChangeStrengthDrink /= 2;
ChangeStrengthFood /= 2;
}
/// <summary>
/// 取回被储存的体力
/// </summary>
public void StoreTake()
{
const int t = 10;
var s = StoreFeeling / t;
StoreFeeling -= s;
if (Math.Abs(StoreFeeling) < 1)
StoreFeeling = 0;
else
FeelingChange(s);
s = StoreStrength / t;
StoreStrength -= s;
if (Math.Abs(StoreStrength) < 1)
StoreStrength = 0;
else
StrengthChange(s);
s = StoreStrengthDrink / t;
StoreStrengthDrink -= s;
if (Math.Abs(StoreStrengthDrink) < 1)
StoreStrengthDrink = 0;
else
StrengthChangeDrink(s);
s = StoreStrengthFood / t;
StoreStrengthFood -= s;
if (Math.Abs(StoreStrengthFood) < 1)
StoreStrengthFood = 0;
else
StrengthChangeFood(s);
}
/// <summary>
/// 吃食物
/// </summary>
/// <param name="food">食物类</param>
public void EatFood(IFood food)
{
Exp += food.Exp;
var tmp = food.Strength / 2;
StrengthChange(tmp);
StoreStrength += tmp;
tmp = food.StrengthFood / 2;
StrengthChangeFood(tmp);
StoreStrengthFood += tmp;
tmp = food.StrengthDrink / 2;
StrengthChangeDrink(tmp);
StoreStrengthDrink += tmp;
tmp = food.Feeling / 2;
FeelingChange(tmp);
StoreFeeling += tmp;
Health += food.Health;
Likability += food.Likability;
}
/// <summary>
/// 宠物当前状态
/// </summary>
[Line(name: "mode")]
public ModeType Mode { get; set; } = ModeType.Nomal;
public double LikabilityMax => 90 + Level * 10;
/// <summary>
/// 计算宠物当前状态
/// </summary>
public ModeType CalMode()
{
int realhel = 60 - (Feeling >= 80 ? 12 : 0) - (Likability >= 80 ? 12 : (Likability >= 40 ? 6 : 0));
//先从最次的开始
if (Health <= realhel)
{
//可以确认从状态不佳和生病二选一
if (Health <= realhel / 2)
{//生病
return ModeType.Ill;
}
else
{
return ModeType.PoorCondition;
}
}
//然后判断是高兴还是普通
realhel = 90 - (Likability >= 80 ? 20 : (Likability >= 40 ? 10 : 0));
if (Feeling >= realhel)
{
return ModeType.Happy;
}
else if (Feeling <= realhel / 2)
{
return ModeType.PoorCondition;
}
return ModeType.Nomal;
}
/// <summary>
/// 新游戏
/// </summary>
public VpetSave(string name)
{
Name = name;
Money = 100;
Exp = 0;
Strength = 100;
StrengthFood = 100;
StrengthDrink = 100;
Feeling = 60;
Health = 100;
Likability = 0;
Mode = CalMode();
}
/// <summary>
/// 读档
/// </summary>
public VpetSave()
{
}
/// <summary>
/// 读档
/// </summary>
public static GameSave Load(ILine data) => LPSConvert.DeserializeObject<GameSave>(data);
/// <summary>
/// 存档
/// </summary>
/// <returns>存档行</returns>
public Line ToLine()
{
//Line save = new Line("vpet", Name);
//save.SetFloat("money", Money);
//save.SetInt("exp", Exp);
//save.SetFloat("strength", Strength);
//save.SetFloat("strengthdrink", StrengthDrink);
//save.SetFloat("strengthfood", StrengthFood);
//save.SetFloat("feeling", Feeling);
//save.SetFloat("health", Health);
//save.SetFloat("Likability", Likability);
return LPSConvert.SerializeObject(this, "vpet");
}
}

View File

@ -685,7 +685,6 @@ namespace VPet_Simulator.Windows
}
}
public void RunAction(string action)
{
switch (action)
@ -1521,7 +1520,7 @@ namespace VPet_Simulator.Windows
//清空资源
Main.Resources = Application.Current.Resources;
//Main.MsgBar.Resources = Application.Current.Resources;
Main.MsgBar.This.Resources = Application.Current.Resources;
Main.ToolBar.Resources = Application.Current.Resources;
//加载主题:
@ -1590,6 +1589,24 @@ namespace VPet_Simulator.Windows
Main.TimeHandle += Handle_Steam;
Main.TimeHandle += (x) => DiagnosisUPLoad();
var tlv = Main.ToolBar.Tlv;
Main.ToolBar.gdPanel.Children.Remove(tlv);
var sp = new StackPanel();
Grid.SetColumnSpan(sp, 3);
sp.Orientation = System.Windows.Controls.Orientation.Horizontal;
sp.Children.Add(tlv);
tlvplus = new TextBlock();
tlvplus.Margin = new Thickness(1);
tlvplus.VerticalAlignment = VerticalAlignment.Bottom;
tlvplus.FontSize = 18;
tlvplus.Foreground = Function.ResourcesBrush(Function.BrushType.PrimaryText);
sp.Children.Add(tlvplus);
Main.ToolBar.gdPanel.Children.Add(sp);
Main.TimeUIHandle += MWUIHandle;
Main.ToolBar.EventMenuPanelShow += () => MWUIHandle(Main);
switch (Set["CGPT"][(gstr)"type"])
{
case "DIY":
@ -1904,6 +1921,15 @@ namespace VPet_Simulator.Windows
//}
}
TextBlock tlvplus;
private void MWUIHandle(Main main)
{
if (Main.ToolBar.BdrPanel.Visibility == Visibility.Visible)
{
tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100}" +
(GameSavesData.GameSave.LevelMax == 0 ? "" : $" x{GameSavesData.GameSave.LevelMax}");
}
}
#if NewYear
int newyearsay = 0;
private void NewYearHandle(Main main)

View File

@ -366,16 +366,20 @@ namespace VPet_Simulator.Windows
var latestsave = ds[i];
if (latestsave != null)
{
#if !DEBUG
try
{
#endif
if (SavesLoad(new LPS(File.ReadAllText(latestsave))))
return;
//MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate());
#if !DEBUG
}
catch // (Exception ex)
catch (Exception ex)
{
//MessageBoxX.Show("存档损毁,无法加载该存档\n可能是数据溢出/超模导致的" + '\n' + ex.Message, "存档损毁".Translate());
MessageBoxX.Show("存档损毁,无法加载该存档\n可能是数据溢出/超模导致的" + '\n' + ex.Message, "存档损毁".Translate());
}
#endif
}
}

View File

@ -205,12 +205,12 @@
<ItemGroup>
<PackageReference Include="Facepunch.Steamworks" Condition="'$(Platform)' == 'x64'" Version="2.3.3" />
<PackageReference Include="Facepunch.Steamworks.win32" Condition="'$(Platform)' == 'x86'" Version="2.3.3" />
<PackageReference Include="LinePutScript" Version="1.11.2" />
<PackageReference Include="LinePutScript" Version="1.11.3" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Panuon.WPF" Version="1.0.4" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.5" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VPet-Simulator.Core\VPet-Simulator.Core.csproj" />

View File

@ -6,7 +6,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:local="clr-namespace:VPet_Simulator.Windows"
mc:Ignorable="d" Height="550" Width="800" FontSize="14"
WindowStartupLocation="CenterScreen" Background="#E0F6FF" pu:WindowXCaption.Height="45"
WindowStartupLocation="CenterScreen"
Background="{DynamicResource PrimaryLighter}" pu:WindowXCaption.Height="45"
pu:WindowXCaption.Background="{DynamicResource DARKPrimary}" pu:WindowXCaption.Foreground="#FFFFFF"
pu:WindowXCaption.Buttons="Close" Icon="/Res/BetterBuy.png"
pu:WindowXCaption.ShadowColor="{DynamicResource ShadowColor}" Closing="WindowX_Closing">

View File

@ -97,7 +97,7 @@ public class SettingModel : ObservableClass<SettingModel>
private readonly ReflectionOptions _saveReflectionOptions = new() { CheckValueEquals = true };
public SettingModel()
: this(new(null, "")) { }
: this(new(null, "Setting#VPET:|\n")) { }
public SettingModel(Setting setting)
{

View File

@ -20,11 +20,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="LinePutScript" Version="1.11.2" />
<PackageReference Include="LinePutScript" Version="1.11.3" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Panuon.WPF" Version="1.0.4" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.5" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.17.6" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>