From 82781cde1c68e22cfc72a4c2d6ce60cfcb07b89f Mon Sep 17 00:00:00 2001 From: ZouJin Date: Mon, 24 Jul 2023 11:53:18 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A8=E7=94=BB=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9B=B8=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MainLogic.cs | 5 +- VPet-Simulator.Core/Graph/FoodAnimation.cs | 2 +- VPet-Simulator.Core/Graph/GraphCore.cs | 17 +-- VPet-Simulator.Core/Graph/GraphHelper.cs | 98 +---------------- VPet-Simulator.Core/Graph/GraphInfo.cs | 102 +++++++++++++++++- VPet-Simulator.Core/Graph/PNGAnimation.cs | 2 +- VPet-Simulator.Core/Graph/Picture.cs | 2 +- .../mod/0000_core/pet/vup/Drink/info.lps | 12 +-- .../mod/0000_core/pet/vup/Eat/Ill/info.lps | 4 +- .../0000_core/pet/vup/Eat/Nomal_1/info.lps | 4 +- .../0000_core/pet/vup/Eat/Nomal_2/info.lps | 4 +- 11 files changed, 128 insertions(+), 124 deletions(-) diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index ef97586..86bdcc3 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -206,7 +206,7 @@ namespace VPet_Simulator.Core } else if (Core.Save.StrengthFood <= 25) { - Core.Save.Health -= Function.Rnd.Next() * TimePass; + Core.Save.Health -= Function.Rnd.NextDouble() * TimePass; addhealth -= 2; } if (Core.Save.StrengthDrink >= 50) @@ -218,7 +218,7 @@ namespace VPet_Simulator.Core } else if (Core.Save.StrengthDrink <= 25) { - Core.Save.Health -= Function.Rnd.Next() * TimePass; + Core.Save.Health -= Function.Rnd.NextDouble() * TimePass; addhealth -= 2; } if (addhealth > 0) @@ -285,7 +285,6 @@ namespace VPet_Simulator.Core { //所有Handle TimeHandle?.Invoke(this); - if (Core.Controller.EnableFunction) { FunctionSpend(0.05); diff --git a/VPet-Simulator.Core/Graph/FoodAnimation.cs b/VPet-Simulator.Core/Graph/FoodAnimation.cs index 9680cb8..77f6869 100644 --- a/VPet-Simulator.Core/Graph/FoodAnimation.cs +++ b/VPet-Simulator.Core/Graph/FoodAnimation.cs @@ -50,7 +50,7 @@ namespace VPet_Simulator.Core public static void LoadGraph(GraphCore graph, FileSystemInfo path, ILine info) { bool isLoop = info[(gbol)"loop"]; - FoodAnimation pa = new FoodAnimation(graph, GraphHelper.GetGraphInfo(path, info), info[(gstr)"front_lay"], info[(gstr)"back_lay"], info, isLoop); + FoodAnimation pa = new FoodAnimation(graph, new GraphInfo(path, info), info[(gstr)"front_lay"], info[(gstr)"back_lay"], info, isLoop); graph.AddGraph(pa); } /// diff --git a/VPet-Simulator.Core/Graph/GraphCore.cs b/VPet-Simulator.Core/Graph/GraphCore.cs index 1e49124..8d781e9 100644 --- a/VPet-Simulator.Core/Graph/GraphCore.cs +++ b/VPet-Simulator.Core/Graph/GraphCore.cs @@ -106,6 +106,10 @@ namespace VPet_Simulator.Core return list[0]; return list[Function.Rnd.Next(list.Count)]; } + if (mode == GameSave.ModeType.Ill) + { + return null; + } int i = (int)mode + 1; if (i < 3) { @@ -115,20 +119,17 @@ namespace VPet_Simulator.Core return list[Function.Rnd.Next(list.Count)]; } i = (int)mode - 1; - if (i >= 0) + if (i >= 1) { //向上兼容的动画 list = gl.FindAll(x => x.GraphInfo.ModeType == (GameSave.ModeType)i); if (list.Count > 0) return list[Function.Rnd.Next(list.Count)]; } - //如果实在找不到,就走随机数 - //if (mode != GameSave.ModeType.Ill) - //{ - list = gl; + //如果实在找不到,就走随机数(无生病) + list = gl.FindAll(x => x.GraphInfo.ModeType != GameSave.ModeType.Ill); if (list.Count > 0) - return list[Function.Rnd.Next(list.Count)]; - //} + return list[Function.Rnd.Next(list.Count)]; } return null;// FindGraph(GraphType.Default, mode); } @@ -305,7 +306,7 @@ namespace VPet_Simulator.Core Str.AddRange(lps["str"]); Duration.AddRange(lps["duration"]); - + foreach (var line in lps.FindAllLine("work")) { Works.Add(LPSConvert.DeserializeObject(line)); diff --git a/VPet-Simulator.Core/Graph/GraphHelper.cs b/VPet-Simulator.Core/Graph/GraphHelper.cs index 2ff73a7..6a30378 100644 --- a/VPet-Simulator.Core/Graph/GraphHelper.cs +++ b/VPet-Simulator.Core/Graph/GraphHelper.cs @@ -20,7 +20,7 @@ namespace VPet_Simulator.Core { public static class GraphHelper { - static string[][] graphtypevalue = null; + internal static string[][] graphtypevalue = null; /// /// 动画类型默认前文本 /// @@ -76,103 +76,7 @@ namespace VPet_Simulator.Core return null; } } - /// - /// 通过文件位置和信息获取动画信息 - /// - /// 文件夹位置 - /// 信息 - /// 动画信息 - public static GraphInfo GetGraphInfo(FileSystemInfo path, ILine info) - { - var pn = Sub.Split(path.FullName.Substring(0, path.FullName.Length - path.Extension.Length).ToLower(), info[(gstr)"startuppath"].ToLower()).Last(); - var path_name = pn.Replace('\\', '_').Split('_').ToList(); - path_name.RemoveAll(string.IsNullOrWhiteSpace); - if (!Enum.TryParse(info[(gstr)"mode"], true, out GameSave.ModeType modetype)) - { - if (path_name.Remove("happy")) - { - modetype = GameSave.ModeType.Happy; - } - else if (path_name.Remove("nomal")) - { - modetype = GameSave.ModeType.Nomal; - } - else if (path_name.Remove("poorcondition")) - { - modetype = GameSave.ModeType.PoorCondition; - } - else if (path_name.Remove("ill")) - { - modetype = GameSave.ModeType.Ill; - } - else - { - modetype = GameSave.ModeType.Nomal; - } - } - if (!Enum.TryParse(info[(gstr)"graph"], true, out GraphType graphtype)) - { - graphtype = GraphInfo.GraphType.Common; - for (int i = 0; i < GraphTypeValue.Length; i++) - {//挨个找第一个匹配的 - if (path_name.Contains(GraphTypeValue[i][0])) - { - int index = path_name.IndexOf(GraphTypeValue[i][0]); - bool ismatch = true; - for (int b = 1; b < GraphTypeValue[i].Length && b + index < path_name.Count; b++) - { - if (path_name[index + b] != GraphTypeValue[i][b]) - { - ismatch = false; - break; - } - } - if (ismatch) - { - graphtype = (GraphType)i; - path_name.RemoveRange(index, GraphTypeValue[i].Length); - break; - } - } - } - } - - if (!Enum.TryParse(info[(gstr)"animat"], true, out AnimatType animatType)) - { - if (path_name.Remove("a") || path_name.Remove("start")) - { - animatType = AnimatType.A_Start; - } - else if (path_name.Remove("b") || path_name.Remove("loop")) - { - animatType = AnimatType.B_Loop; - } - else if (path_name.Remove("c") || path_name.Remove("end")) - { - animatType = AnimatType.C_End; - } - else - { - animatType = AnimatType.Single; - } - } - string name = info.Info; - if (string.IsNullOrWhiteSpace(name)) - { - while (path_name.Count > 0 && (double.TryParse(path_name.Last(), out _) || path_name.Last().StartsWith("~"))) - { - path_name.RemoveAt(path_name.Count - 1); - } - if (path_name.Count > 0) - name = path_name.Last(); - } - if (string.IsNullOrWhiteSpace(name)) - { - name = graphtype.ToString().ToLower(); - } - return new GraphInfo(name, graphtype, animatType, modetype);// { Info = info }; - } /// /// 工作/学习 diff --git a/VPet-Simulator.Core/Graph/GraphInfo.cs b/VPet-Simulator.Core/Graph/GraphInfo.cs index b04aedf..e4f3db7 100644 --- a/VPet-Simulator.Core/Graph/GraphInfo.cs +++ b/VPet-Simulator.Core/Graph/GraphInfo.cs @@ -1,8 +1,11 @@ -using System; +using LinePutScript; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using static VPet_Simulator.Core.GraphHelper; namespace VPet_Simulator.Core { @@ -32,7 +35,104 @@ namespace VPet_Simulator.Core Type = type; ModeType = modeType; } + /// + /// 通过文件位置和信息获取动画信息 + /// + /// 文件夹位置 + /// 信息 + public GraphInfo(FileSystemInfo path, ILine info) + { + var pn = Sub.Split(path.FullName.Substring(0, path.FullName.Length - path.Extension.Length).ToLower(), info[(gstr)"startuppath"].ToLower()).Last(); + var path_name = pn.Replace('\\', '_').Split('_').ToList(); + path_name.RemoveAll(string.IsNullOrWhiteSpace); + if (!Enum.TryParse(info[(gstr)"mode"], true, out GameSave.ModeType modetype)) + { + if (path_name.Remove("happy")) + { + modetype = GameSave.ModeType.Happy; + } + else if (path_name.Remove("nomal")) + { + modetype = GameSave.ModeType.Nomal; + } + else if (path_name.Remove("poorcondition")) + { + modetype = GameSave.ModeType.PoorCondition; + } + else if (path_name.Remove("ill")) + { + modetype = GameSave.ModeType.Ill; + } + else + { + modetype = GameSave.ModeType.Nomal; + } + } + if (!Enum.TryParse(info[(gstr)"graph"], true, out GraphType graphtype)) + { + graphtype = GraphInfo.GraphType.Common; + for (int i = 0; i < GraphTypeValue.Length; i++) + {//挨个找第一个匹配的 + if (path_name.Contains(GraphTypeValue[i][0])) + { + int index = path_name.IndexOf(GraphTypeValue[i][0]); + bool ismatch = true; + for (int b = 1; b < GraphTypeValue[i].Length && b + index < path_name.Count; b++) + { + if (path_name[index + b] != GraphTypeValue[i][b]) + { + ismatch = false; + break; + } + } + if (ismatch) + { + graphtype = (GraphType)i; + path_name.RemoveRange(index, GraphTypeValue[i].Length); + break; + } + } + } + } + + if (!Enum.TryParse(info[(gstr)"animat"], true, out AnimatType animatType)) + { + if (path_name.Remove("a") || path_name.Remove("start")) + { + animatType = AnimatType.A_Start; + } + else if (path_name.Remove("b") || path_name.Remove("loop")) + { + animatType = AnimatType.B_Loop; + } + else if (path_name.Remove("c") || path_name.Remove("end")) + { + animatType = AnimatType.C_End; + } + else + { + animatType = AnimatType.Single; + } + } + Name = info.Info; + if (string.IsNullOrWhiteSpace(Name)) + { + while (path_name.Count > 0 && (double.TryParse(path_name.Last(), out _) || path_name.Last().StartsWith("~"))) + { + path_name.RemoveAt(path_name.Count - 1); + } + if (path_name.Count > 0) + Name = path_name.Last(); + } + if (string.IsNullOrWhiteSpace(Name)) + { + Name = graphtype.ToString().ToLower(); + } + Type = graphtype; + Animat = animatType; + ModeType = modetype; + } /// /// 类型: 主要动作分类 /// diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.cs b/VPet-Simulator.Core/Graph/PNGAnimation.cs index 7a3f927..c26b34b 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.cs @@ -155,7 +155,7 @@ namespace VPet_Simulator.Core var paths = p.GetFiles(); bool isLoop = info[(gbol)"loop"]; - PNGAnimation pa = new PNGAnimation(graph, path.FullName, paths, GraphHelper.GetGraphInfo(path, info), isLoop); + PNGAnimation pa = new PNGAnimation(graph, path.FullName, paths, new GraphInfo(path, info), isLoop); graph.AddGraph(pa); } diff --git a/VPet-Simulator.Core/Graph/Picture.cs b/VPet-Simulator.Core/Graph/Picture.cs index 5857c3a..22fe65c 100644 --- a/VPet-Simulator.Core/Graph/Picture.cs +++ b/VPet-Simulator.Core/Graph/Picture.cs @@ -50,7 +50,7 @@ namespace VPet_Simulator.Core length = 1000; } bool isLoop = info[(gbol)"loop"]; - Picture pa = new Picture(graph, path.FullName, GraphHelper.GetGraphInfo(path, info), length, isLoop); + Picture pa = new Picture(graph, path.FullName, new GraphInfo(path, info), length, isLoop); graph.AddGraph(pa); } /// diff --git a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Drink/info.lps b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Drink/info.lps index d29181b..0634ecb 100644 --- a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Drink/info.lps +++ b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Drink/info.lps @@ -1,9 +1,9 @@ -PNGAnimation#drink_back_lay:|path#Happy\back_lay:|mode#Happy:|graph#Not_Able:| -///PNGAnimation#drink_front_lay:|path#Happy\front_lay:|mode#Happy:|graph#Not_Able:| -PNGAnimation#drink_back_lay:|path#Nomal\back_lay:|mode#Nomal:|graph#Not_Able:| -PNGAnimation#drink_front_lay:|path#front_lay:|mode#Nomal:|graph#Not_Able:| -PNGAnimation#drink_back_lay:|path#PoorCondition\back_lay:|mode#PoorCondition:|graph#Not_Able:| -///PNGAnimation#drink_front_lay:|path#PoorCondition\front_lay:|mode#PoorCondition:|graph#Not_Able:| +PNGAnimation#drink_back_lay:|path#Happy\back_lay:|mode#Happy:|graph#Common:| +///PNGAnimation#drink_front_lay:|path#Happy\front_lay:|mode#Happy:|graph#Common:| +PNGAnimation#drink_back_lay:|path#Nomal\back_lay:|mode#Nomal:|graph#Common:| +PNGAnimation#drink_front_lay:|path#front_lay:|mode#Nomal:|graph#Common:| +PNGAnimation#drink_back_lay:|path#PoorCondition\back_lay:|mode#PoorCondition:|graph#Common:| +///PNGAnimation#drink_front_lay:|path#PoorCondition\front_lay:|mode#PoorCondition:|graph#Common:| FoodAnimation#drink:|mode#Happy:|graph#drink:|a0#1000:|a1#125,268,286,77,60:|a2#125,167,164,78:|a3#125,198,160,78:|a4#125,199,163,78:|a5#125,199,160,78:|a6#125,199,163,78:|a7#125,199,160,78:|a8#125,169,164,78:|a9#125,268,286,77,60:|a10#625:|front_lay#drink_front_lay:|back_lay#drink_back_lay:| FoodAnimation#drink:|mode#nomal:|graph#drink:|a0#1000:|a1#125,268,286,77,60:|a2#125,167,164,78:|a3#125,198,160,78:|a4#125,199,163,78:|a5#125,199,160,78:|a6#125,199,163,78:|a7#125,199,160,78:|a8#125,169,164,78:|a9#125,268,286,77,60:|a10#625:|front_lay#drink_front_lay:|back_lay#drink_back_lay:| FoodAnimation#drink:|mode#PoorCondition:|graph#drink:|a0#1000:|a1#125,268,286,77,60:|a2#125,167,164,78:|a3#125,198,160,78:|a4#125,199,163,78:|a5#125,199,160,78:|a6#125,199,163,78:|a7#125,199,160,78:|a8#125,169,164,78:|a9#125,268,286,77,60:|a10#625:|front_lay#drink_front_lay:|back_lay#drink_back_lay:| diff --git a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Ill/info.lps b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Ill/info.lps index 12e632c..4caeaa0 100644 --- a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Ill/info.lps +++ b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Ill/info.lps @@ -1,3 +1,3 @@ -PNGAnimation#eat_back_lay:|path#back_lay:|mode#ill:|graph#Not_Able:| -PNGAnimation#eat_front_lay:|path#front_lay:|mode#ill:|graph#Not_Able:| +PNGAnimation#eat_back_lay:|path#back_lay:|mode#ill:|graph#Common:| +PNGAnimation#eat_front_lay:|path#front_lay:|mode#ill:|graph#Common:| FoodAnimation#eat:|mode#ill:|graph#Eat:|a0#500:|a1#125,60,125,59:|a2#125,120,175,59:|a3#125,170,250,59:|a4#250,165,232,64:|a5#250,170,265,65:|a6#250,170,270,65:|a7#250,180,270,64:|a8#2000:|front_lay#eat_front_lay:|back_lay#eat_back_lay:|///Time,MarginX,Y,Width,Rotate,Opacity \ No newline at end of file diff --git a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_1/info.lps b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_1/info.lps index 3f22feb..437e1a3 100644 --- a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_1/info.lps +++ b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_1/info.lps @@ -1,3 +1,3 @@ -PNGAnimation#eat_back_lay:|path#back_lay:|mode#nomal:|graph#Not_Able:| -PNGAnimation#eat_front_lay:|path#front_lay:|mode#nomal:|graph#Not_Able:| +PNGAnimation#eat_back_lay:|path#back_lay:|mode#nomal:|graph#Common:| +PNGAnimation#eat_front_lay:|path#front_lay:|mode#nomal:|graph#Common:| FoodAnimation#eat:|mode#nomal:|graph#Eat:|a0#175,215,23,60,0,0.375:|a1#125,247,88,60,25,0.4375:|a2#125,233,83,60,-20:|a3#125,228,178,57,-5.5:|a4#750,224,196,65:|a5#125,222,163,65:|a6#375,224,194,65:|a7#125,222,158,65:|a8#750:|front_lay#eat_front_lay:|back_lay#eat_back_lay:| \ No newline at end of file diff --git a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_2/info.lps b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_2/info.lps index ededd86..3dc8e06 100644 --- a/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_2/info.lps +++ b/VPet-Simulator.Windows/mod/0000_core/pet/vup/Eat/Nomal_2/info.lps @@ -1,3 +1,3 @@ -PNGAnimation#eat_back_lay_2:|path#back_lay:|mode#nomal:|graph#Not_Able:| -PNGAnimation#eat_front_lay_2:|path#front_lay:|mode#nomal:|graph#Not_Able:| +PNGAnimation#eat_back_lay_2:|path#back_lay:|mode#nomal:|graph#Common:| +PNGAnimation#eat_front_lay_2:|path#front_lay:|mode#nomal:|graph#Common:| FoodAnimation#eat:|mode#nomal:|graph#Eat:|a0#175,205,23,60,0,0.375:|a1#125,220,88,60,25,0.4375:|a2#125,222,83,60,-20:|a3#125,216,178,57,-5.5:|a4#750,212,196,65:|a5#125,210,163,65:|a6#375,212,194,65:|a7#125,210,158,65:|a8#750:|front_lay#eat_front_lay_2:|back_lay#eat_back_lay_2:| \ No newline at end of file