From badd820b23489c0af684ed075361e5a1d7332236 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 18 Dec 2024 11:17:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=8A=A8=E7=94=BBAction?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9Ereset=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/ActionBase.cs | 4 ---- Assets/Scripts/Actions/ActionHelper.cs | 6 ++++-- Assets/Scripts/Actions/AnimationAction.cs | 10 ++++++++-- Assets/Scripts/Xml/XmlParser.cs | 22 ++++++++++++++++++++-- Doc/Xml配置文档.xml | 4 ++-- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Actions/ActionBase.cs b/Assets/Scripts/Actions/ActionBase.cs index 140d45dc..b1dafcd9 100644 --- a/Assets/Scripts/Actions/ActionBase.cs +++ b/Assets/Scripts/Actions/ActionBase.cs @@ -10,10 +10,6 @@ namespace XMLTool public float time; } - public class AnimationAction : Action - { - public string animName; - } public class StringListAction : Action diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index d39d6ed1..17c96bef 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -99,8 +99,10 @@ public class ActionHelper case "Btns": return BtnsAction.Allocate(act.Value); case "Anim": - var anim = (XMLTool.AnimationAction)act; - return QFramework.AnimationAction.Allocate(anim.Value, anim.animName); + { + var strAction = (XMLTool.StringListAction)act; + return QFramework.AnimationAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); + } case "UITools": { var strAction = (XMLTool.StringListAction)act; diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index 8f976538..c211d434 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -20,15 +20,17 @@ namespace QFramework string path; string animName; + bool reset = false; Animation anim; - public static AnimationAction Allocate(string path, string animName, System.Action OnFinished = null) + public static AnimationAction Allocate(string path, string animName, string reset, System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; + retNode.Reset(); retNode.path = path; retNode.animName = animName; - retNode.Reset(); + bool.TryParse(reset, out retNode.reset); retNode.OnFinished = OnFinished; return retNode; } @@ -44,6 +46,10 @@ namespace QFramework { anim = obj.GetComponent(); anim.Play(animName); + if (reset) + { + ActionKit.DelayFrame(1, () => anim.Stop()); + } } else { diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 8d9f385c..eb047213 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -317,8 +317,26 @@ namespace XMLTool break; case "Anim": { - var act = new AnimationAction(); - act.animName = action.Attribute("animName").Value; + var act = new StringListAction(); + var animName = action.Attribute("animName"); + if (animName != null) + { + act.args.Add(animName.Value); + } + else + { + act.args.Add(""); + } + var reset = action.Attribute("reset"); + if (reset != null) + { + act.args.Add(reset.Value); + } + else + { + act.args.Add("false"); + } + newAction = act; } break; diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 1d08b8b7..63d97c07 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -15,8 +15,8 @@ - - + + From 8d6b8d51b60910566f6895aea4d154ff7774b4ab Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 18 Dec 2024 11:18:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=BB=9F=E4=B8=80=E6=88=90=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Doc/Xml配置文档.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 63d97c07..911bd881 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -25,7 +25,8 @@ rightLabel="提示:器械选择正确。" wrongLabel="提示:器械选择错误,\r\n当前模块中,不需要该物品。" rightEvent="" - wrongEvent=""/> + wrongEvent=""> + @@ -41,10 +42,10 @@ - + - + From 3fc72569c5e15637c1a5f453fdad9806e1b0356d Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 18 Dec 2024 13:16:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=89=A9=E4=BD=93?= =?UTF-8?q?=E9=AB=98=E4=BA=AEAction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/ActionHelper.cs | 5 + Assets/Scripts/Actions/HighLightAction.cs | 102 ++++++++++++++++++ .../Scripts/Actions/HighLightAction.cs.meta | 11 ++ Assets/Scripts/Xml/XmlParser.cs | 24 +++++ Doc/Xml配置文档.xml | 5 +- 5 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/Actions/HighLightAction.cs create mode 100644 Assets/Scripts/Actions/HighLightAction.cs.meta diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 17c96bef..fe72080c 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -156,6 +156,11 @@ public class ActionHelper var strAction = (XMLTool.StringListAction)act; return VideoAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3]); } + case "HighLight": + { + var strAction = (XMLTool.StringListAction)act; + return HighLightAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); + } } break; case XMLTool.Condition condition: diff --git a/Assets/Scripts/Actions/HighLightAction.cs b/Assets/Scripts/Actions/HighLightAction.cs new file mode 100644 index 00000000..94ae7fdd --- /dev/null +++ b/Assets/Scripts/Actions/HighLightAction.cs @@ -0,0 +1,102 @@ +using HighlightPlus; +using System; +using Unity.VisualScripting; +using UnityEditor; +using UnityEngine; + +namespace QFramework +{ + internal class HighLightAction : IAction + { + + + public System.Action OnFinished { get; set; } + + + private HighLightAction() + { + } + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new HighLightAction(), null, 10); + + string path; + Color color = Color.green; + bool isHigh = true; + public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.path = path; + if (string.IsNullOrEmpty(color) == false) + { + retNode.color = Utility.ToColor(color); + } + bool.TryParse(isHigh, out retNode.isHigh); + retNode.OnFinished = OnFinished; + return retNode; + } + + + public ulong ActionID { get; set; } + public ActionStatus Status { get; set; } + + public void OnStart() + { + GameObject obj = Utility.FindObj(path); + if (obj != null) + { + if (isHigh) + { + var effect = obj.GetOrAddComponent(); + obj.GetOrAddComponent(); + effect.outlineColor = color; + effect.highlighted = true; + } + else + { + var effect = obj.GetComponent(); + if (effect) + { + effect.highlighted = false; + } + } + + } + } + + public void OnExecute(float dt) + { + this.Finish(); + OnFinished?.Invoke(); + } + + public void OnFinish() + { + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } + + public bool Paused { get; set; } + + public void Deinit() + { + if (!Deinited) + { + OnFinished = null; + Deinited = true; + mPool.Recycle(this); + } + } + + public bool Deinited { get; set; } + } + + +} \ No newline at end of file diff --git a/Assets/Scripts/Actions/HighLightAction.cs.meta b/Assets/Scripts/Actions/HighLightAction.cs.meta new file mode 100644 index 00000000..ab798898 --- /dev/null +++ b/Assets/Scripts/Actions/HighLightAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 491e5e519156b5e4f9591a0221d5b824 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index eb047213..fa521ddf 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -633,6 +633,30 @@ namespace XMLTool newAction = act; } break; + case "HighLight": + { + var act = new StringListAction(); + XAttribute isHigh = action.Attribute("isHigh"); + if (isHigh != null) + { + act.args.Add(isHigh.Value); + } + else + { + act.args.Add("true"); + } + XAttribute color = action.Attribute("color"); + if (color != null) + { + act.args.Add(color.Value); + } + else + { + act.args.Add(""); + } + newAction = act; + } + break; default: newAction = new Action(); break; diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 911bd881..5e6e2834 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -49,7 +49,10 @@ - + + + +