From 3e4fd51b96e59a1c44342325604f6813586e6ccb Mon Sep 17 00:00:00 2001 From: ZouJin Date: Wed, 27 Sep 2023 15:13:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E8=AF=B4=E8=AF=9D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MainLogic.cs | 20 +++++++--- .../ExtensionFunction.cs | 39 ++++++++++++++++++- VPet-Simulator.Windows/MainWindow.xaml.cs | 7 ++-- .../WinDesign/TalkSelect.xaml.cs | 4 +- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index ada3e35..8858646 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -33,15 +33,15 @@ namespace VPet_Simulator.Core /// /// 说话,使用随机表情 /// - public void SayRnd(string text, bool force = false) + public void SayRnd(string text, bool force = false, string desc = null) { - Say(text, Core.Graph.FindName(GraphType.Say), force); + Say(text, Core.Graph.FindName(GraphType.Say), force, desc); } /// /// 说话 /// /// 说话内容 - public void Say(string text, string graphname = null, bool force = false) + public void Say(string text, string graphname = null, bool force = false, string desc = null) { Task.Run(() => { @@ -49,12 +49,22 @@ namespace VPet_Simulator.Core if (force || !string.IsNullOrWhiteSpace(graphname) && DisplayType.Type == GraphType.Default)//这里不使用idle是因为idle包括学习等 Display(graphname, AnimatType.A_Start, () => { - Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text, graphname)); + Dispatcher.Invoke(() => + { + if (!string.IsNullOrWhiteSpace(desc)) + MsgBar.MessageBoxContent.Children.Add(new TextBlock() { Text = desc, FontSize = 20, ToolTip = desc, HorizontalAlignment = System.Windows.HorizontalAlignment.Right }); + MsgBar.Show(Core.Save.Name, text, graphname); + }); DisplayBLoopingForce(graphname); }); else { - Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text)); + Dispatcher.Invoke(() => + { + if (!string.IsNullOrWhiteSpace(desc)) + MsgBar.MessageBoxContent.Children.Add(new TextBlock() { Text = desc, FontSize = 20, ToolTip = desc, HorizontalAlignment = System.Windows.HorizontalAlignment.Right }); + MsgBar.Show(Core.Save.Name, text); + }); } }); } diff --git a/VPet-Simulator.Windows.Interface/ExtensionFunction.cs b/VPet-Simulator.Windows.Interface/ExtensionFunction.cs index 6da7952..5d04b87 100644 --- a/VPet-Simulator.Windows.Interface/ExtensionFunction.cs +++ b/VPet-Simulator.Windows.Interface/ExtensionFunction.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using VPet_Simulator.Core; using static VPet_Simulator.Core.GraphHelper; namespace VPet_Simulator.Windows.Interface @@ -25,7 +26,7 @@ namespace VPet_Simulator.Windows.Interface var spend = ((work.StrengthFood >= 0 ? 1 : -1) * Math.Pow(work.StrengthFood * 2 + 1, 2) / 6 + (work.StrengthDrink >= 0 ? 1 : -1) * Math.Pow(work.StrengthDrink * 2 + 1, 2) / 9 + (work.Feeling >= 0 ? 1 : -1) * Math.Pow((work.Type == Work.WorkType.Play ? -1 : 1) * work.Feeling * 2 + 1, 2) / 12) * - (Math.Pow(work.LevelLimit / 2 + 1, 0.5) / 4 + 1) - 0.5; + (Math.Pow(work.LevelLimit / 2 + 1, 0.5) / 4 + 1) - 0.5; var get = (work.MoneyBase + work.MoneyLevel * 10) * (work.MoneyLevel + 1) * (1 + work.FinishBonus / 2); if (work.Type != Work.WorkType.Work) { @@ -38,6 +39,41 @@ namespace VPet_Simulator.Windows.Interface return true; return rel > 2; // 推荐rel为1.0-1.4之间 超过2.0就是超模 } + + public static string FoodToDescription(this IFood food) + { + var dic = new List>() + { + new Tuple(LocalizeCore.Translate("经验值"), food.Exp, ValueToPlusPlus(food.Exp, 1 / 4, 5)), + new Tuple(LocalizeCore.Translate("饱腹度"),food.StrengthFood, ValueToPlusPlus(food.StrengthFood, 1 / 2, 5)) , + new Tuple(LocalizeCore.Translate("口渴度"), food.StrengthDrink, ValueToPlusPlus(food.StrengthDrink, 1 / 2.5, 5)), + new Tuple(LocalizeCore.Translate("体力"),food.Strength, ValueToPlusPlus(food.Strength, 1 / 4, 5)), + new Tuple(LocalizeCore.Translate("心情"), food.Feeling, ValueToPlusPlus(food.Feeling, 1 / 3, 5)), + new Tuple(LocalizeCore.Translate("健康"),food.Health, ValueToPlusPlus(food.Health, 1, 5)) , + new Tuple(LocalizeCore.Translate("好感度"),food.Likability, ValueToPlusPlus(food.Likability, 1.5, 5)) + }; + var dic2 = dic.Where(kv => kv.Item2 != 0) + .Select(x => x.Item1 + x.Item3); + return string.Join("\n", dic2); + } + /// + /// 把值变成++ + /// + /// 值 + /// 倍率 + /// + public static string ValueToPlusPlus(double value, double magnification, int max = 10) + { + int v = (int)Math.Abs(value); + v = (int)(Math.Pow(v, magnification)); + v = Math.Min(Math.Max(v, 0), max); + if (value < 0) + return new string('-', v); + + else + return new string('+', v); + } + } public static class ExtensionValue { @@ -46,4 +82,5 @@ namespace VPet_Simulator.Windows.Interface /// public static string BaseDirectory = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName; } + } diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index fd896d0..ddc23d2 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -26,6 +26,7 @@ using Line = LinePutScript.Line; using static VPet_Simulator.Core.GraphInfo; using System.Globalization; using static VPet_Simulator.Windows.Interface.ExtensionFunction; +using System.Web.UI.WebControls; namespace VPet_Simulator.Windows { @@ -403,7 +404,7 @@ namespace VPet_Simulator.Windows else//新玩家,默认设置为 Set["CGPT"][(gstr)"type"] = "LB"; - + await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate())); //当前桌宠动画 @@ -445,7 +446,7 @@ namespace VPet_Simulator.Windows } //var food = new Food(); foreach (var selet in SelectTexts) - { + { selet.Exp = Math.Max(Math.Min(selet.Exp, 1000), -1000); //food.Exp += selet.Exp; selet.Feeling = Math.Max(Math.Min(selet.Feeling, 1000), -1000); @@ -682,7 +683,7 @@ namespace VPet_Simulator.Windows } Main.Core.Save.EatFood(rt); Main.Core.Save.Money += rt.Money; - Main.SayRnd(rt.TranslateText); + Main.SayRnd(rt.TranslateText, desc: rt.FoodToDescription()); } } }; diff --git a/VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs b/VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs index 9878ab7..e071410 100644 --- a/VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs @@ -132,7 +132,7 @@ namespace VPet_Simulator.Windows else mw.GameSavesData.Statistics[(gint)"stat_say_like_d"]++; } - if(say.Money != 0) + if (say.Money != 0) { if (say.Money > 0) mw.GameSavesData.Statistics[(gint)"stat_say_money_p"]++; @@ -145,7 +145,7 @@ namespace VPet_Simulator.Windows textSaid.Add(say.Choose); RelsTime = RelsTime.AddMinutes(5); - mw.Main.SayRnd(say.ConverText(mw.Main)); + mw.Main.SayRnd(say.ConverText(mw.Main), desc: say.FoodToDescription()); if (say.ToTags.Count > 0) { var list = mw.SelectTexts.FindAll(x => x.ContainsTag(say.ToTags)).ToList();