mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复等级更新错误
This commit is contained in:
parent
5920cf753d
commit
6a74e8e779
@ -14,11 +14,6 @@ namespace VPet_Simulator.Windows.Interface;
|
||||
/// </summary>
|
||||
public class GameSave_VPet : IGameSave
|
||||
{
|
||||
IMainWindow imw;
|
||||
public GameSave_VPet(IMainWindow imw)
|
||||
{
|
||||
this.imw = imw;
|
||||
}
|
||||
/// <summary>
|
||||
/// 宠物名字
|
||||
/// </summary>
|
||||
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否升级
|
||||
/// </summary>
|
||||
public bool IsLevelUp => true;
|
||||
/// <summary>
|
||||
/// 是否升级指上限
|
||||
/// </summary>
|
||||
public bool IsLevelMaxUp { get; set; }
|
||||
/// <summary>
|
||||
/// 之前的等级
|
||||
/// </summary>
|
||||
public int BeforeLevel { get; set; }
|
||||
/// <summary>
|
||||
/// 之前的等级上限
|
||||
/// </summary>
|
||||
public int BeforeLevelMax { get; set; }
|
||||
}
|
||||
public event Action<LevelUpEventArgs> Event_LevelUp;
|
||||
/// <summary>
|
||||
/// 玩家总共获得的经验值数量
|
||||
/// </summary>
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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级进行计算
|
||||
|
Loading…
Reference in New Issue
Block a user