From 24f97fedbb0abcd23267ac827a2b5ee7571f8322 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 27 Dec 2024 20:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86resetAction=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Controller/OperationController.cs | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Controller/OperationController.cs b/Assets/Scripts/Controller/OperationController.cs index 991c6527..dfad5464 100644 --- a/Assets/Scripts/Controller/OperationController.cs +++ b/Assets/Scripts/Controller/OperationController.cs @@ -125,17 +125,20 @@ public class OperationController : MonoSingleton if (this.index < targetIndex) { var seq = ActionKit.Sequence(); - for (int i = this.index + 1; i < targetIndex; i++) + if (this.index >= 0) { - // ɶ ֱִ - IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished); - TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished }); - if (finishAction!=null) + for (int i = this.index; i < targetIndex; i++) { - seq.Append(finishAction); + // ɶ ֱִ + IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished); + TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished }); + if (finishAction != null) + { + seq.Append(finishAction); + } } } - seq.Start(this,() => + seq.Start(this, () => { curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); RunCurAction(curAction, targetIndex); @@ -143,19 +146,22 @@ public class OperationController : MonoSingleton } else if (this.index > targetIndex) { + var seq = ActionKit.Sequence(); for (int i = this.index; i > targetIndex; i--) { // ö ֱ IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset); if (resetAction != null) { - resetAction.Start(this); + seq.Append(resetAction); } TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart }); - } - curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); - RunCurAction(curAction, targetIndex); + seq.Start(this, () => + { + curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); + RunCurAction(curAction, targetIndex); + }); } else { @@ -166,7 +172,7 @@ public class OperationController : MonoSingleton } } - public void RunCurAction(IAction curAction,int targetIndex) + public void RunCurAction(IAction curAction, int targetIndex) { if (curAction != null) {