From 55142c5ab683198f2d8ca2c21f9c70f7467764e0 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 11 Aug 2023 12:48:04 +1000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=85=BB=E5=91=B3=E7=A8=8B?= =?UTF-8?q?=E5=BA=A6:=E5=90=83=E5=A4=9A=E4=BA=86=E4=BC=9A=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 | 48 ++++++++++--------- .../WinDesign/winBetterBuy.xaml.cs | 5 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/VPet-Simulator.Windows.Interface/Mod/Food.cs b/VPet-Simulator.Windows.Interface/Mod/Food.cs index 4405dd8..a76c3e3 100644 --- a/VPet-Simulator.Windows.Interface/Mod/Food.cs +++ b/VPet-Simulator.Windows.Interface/Mod/Food.cs @@ -103,6 +103,7 @@ namespace VPet_Simulator.Windows.Interface [Line(ignoreCase: true)] public string Desc { get; set; } private string desc = null; + private string descs = null; /// /// 描述(ToBetterBuy) /// @@ -126,26 +127,7 @@ namespace VPet_Simulator.Windows.Interface sb.Append("好感度".Translate() + ":\t").Append(Likability > 0 ? "+" : "").Append(Likability.ToString("f2")); desc = sb.ToString(); } - DateTime now = DateTime.Now; - DateTime eattime = imw.Set.PetData.GetDateTime("buytime_" + Name, now); - string descs; - if (eattime <= now) - { - if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink) - descs = "喜好度".Translate(); - else - descs = "有效度".Translate(); - descs += ":\t100%"; - } - else - { - if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink) - descs = "喜好度".Translate(); - else - descs = "有效度".Translate(); - descs += Math.Max(0.5, 1 - Math.Pow((eattime - now).TotalHours, 2) * 0.01).ToString("p0"); - descs += "\t\t" + "恢复".Translate() + ":\t" + (eattime).ToString("MM/dd HH"); - } + return desc + '\n' + descs + '\n' + Desc.Translate(); } } @@ -163,7 +145,6 @@ namespace VPet_Simulator.Windows.Interface [Line(ignoreCase: true)] public string Image; - private IMainWindow imw; /// /// 加载物品图片 @@ -172,7 +153,30 @@ namespace VPet_Simulator.Windows.Interface { ImageSource = imw.ImageSources.FindImage(Image ?? Name, "food"); Star = imw.Set["betterbuy"]["star"].GetInfos().Contains(Name); - this.imw = imw; + LoadEatTimeSource(imw); + } + public void LoadEatTimeSource(IMainWindow imw) + { + DateTime now = DateTime.Now; + DateTime eattime = imw.Set.PetData.GetDateTime("buytime_" + Name, now); + string descs; + if (eattime <= now) + { + if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink) + descs = "喜好度".Translate(); + else + descs = "有效度".Translate(); + descs += ":\t100%"; + } + else + { + if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink) + descs = "喜好度".Translate(); + else + descs = "有效度".Translate(); + descs += ":\t" + Math.Max(0.5, 1 - Math.Pow((eattime - now).TotalHours, 2) * 0.01).ToString("p0"); + descs += "\t\t" + "恢复".Translate() + ":\t" + (eattime).ToString("MM/dd HH"); + } } } } diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs index b95d501..f2de987 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs @@ -189,11 +189,12 @@ namespace VPet_Simulator.Windows eattimes = (eattime - now).TotalHours; } //开始加点 - mw.Core.Save.EatFood(item, Math.Max(0.5, 1 - Math.Sqrt(eattimes) * 0.01)); + 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("Eattime"); mw.Core.Save.Money -= item.Price; @@ -224,7 +225,7 @@ namespace VPet_Simulator.Windows mw.Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price; break; } - + } if (!_puswitch.IsChecked.Value) TryClose();