diff --git a/VPet-Simulator.Windows.Interface/GameSave_VPet.cs b/VPet-Simulator.Windows.Interface/GameSave_VPet.cs
index 1feb76c..a7090c9 100644
--- a/VPet-Simulator.Windows.Interface/GameSave_VPet.cs
+++ b/VPet-Simulator.Windows.Interface/GameSave_VPet.cs
@@ -14,11 +14,6 @@ namespace VPet_Simulator.Windows.Interface;
///
public class GameSave_VPet : IGameSave
{
- IMainWindow imw;
- public GameSave_VPet(IMainWindow imw)
- {
- this.imw = imw;
- }
///
/// 宠物名字
///
@@ -58,6 +53,8 @@ public class GameSave_VPet : IGameSave
int lun = LevelUpNeed();
bool islevelup = false;
bool islevelmaxup = false;
+ int BeforeLevel = Level;
+ int BeforeLevelMax = LevelMax;
while (value >= lun)
{
islevelup = true;
@@ -71,26 +68,38 @@ public class GameSave_VPet : IGameSave
}
lun = LevelUpNeed();
}
+ exp = value;
if (islevelup)
- {//播放等级升级动画
- var gf = imw.Core.Graph.FindGraph("levelup", GraphInfo.AnimatType.Single, Mode);
- if (gf != null)
+ {
+ Event_LevelUp?.Invoke(new LevelUpEventArgs()
{
- imw.Main.Display(gf, imw.Main.DisplayToNomal);
- }
- }
- if (islevelmaxup)
- {//告知用户上限等级上升
- imw.Dispatcher.Invoke(() =>
- {
- imw.Main.Say("邦邦咔邦,{0}等级突破了!".Translate(Name));
- MessageBoxX.Show("系统提示\n您的桌宠等级已经突破\nLv{0}→LV{1} x{2}\n已突破为尊贵的x{3}阶".Translate(
- 1000 + (LevelMax - 1) * 100, 100 * LevelMax, LevelMax), "桌宠等级突破".Translate());
+ IsLevelMaxUp = islevelmaxup,
+ BeforeLevel = BeforeLevel,
+ BeforeLevelMax = BeforeLevelMax
});
}
- exp = value;
}
}
+ public class LevelUpEventArgs : EventArgs
+ {
+ ///
+ /// 是否升级
+ ///
+ public bool IsLevelUp => true;
+ ///
+ /// 是否升级指上限
+ ///
+ public bool IsLevelMaxUp { get; set; }
+ ///
+ /// 之前的等级
+ ///
+ public int BeforeLevel { get; set; }
+ ///
+ /// 之前的等级上限
+ ///
+ public int BeforeLevelMax { get; set; }
+ }
+ public event Action Event_LevelUp;
///
/// 玩家总共获得的经验值数量
///
diff --git a/VPet-Simulator.Windows.Interface/GameSave_v2.cs b/VPet-Simulator.Windows.Interface/GameSave_v2.cs
index 41ae366..666f87f 100644
--- a/VPet-Simulator.Windows.Interface/GameSave_v2.cs
+++ b/VPet-Simulator.Windows.Interface/GameSave_v2.cs
@@ -5,6 +5,8 @@ using Panuon.WPF.UI;
using System;
using System.Security.Cryptography;
using System.Text;
+using static VPet_Simulator.Core.GraphHelper;
+using VPet_Simulator.Core;
namespace VPet_Simulator.Windows.Interface
{
@@ -21,6 +23,7 @@ namespace VPet_Simulator.Windows.Interface
GameSave = new GameSave_VPet(petname);
Statistics = new Statistics();
}
+
protected void load(ILPS lps, Statistics oldStatistics = null, GameSave_VPet oldGameSave = null, ILPS olddata = null)
{
if (lps.FindLine("statistics") == null)
diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs
index 2f8b540..73e9e26 100644
--- a/VPet-Simulator.Windows/MainWindow.cs
+++ b/VPet-Simulator.Windows/MainWindow.cs
@@ -2360,5 +2360,24 @@ namespace VPet_Simulator.Windows
return works;
}
public System.Windows.Controls.MenuItem WorkStarMenu;
+
+ public void LevelUP(GameSave_VPet.LevelUpEventArgs args)
+ {
+ var gf = Core.Graph.FindGraph("levelup", GraphInfo.AnimatType.Single, GameSavesData.GameSave.Mode);
+ if (gf != null)
+ {
+ Main.Display(gf, Main.DisplayToNomal);
+ }
+ if (args.IsLevelMaxUp)
+ {//告知用户上限等级上升
+ Dispatcher.Invoke(() =>
+ {
+ Main.Say("邦邦咔邦,{0}等级突破了!".Translate(Name));
+ MessageBoxX.Show("系统提示\n您的桌宠等级已经突破\nLv{0}→LV{1} x{2}\n已突破为尊贵的x{3}阶".Translate(
+ 1000 + args.BeforeLevelMax * 100, 100 * GameSavesData.GameSave.LevelMax, GameSavesData.GameSave.LevelMax),
+ "桌宠等级突破".Translate());
+ });
+ }
+ }
}
}
diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs
index 01dd83e..0f5e91c 100644
--- a/VPet-Simulator.Windows/MainWindow.xaml.cs
+++ b/VPet-Simulator.Windows/MainWindow.xaml.cs
@@ -66,7 +66,7 @@ namespace VPet_Simulator.Windows
{
return line.GetString();
}
- if(str.Contains('_') && double.TryParse(str.Split('_').Last(), out double d))
+ if (str.Contains('_') && double.TryParse(str.Split('_').Last(), out double d))
return d.ToString();
return null;
};
@@ -551,6 +551,7 @@ namespace VPet_Simulator.Windows
GameSavesData = new GameSave_v2(petname.Translate());
Core.Save = GameSavesData.GameSave;
HashCheck = HashCheck;
+ GameSavesData.GameSave.Event_LevelUp += LevelUP;
}
private void WorkTimer_E_FinishWork(WorkTimer.FinishWorkInfo obj)
diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
index d55afab..450c48b 100644
--- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
+++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
@@ -1483,6 +1483,8 @@ namespace VPet_Simulator.Windows
var oldsave = mw.GameSavesData;
mw.GameSavesData = new GameSave_v2(mw.Core.Save.Name);
mw.Core.Save = mw.GameSavesData.GameSave;
+ mw.GameSavesData.GameSave.Event_LevelUp += mw.LevelUP;
+
if (oldsave.HashCheck) // 对于重开无作弊的玩家保留统计
{
mw.GameSavesData.Statistics = oldsave.Statistics;
@@ -1627,6 +1629,7 @@ namespace VPet_Simulator.Windows
GameSave_v2 ogs = mw.GameSavesData;
mw.GameSavesData = new GameSave_v2(ogs.GameSave.Name);
mw.GameSavesData.Statistics[(gint)"stat_total_time"] = playtime * 60;
+ mw.GameSavesData.GameSave.Event_LevelUp += mw.LevelUP;
//同步等级
//按2小时=1级进行计算