From 78b84adf32d249d6139bb736e6fe3a070d03032a Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 15 Mar 2024 18:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E6=9C=BA=E5=8A=9F=E8=83=BD=E9=A2=84?= =?UTF-8?q?=E5=A4=87=20+=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MainLogic.cs | 31 +++++------ VPet-Simulator.Core/Display/WorkTimer.xaml.cs | 32 ++++++----- VPet-Simulator.Windows/MainWindow.cs | 11 ++-- VPet-Simulator.Windows/MainWindow.xaml.cs | 30 ++++++++--- .../WinDesign/winGameSetting.xaml | 5 +- .../WinDesign/winMutiPlayer.xaml | 21 ++++++++ .../WinDesign/winMutiPlayer.xaml.cs | 54 +++++++++++++++++++ 7 files changed, 136 insertions(+), 48 deletions(-) create mode 100644 VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml create mode 100644 VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index d33bf69..07c0782 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -156,6 +156,7 @@ namespace VPet_Simulator.Core labeldisplaytimer.Start(); }); } + public Work NowWork; /// /// 根据消耗计算相关数据 /// @@ -171,6 +172,8 @@ namespace VPet_Simulator.Core freedrop = Math.Min(Math.Sqrt(freedrop) * TimePass / 2, Core.Save.FeelingMax / 400); switch (State) { + case WorkingState.Empty: + break; case WorkingState.Sleep: //睡觉不消耗 Core.Save.StrengthChange(TimePass * 2); @@ -189,9 +192,10 @@ namespace VPet_Simulator.Core LastInteractionTime = DateTime.Now; break; case WorkingState.Work: - var nowwork = nowWork; - var needfood = TimePass * nowwork.StrengthFood; - var needdrink = TimePass * nowwork.StrengthDrink; + if (NowWork == null) + break; + var needfood = TimePass * NowWork.StrengthFood; + var needdrink = TimePass * NowWork.StrengthDrink; double efficiency = 0; int addhealth = -2; if (Core.Save.StrengthFood <= 25) @@ -232,19 +236,19 @@ namespace VPet_Simulator.Core } if (addhealth > 0) Core.Save.Health += addhealth * TimePass; - var addmoney = Math.Max(0, nowwork.MoneyBase * (1.500000000 * efficiency - 0.5)); - if (nowwork.Type == Work.WorkType.Work) + var addmoney = Math.Max(0, NowWork.MoneyBase * (1.500000000 * efficiency - 0.5)); + if (NowWork.Type == Work.WorkType.Work) Core.Save.Money += addmoney; else Core.Save.Exp += addmoney; WorkTimer.GetCount += addmoney; - if (nowwork.Type == Work.WorkType.Play) + if (NowWork.Type == Work.WorkType.Play) { LastInteractionTime = DateTime.Now; - Core.Save.FeelingChange(-nowwork.Feeling * TimePass); + Core.Save.FeelingChange(-NowWork.Feeling * TimePass); } else - Core.Save.FeelingChange(-freedrop * nowwork.Feeling); + Core.Save.FeelingChange(-freedrop * NowWork.Feeling); if (Core.Save.Mode == IGameSave.ModeType.Ill)//生病时候停止工作 WorkTimer.Stop(); break; @@ -479,14 +483,7 @@ namespace VPet_Simulator.Core /// 当前状态 /// public WorkingState State = WorkingState.Nomal; - /// - /// 当前状态辅助ID - /// - public int StateID = 0; - /// - /// 当前工作 - /// - public GraphHelper.Work nowWork => Core.Graph.GraphConfig.Works[StateID]; + /// /// 当前正在的状态 /// @@ -552,7 +549,7 @@ namespace VPet_Simulator.Core { if (!Core.Controller.EnableFunction || Core.Save.Mode != IGameSave.ModeType.Ill) if (!Core.Controller.EnableFunction || Core.Save.Level >= work.LevelLimit) - if (State == Main.WorkingState.Work && StateID == Core.Graph.GraphConfig.Works.IndexOf(work)) + if (State == Main.WorkingState.Work && NowWork.Name == work.Name) WorkTimer.Stop(); else { diff --git a/VPet-Simulator.Core/Display/WorkTimer.xaml.cs b/VPet-Simulator.Core/Display/WorkTimer.xaml.cs index c0fc738..eaf9064 100644 --- a/VPet-Simulator.Core/Display/WorkTimer.xaml.cs +++ b/VPet-Simulator.Core/Display/WorkTimer.xaml.cs @@ -82,23 +82,23 @@ namespace VPet_Simulator.Core if (Visibility == Visibility.Collapsed) return; TimeSpan ts = DateTime.Now - StartTime; TimeSpan tleft; - if (ts.TotalMinutes > nowWork.Time) + if (ts.TotalMinutes > m.NowWork.Time) { //学完了,停止 //ts = TimeSpan.FromMinutes(MaxTime); //tleft = TimeSpan.Zero; //PBLeft.Value = MaxTime; - FinishWorkInfo fwi = new FinishWorkInfo(nowWork, GetCount); + FinishWorkInfo fwi = new FinishWorkInfo(m.NowWork, GetCount); E_FinishWork?.Invoke(fwi); - if (nowWork.Type == Work.WorkType.Work) + if (m.NowWork.Type == Work.WorkType.Work) { - m.Core.Save.Money += GetCount * nowWork.FinishBonus; + m.Core.Save.Money += GetCount * m.NowWork.FinishBonus; Stop(() => m.SayRnd(LocalizeCore.Translate("{2}完成啦, 累计赚了 {0:f2} 金钱\n共计花费了{1}分钟", fwi.count, fwi.spendtime, fwi.work.NameTrans), true)); } else { - m.Core.Save.Exp += GetCount * nowWork.FinishBonus; + m.Core.Save.Exp += GetCount * m.NowWork.FinishBonus; Stop(() => m.SayRnd(LocalizeCore.Translate("{2}完成啦, 累计获得 {0:f2} 经验\n共计花费了{1}分钟", fwi.count, fwi.spendtime, fwi.work.NameTrans), true)); } @@ -106,7 +106,7 @@ namespace VPet_Simulator.Core } else { - tleft = TimeSpan.FromMinutes(nowWork.Time) - ts; + tleft = TimeSpan.FromMinutes(m.NowWork.Time) - ts; PBLeft.Value = ts.TotalMinutes; } switch (DisplayType) @@ -118,7 +118,7 @@ namespace VPet_Simulator.Core ShowTimeSpan(tleft); break; case 2: tNumber.Text = GetCount.ToString("f0"); - if (nowWork.Type == Work.WorkType.Work) + if (m.NowWork.Type == Work.WorkType.Work) tNumberUnit.Text = LocalizeCore.Translate("钱"); else tNumberUnit.Text = "EXP"; @@ -154,18 +154,18 @@ namespace VPet_Simulator.Core else { DisplayBorder.Visibility = Visibility.Visible; - btnStop.Content = LocalizeCore.Translate("停止") + nowWork.NameTrans; + btnStop.Content = LocalizeCore.Translate("停止") + m.NowWork.NameTrans; switch (DisplayType) { default: case 0: - tNow.Text = LocalizeCore.Translate("当前已{0}", nowWork.NameTrans); + tNow.Text = LocalizeCore.Translate("当前已{0}", m.NowWork.NameTrans); break; case 1: - tNow.Text = LocalizeCore.Translate("剩余{0}时间", nowWork.NameTrans); + tNow.Text = LocalizeCore.Translate("剩余{0}时间", m.NowWork.NameTrans); break; case 2: - if (nowWork.Type == Work.WorkType.Work) + if (m.NowWork.Type == Work.WorkType.Work) tNow.Text = LocalizeCore.Translate("累计金钱收益"); else tNow.Text = LocalizeCore.Translate("获得经验值"); @@ -187,7 +187,7 @@ namespace VPet_Simulator.Core // return; Visibility = Visibility.Visible; m.State = Main.WorkingState.Work; - m.StateID = m.Core.Graph.GraphConfig.Works.IndexOf(work); + m.NowWork = work; StartTime = DateTime.Now; GetCount = 0; @@ -195,24 +195,22 @@ namespace VPet_Simulator.Core work.Display(m); PBLeft.Maximum = work.Time; - nowWork = work; DisplayUI(); } - private Work nowWork; /// /// 停止工作 /// /// public void Stop(Action @then = null) { - if (m.State == Main.WorkingState.Work && nowWork != null) + if (m.State == Main.WorkingState.Work && m.NowWork != null) { - FinishWorkInfo fwi = new FinishWorkInfo(nowWork, GetCount); + FinishWorkInfo fwi = new FinishWorkInfo(m.NowWork, GetCount); E_FinishWork?.Invoke(fwi); } Visibility = Visibility.Collapsed; m.State = Main.WorkingState.Nomal; - m.Display(nowWork.Graph, AnimatType.C_End, then ?? m.DisplayNomal); + m.Display(m.NowWork.Graph, AnimatType.C_End, then ?? m.DisplayNomal); } private void btnStop_Click(object sender, RoutedEventArgs e) { diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index a1ea75f..a5b4a4d 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -763,7 +763,7 @@ namespace VPet_Simulator.Windows switch (Main.State) { case Main.WorkingState.Work: - if (Main.nowWork.Type == Work.WorkType.Work) + if (Main.NowWork.Type == Work.WorkType.Work) stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval; else stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval; @@ -940,7 +940,7 @@ namespace VPet_Simulator.Windows switch (obj.State) { case Main.WorkingState.Work: - SteamFriends.SetRichPresence("work", obj.nowWork.Name.Translate()); + SteamFriends.SetRichPresence("work", obj.NowWork.Name.Translate()); SteamFriends.SetRichPresence("steam_display", "#Status_Work"); break; case Main.WorkingState.Sleep: @@ -1345,9 +1345,8 @@ namespace VPet_Simulator.Windows /// 加载游戏 /// /// MOD地址 - public async void GameLoad(List Path) + public async Task GameLoad(List Path) { - Path = Path.Distinct().ToList(); await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD")); //加载mod @@ -1997,6 +1996,10 @@ namespace VPet_Simulator.Windows tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100} x{GameSavesData.GameSave.LevelMax}"; } } + + + + #if NewYear int newyearsay = 0; private void NewYearHandle(Main main) diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index cd042a5..e7d2291 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -21,6 +21,7 @@ using static VPet_Simulator.Core.GraphInfo; using System.Globalization; using LinePutScript.Dictionary; using Steamworks.Data; +using VPet_Simulator.Windows.WinDesign; namespace VPet_Simulator.Windows { @@ -100,7 +101,7 @@ namespace VPet_Simulator.Windows GameInitialization(); - Task.Run(() => + Task.Run(async () => { //加载所有MOD List Path = new List(); @@ -216,10 +217,27 @@ namespace VPet_Simulator.Windows else//新玩家,默认设置为 Set["CGPT"][(gstr)"type"] = "LB"; - GameLoad(Path); + await GameLoad(Path); + if (IsSteamUser) + Dispatcher.Invoke(() => + { + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "访客表".Translate(), () => + { + if (winMutiPlayer == null) + { + winMutiPlayer = new winMutiPlayer(this); + winMutiPlayer.Show(); + } + else + { + winMutiPlayer.Focus(); + } + }); + }); + }); } - + internal winMutiPlayer winMutiPlayer; public new void Close() { @@ -372,9 +390,9 @@ namespace VPet_Simulator.Windows try { #endif - if (SavesLoad(new LPS(File.ReadAllText(latestsave)))) - return; - //MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate()); + if (SavesLoad(new LPS(File.ReadAllText(latestsave)))) + return; + //MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate()); #if !DEBUG } catch (Exception ex) diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index 0ef0e16..5fbc503 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -396,10 +396,7 @@ ToolTip="{ll:Str '重新开始新游戏,重置统计等信息\ 对于想要获得脱离超模从而获得成就非常有帮助'}" Click="restart_click" />