diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 0d421db8..8b3408d9 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -181,6 +181,11 @@ public class ActionHelper { return DestroyAction.Allocate(act.Value); } + case "ResultTip": + { + var strAction = (XMLTool.StringListAction)act; + return ResultTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); + } default: Debug.LogError($"ûҵAction{act.Type}"); break; diff --git a/Assets/Scripts/Actions/ResultTipAction.cs b/Assets/Scripts/Actions/ResultTipAction.cs new file mode 100644 index 00000000..998c7abc --- /dev/null +++ b/Assets/Scripts/Actions/ResultTipAction.cs @@ -0,0 +1,82 @@ +using QFramework.Example; +using System; +using UnityEngine; + +namespace QFramework +{ + internal class ResultTipAction : IAction + { + public System.Action OnFinished { get; set; } + + + private ResultTipAction() + { + } + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new ResultTipAction(), null, 10); + + public string txt; + public string isRight; + public string finishedEvent; + public static ResultTipAction Allocate(string txt, string isRight, string finishedEvent, System.Action OnFinished = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.txt = txt; + retNode.isRight = isRight; + retNode.finishedEvent = finishedEvent; + retNode.OnFinished = OnFinished; + return retNode; + } + + + public ulong ActionID { get; set; } + public ActionStatus Status { get; set; } + + public void OnStart() + { + UIResultTipData data = new UIResultTipData(); + data.label = txt; + bool.TryParse(isRight, out data.isRight); + if (string.IsNullOrEmpty(finishedEvent) == false) + { + data.callback = () => StringEventSystem.Global.Send(finishedEvent); + } + UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); + } + + public void OnExecute(float dt) + { + + } + + 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/ResultTipAction.cs.meta b/Assets/Scripts/Actions/ResultTipAction.cs.meta new file mode 100644 index 00000000..c37e7e06 --- /dev/null +++ b/Assets/Scripts/Actions/ResultTipAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7cdaddc504b6e994eb7c5d8d8fea65d8 +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 0f1ad7a7..b96dd49d 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -812,6 +812,30 @@ namespace XMLTool newAction = act; } break; + case "ResultTip": + { + var act = new StringListAction(); + XAttribute isRight = action.Attribute("isRight"); + if (isRight != null) + { + act.args.Add(isRight.Value); + } + else + { + act.args.Add("false"); + } + XAttribute finishedEvent = action.Attribute("finishedEvent"); + if (finishedEvent != null) + { + act.args.Add(finishedEvent.Value); + } + else + { + act.args.Add(""); + } + newAction = act; + } + break; default: newAction = new Action(); break; diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index b5a60869..48a6e070 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -78,7 +78,8 @@ - + +