From 2c7e01db2bfdd3eea7247a672534e6421ba12918 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 11 Aug 2023 01:48:27 +1000 Subject: [PATCH] =?UTF-8?q?=E5=90=83=E4=B8=9C=E8=A5=BF=E4=BC=9A=E5=90=83?= =?UTF-8?q?=E8=85=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Windows.Interface/Mod/Food.cs | 17 +++++++++++ VPet-Simulator.Windows/Function/CoreMOD.cs | 29 +++++++++++++++++-- VPet-Simulator.Windows/MainWindow.cs | 12 ++++---- VPet-Simulator.Windows/MainWindow.xaml.cs | 2 +- .../WinDesign/winBetterBuy.xaml.cs | 28 ++++++++++++++++-- 5 files changed, 77 insertions(+), 11 deletions(-) diff --git a/VPet-Simulator.Windows.Interface/Mod/Food.cs b/VPet-Simulator.Windows.Interface/Mod/Food.cs index e853331..908b5e3 100644 --- a/VPet-Simulator.Windows.Interface/Mod/Food.cs +++ b/VPet-Simulator.Windows.Interface/Mod/Food.cs @@ -127,6 +127,19 @@ namespace VPet_Simulator.Windows.Interface sb.AppendLine().Append(Desc.Translate()); desc = sb.ToString(); } + DateTime now = DateTime.Now; + DateTime eattime = imw.Set.PetData.GetDateTime("buytime_" + Name, now); + double eattimes = 0; + string descs; + if (eattime <= now) + { + if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink) + descs = "腻味程度".Translate(); + } + else + { + eattimes = (eattime - now).TotalHours; + } return desc; } } @@ -143,6 +156,9 @@ namespace VPet_Simulator.Windows.Interface /// [Line(ignoreCase: true)] public string Image; + + private IMainWindow imw; + /// /// 加载物品图片 /// @@ -150,6 +166,7 @@ namespace VPet_Simulator.Windows.Interface { ImageSource = imw.ImageSources.FindImage(Image ?? Name, "food"); Star = imw.Set["betterbuy"]["star"].GetInfos().Contains(Name); + this.imw = imw; } } } diff --git a/VPet-Simulator.Windows/Function/CoreMOD.cs b/VPet-Simulator.Windows/Function/CoreMOD.cs index 3b2f3a0..99dd44c 100644 --- a/VPet-Simulator.Windows/Function/CoreMOD.cs +++ b/VPet-Simulator.Windows/Function/CoreMOD.cs @@ -15,11 +15,12 @@ namespace VPet_Simulator.Windows { public class CoreMOD { - public static List LoadedDLL { get; } = new List() + public static HashSet LoadedDLL { get; } = new HashSet() { "ChatGPT.API.Framework.dll","Panuon.WPF.dll","steam_api.dll","Panuon.WPF.UI.dll","steam_api64.dll", "LinePutScript.dll","Newtonsoft.Json.dll","Facepunch.Steamworks.Win32.dll", "Facepunch.Steamworks.Win64.dll", - "VPet-Simulator.Core.dll","VPet-Simulator.Windows.Interface.dll","LinePutScript.Localization.WPF.dll" + "VPet-Simulator.Core.dll","VPet-Simulator.Windows.Interface.dll","LinePutScript.Localization.WPF.dll", + "CSCore.dll" }; public static string NowLoading = null; public string Name; @@ -257,6 +258,30 @@ namespace VPet_Simulator.Windows } public static class ExtensionSetting { + /// + /// 吃食物 附带倍率 + /// + /// 存档 + /// 食物 + /// 默认1倍 + public static void EatFood(this GameSave save, IFood food, double buff) + { + save.Exp += food.Exp * buff; + var tmp = food.Strength / 2 * buff; + save.StrengthChange(tmp); + save.StoreStrength += tmp; + tmp = food.StrengthFood / 2 * buff; + save.StrengthChangeFood(tmp); + save.StoreStrengthFood += tmp; + tmp = food.StrengthDrink / 2 * buff; + save.StrengthChangeDrink(tmp); + save.StoreStrengthDrink += tmp; + tmp = food.Feeling / 2 * buff; + save.FeelingChange(tmp); + save.StoreFeeling += tmp * buff; + save.Health += food.Health * buff; + save.Likability += food.Likability * buff; + } public static bool IsOnMod(this Setting t, string ModName) { if (ModName == "Core") diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index bda343e..deef4a7 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -4,10 +4,8 @@ using LinePutScript; using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; -using System.Data; using System.Diagnostics; using System.IO; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Timers; @@ -346,7 +344,7 @@ namespace VPet_Simulator.Windows switch (Main.State) { case Main.WorkingState.Work: - if (Core.Graph.GraphConfig.Works[Main.StateID].Type == GraphHelper.Work.WorkType.Work) + if (Main.nowWork.Type == GraphHelper.Work.WorkType.Work) stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval; else stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval; @@ -459,11 +457,13 @@ namespace VPet_Simulator.Windows } private void MusicTimer_Elapsed(object sender, ElapsedEventArgs e) { - if (catch_MusicVolCount >= 10) + catch_MusicVolSum += AudioPlayingVolume(); + catch_MusicVolCount++; + if (catch_MusicVolCount >= 20) { double ans = catch_MusicVolSum / catch_MusicVolCount; - catch_MusicVolSum = 0; - catch_MusicVolCount = 0; + catch_MusicVolSum /= 4; + catch_MusicVolCount /= 4; if (ans > Set.MusicCatch) { var bef = CurrMusicType; diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 7e3732b..f658f3c 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -288,7 +288,7 @@ namespace VPet_Simulator.Windows Set["CGPT"].Remove(cgpteb); } //音乐识别timer加载 - MusicTimer = new System.Timers.Timer(200) + MusicTimer = new System.Timers.Timer(100) { AutoReset = false }; diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs index 2446c89..88f4bf1 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs @@ -19,6 +19,7 @@ using System.Windows.Media.Imaging; using System.Windows.Shapes; using VPet_Simulator.Core; using VPet_Simulator.Windows.Interface; +using static System.Windows.Forms.LinkLabel; using static VPet_Simulator.Core.GraphCore; using static VPet_Simulator.Core.GraphInfo; using static VPet_Simulator.Core.IGraph; @@ -173,8 +174,26 @@ namespace VPet_Simulator.Windows , "金钱不足".Translate()); return; } + + //获取吃腻时间 + + DateTime now = DateTime.Now; + DateTime eattime = mw.Set.PetData.GetDateTime("buytime_" + item.Name, now); + double eattimes = 0; + if (eattime <= now) + { + eattime = now; + } + else + { + eattimes = (eattime - now).TotalHours; + } //开始加点 - mw.Core.Save.EatFood(item); + mw.Core.Save.EatFood(item, Math.Max(0.5, 1 - Math.Sqrt(eattimes) * 0.01)); + //吃腻了 + eattimes += 2; + mw.Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes)); + mw.Core.Save.Money -= item.Price; //统计 mw.Set.Statistics[(gint)("buy_" + item.Name)]++; @@ -203,13 +222,18 @@ namespace VPet_Simulator.Windows mw.Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price; break; } + } if (!_puswitch.IsChecked.Value) TryClose(); var name = mw.Core.Graph.FindName(item.Type == Food.FoodType.Drink ? GraphType.Drink : GraphType.Eat); var ig = mw.Core.Graph.FindGraph(name, AnimatType.Single, mw.Core.Save.Mode); var b = mw.Main.FindDisplayBorder(ig); - ig.Run(b, item.ImageSource, mw.Main.DisplayToNomal); + ig.Run(b, item.ImageSource, () => + { + mw.Main.EventTimer_Elapsed(); + mw.Main.DisplayToNomal(); + }); } private void BtnSearch_Click(object sender, RoutedEventArgs e)