From 25832f18627b68cb5fbeea54ae9960f0e7597e97 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Thu, 24 Aug 2023 05:49:16 +1000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=A0=E7=89=A9=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E5=90=83=E4=B8=9C=E8=A5=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MainDisplay.cs | 17 ++++ VPet-Simulator.Windows.Interface/Mod/Food.cs | 21 ++++- VPet-Simulator.Windows.Interface/Setting.cs | 14 +++ VPet-Simulator.Windows/MainWindow.cs | 91 ++++++++++++++++++- .../VPet-Simulator.Windows.csproj | 7 -- .../WinDesign/winBetterBuy.xaml | 31 +++++-- .../WinDesign/winBetterBuy.xaml.cs | 89 +++++------------- .../WinDesign/winTrusteeShip.xaml | 13 --- .../WinDesign/winTrusteeShip.xaml.cs | 27 ------ .../mod/0000_core/lang/en/Prog2308.lps | 5 +- .../mod/0000_core/lang/zh-Hans/Prog2308.lps | 5 +- .../mod/0000_core/lang/zh-Hant/Prog2308.lps | 5 +- 12 files changed, 198 insertions(+), 127 deletions(-) delete mode 100644 VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml delete mode 100644 VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml.cs diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index 09c1aeb..6f03d94 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -9,6 +9,7 @@ using LinePutScript.Localization.WPF; using static VPet_Simulator.Core.GraphInfo; using System.Xml.Linq; using System.Linq; +using System.Windows.Media; namespace VPet_Simulator.Core { @@ -641,5 +642,21 @@ namespace VPet_Simulator.Core } } + /// + /// 显示夹层动画 + /// + /// 动画类型 + /// 夹层内容 + /// 动画结束后操作 + public void Display(GraphType Type, ImageSource img, Action EndAction) + { + var name = Core.Graph.FindName(Type); + var ig = Core.Graph.FindGraph(name, AnimatType.Single, Core.Save.Mode); + if (ig != null) + { + var b = FindDisplayBorder(ig); + ig.Run(b, img, EndAction); + } + } } } diff --git a/VPet-Simulator.Windows.Interface/Mod/Food.cs b/VPet-Simulator.Windows.Interface/Mod/Food.cs index 0dd49bb..b1b0266 100644 --- a/VPet-Simulator.Windows.Interface/Mod/Food.cs +++ b/VPet-Simulator.Windows.Interface/Mod/Food.cs @@ -53,6 +53,10 @@ namespace VPet_Simulator.Windows.Interface /// 礼品 (没做) /// Gift, + /// + /// 不超模的好食物 + /// + NoOverLoad, } /// /// 食物类型 @@ -128,7 +132,7 @@ namespace VPet_Simulator.Windows.Interface sb.Append("好感度".Translate() + ":\t").Append(Likability > 0 ? "+" : "").Append(Likability.ToString("f2")); desc = sb.ToString(); } - + return desc + '\n' + descs + '\n' + Desc.Translate(); } } @@ -145,8 +149,19 @@ namespace VPet_Simulator.Windows.Interface /// [Line(ignoreCase: true)] public string Image; - - + private bool? isoverload = null; + /// + /// 该食物是否超模 + /// + public bool IsOverLoad() + { + if (isoverload == null) + { + double realp = ((Exp / 4 + Strength / 5 + StrengthDrink / 3 + StrengthFood / 2 + Feeling / 6) / 3 + Health + Likability * 5); + isoverload = Price > realp * 1.3 || Price < realp * 0.7;//30%容错 + } + return isoverload.Value; + } /// /// 加载物品图片 /// diff --git a/VPet-Simulator.Windows.Interface/Setting.cs b/VPet-Simulator.Windows.Interface/Setting.cs index e20c9b3..cf999af 100644 --- a/VPet-Simulator.Windows.Interface/Setting.cs +++ b/VPet-Simulator.Windows.Interface/Setting.cs @@ -415,5 +415,19 @@ namespace VPet_Simulator.Windows.Interface get => this["gameconfig"].GetInt("resolution", 500); set => this["gameconfig"].SetInt("resolution", value); } + + bool autobuy; + /// + /// 允许桌宠自动购买食品 + /// + public bool AutoBuy + { + get => autobuy; + set + { + autobuy = value; + this["gameconfig"].SetBool("allowmove", !value); + } + } } } diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 66cf1b5..6b227ac 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -2,6 +2,7 @@ using CSCore.CoreAudioAPI; using LinePutScript; using LinePutScript.Localization.WPF; +using Panuon.WPF.UI; using Steamworks; using System; using System.Collections.Generic; @@ -236,7 +237,42 @@ namespace VPet_Simulator.Windows int lowstrengthAskCountDrink = 20; private void lowStrength() { - if (Core.Save.Mode == GameSave.ModeType.Happy || Core.Save.Mode == GameSave.ModeType.Nomal) + if (Set.AutoBuy && Core.Save.Money >= 100) + { + var havemoney = Core.Save.Money * 1.2; + List food = Foods.FindAll(x => x.Price >= 2 && x.Health >= 0 && x.Exp >= 0 && x.Likability >= 0 && x.Price < havemoney //桌宠不吃负面的食物 + && x.IsOverLoad() // 不吃超模食物 + ); + + if (Core.Save.StrengthFood < 75) + { + if (Core.Save.StrengthFood < 50) + {//太饿了,找正餐 + food = food.FindAll(x => x.Type == Food.FoodType.Meal && x.StrengthFood > 20); + } + else + {//找零食 + food = food.FindAll(x => x.Type == Food.FoodType.Snack && x.StrengthFood > 10); + } + if (food.Count == 0) + return; + var item = food[Function.Rnd.Next(food.Count)]; + Core.Save.Money -= item.Price * 1.2; + TakeItem(item); + Main.Display(GraphType.Eat, item.ImageSource, Main.DisplayToNomal); + } + else if (Core.Save.StrengthDrink < 75) + { + food = food.FindAll(x => x.Type == Food.FoodType.Drink && x.StrengthDrink > 10); + if (food.Count == 0) + return; + var item = food[Function.Rnd.Next(food.Count)]; + Core.Save.Money -= item.Price * 1.2; + TakeItem(item); + Main.Display(GraphType.Drink, item.ImageSource, Main.DisplayToNomal); + } + } + else if (Core.Save.Mode == GameSave.ModeType.Happy || Core.Save.Mode == GameSave.ModeType.Nomal) { if (Core.Save.StrengthFood < 75 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0) { @@ -339,6 +375,59 @@ namespace VPet_Simulator.Windows } + /// + /// 使用/食用物品 (不包括显示动画) + /// + /// 物品 + public void TakeItem(Food item) + { + //获取吃腻时间 + DateTime now = DateTime.Now; + DateTime eattime = Set.PetData.GetDateTime("buytime_" + item.Name, now); + double eattimes = 0; + if (eattime > now) + { + eattimes = (eattime - now).TotalHours; + } + //开始加点 + Core.Save.EatFood(item, Math.Max(0.5, 1 - Math.Pow(eattimes, 2) * 0.01)); + //吃腻了 + eattimes += 2; + Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes)); + //通知 + item.LoadEatTimeSource(this); + item.NotifyOfPropertyChange("Eattime"); + + Core.Save.Money -= item.Price; + //统计 + Set.Statistics[(gint)("buy_" + item.Name)]++; + Set.Statistics[(gdbe)"stat_betterbuy"] += item.Price; + switch (item.Type) + { + case Food.FoodType.Food: + Set.Statistics[(gdbe)"stat_bb_food"] += item.Price; + break; + case Food.FoodType.Drink: + Set.Statistics[(gdbe)"stat_bb_drink"] += item.Price; + break; + case Food.FoodType.Drug: + Set.Statistics[(gdbe)"stat_bb_drug"] += item.Price; + break; + case Food.FoodType.Snack: + Set.Statistics[(gdbe)"stat_bb_snack"] += item.Price; + break; + case Food.FoodType.Functional: + Set.Statistics[(gdbe)"stat_bb_functional"] += item.Price; + break; + case Food.FoodType.Meal: + Set.Statistics[(gdbe)"stat_bb_meal"] += item.Price; + break; + case Food.FoodType.Gift: + Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price; + break; + } + } + public void RunAction(string action) { diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index 30d0dc8..5db6307 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -174,9 +174,6 @@ winReport.xaml - - winTrusteeShip.xaml - Designer MSBuild:Compile @@ -234,10 +231,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml index 5393a02..9a0a1c1 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml @@ -49,16 +49,31 @@ Click="BtnSearch_Click" /> - : $ + : $ - + + + + + + + + + diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs index f7d32c9..6e8bc26 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs @@ -193,12 +193,11 @@ namespace VPet_Simulator.Windows //PageDetail.RaiseEvent(eventArg); } bool showeatanm = true; + private void BtnBuy_Click(object sender, RoutedEventArgs e) { - var Button = sender as Button; var item = Button.DataContext as Food; - //看是什么模式 if (mw.Set.EnableFunction) { @@ -209,58 +208,7 @@ 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, Math.Max(0.5, 1 - Math.Pow(eattimes, 2) * 0.01)); - //吃腻了 - eattimes += 2; - mw.Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes)); - //通知 - item.LoadEatTimeSource(mw); - item.NotifyOfPropertyChange(DateTime.Now.ToString()); - - mw.Core.Save.Money -= item.Price; - //统计 - mw.Set.Statistics[(gint)("buy_" + item.Name)]++; - mw.Set.Statistics[(gdbe)"stat_betterbuy"] += item.Price; - switch (item.Type) - { - case Food.FoodType.Food: - mw.Set.Statistics[(gdbe)"stat_bb_food"] += item.Price; - break; - case Food.FoodType.Drink: - mw.Set.Statistics[(gdbe)"stat_bb_drink"] += item.Price; - break; - case Food.FoodType.Drug: - mw.Set.Statistics[(gdbe)"stat_bb_drug"] += item.Price; - break; - case Food.FoodType.Snack: - mw.Set.Statistics[(gdbe)"stat_bb_snack"] += item.Price; - break; - case Food.FoodType.Functional: - mw.Set.Statistics[(gdbe)"stat_bb_functional"] += item.Price; - break; - case Food.FoodType.Meal: - mw.Set.Statistics[(gdbe)"stat_bb_meal"] += item.Price; - break; - case Food.FoodType.Gift: - mw.Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price; - break; - } - + mw.TakeItem(item); } if (showeatanm) {//显示动画 @@ -278,18 +226,12 @@ namespace VPet_Simulator.Windows gt = GraphType.Gift; break; } - var name = mw.Core.Graph.FindName(gt); - var ig = mw.Core.Graph.FindGraph(name, AnimatType.Single, mw.Core.Save.Mode); - if (ig != null) + mw.Main.Display(gt, item.ImageSource, () => { - var b = mw.Main.FindDisplayBorder(ig); - ig.Run(b, item.ImageSource, () => - { - showeatanm = true; - mw.Main.DisplayToNomal(); - mw.Main.EventTimer_Elapsed(); - }); - } + showeatanm = true; + mw.Main.DisplayToNomal(); + mw.Main.EventTimer_Elapsed(); + }); } if (!_puswitch.IsChecked.Value) { @@ -394,5 +336,22 @@ namespace VPet_Simulator.Windows rMoney = sender as Run; rMoney.Text = mw.Core.Save.Money.ToString("f2"); } + private Switch _puswitchautobuy; + private void Switch_Loaded_1(object sender, RoutedEventArgs e) + { + _puswitchautobuy = sender as Switch; + _puswitchautobuy.IsChecked = mw.Set.AutoBuy; + _puswitchautobuy.Click += Switch_AutoBuy_Checked; + } + private void Switch_AutoBuy_Checked(object sender, RoutedEventArgs e) + { + if (_puswitchautobuy.IsChecked.Value && mw.Core.Save.Money < 100) + { + _puswitchautobuy.IsChecked = false; + MessageBoxX.Show(mw, "余额不足100,无法开启自动购买".Translate(), "更好买".Translate()); + return; + } + mw.Set.AutoBuy = _puswitchautobuy.IsChecked.Value; + } } } diff --git a/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml b/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml deleted file mode 100644 index 3e0aa4f..0000000 --- a/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml.cs b/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml.cs deleted file mode 100644 index 927e61d..0000000 --- a/VPet-Simulator.Windows/WinDesign/winTrusteeShip.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace VPet_Simulator.Windows.WinDesign -{ - /// - /// winTrusteeShip.xaml 的交互逻辑 - /// - public partial class winTrusteeShip : Window - { - public winTrusteeShip() - { - InitializeComponent(); - } - } -} diff --git a/VPet-Simulator.Windows/mod/0000_core/lang/en/Prog2308.lps b/VPet-Simulator.Windows/mod/0000_core/lang/en/Prog2308.lps index 54e95b9..24ccf22 100644 --- a/VPet-Simulator.Windows/mod/0000_core/lang/en/Prog2308.lps +++ b/VPet-Simulator.Windows/mod/0000_core/lang/en/Prog2308.lps @@ -14,4 +14,7 @@ 使用桌宠选项式\r聊天功能#Use vpet option type\rchat function:| 支持MOD与创意工坊添加聊天内容#Support MOD and creative workshop add chat content:| 按经验值#Exp:| -删错误#Delete error:| \ No newline at end of file +删错误#Delete error:| +余额不足100,无法开启自动购买#Balance is less than 100, unable to open automatic purchase:| +让宠物自己买东西吃#Let the pet buy self:| +当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#When the pet is thirsty or hungry, it will buy something to eat it self\rPlease note that the pet may spend money and eat the wrong things\rExtra 20% takeout delivery fee:| \ No newline at end of file diff --git a/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hans/Prog2308.lps b/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hans/Prog2308.lps index a1cc766..1b75c3b 100644 --- a/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hans/Prog2308.lps +++ b/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hans/Prog2308.lps @@ -14,4 +14,7 @@ 使用桌宠选项式\r聊天功能#使用桌宠选项式\r聊天功能:| 支持MOD与创意工坊添加聊天内容#支持MOD与创意工坊添加聊天内容:| 按经验值#按经验值:| -删错误#删错误:| \ No newline at end of file +删错误#删错误:| +余额不足100,无法开启自动购买#余额不足100,无法开启自动购买:| +让宠物自己买东西吃#让宠物自己买东西吃:| +当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用:| \ No newline at end of file diff --git a/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hant/Prog2308.lps b/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hant/Prog2308.lps index 58fb55f..d675185 100644 --- a/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hant/Prog2308.lps +++ b/VPet-Simulator.Windows/mod/0000_core/lang/zh-Hant/Prog2308.lps @@ -14,4 +14,7 @@ 使用桌宠选项式\r聊天功能#使用桌寵選項式\r聊天功能:| 支持MOD与创意工坊添加聊天内容#支持MOD與創意工坊添加聊天內容:| 按经验值#按經驗值:| -删错误#刪錯誤:| \ No newline at end of file +删错误#刪錯誤:| +余额不足100,无法开启自动购买#餘額不足100,無法開啟自動購買:| +让宠物自己买东西吃#讓寵物自己買東西吃:| +当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#當寵物口渴或者饑餓的時候會自己買東西吃\r請注意,寵物可能會亂花錢和吃錯誤的東西\r額外加收20%外賣運送費用:| \ No newline at end of file