From d6f069c4084251406a39837444defebe02b849a8 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 27 Dec 2024 19:54:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AD=A5=E9=AA=A4=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=B7=B3=E6=AD=A5=E9=AA=A4=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=20=E5=85=88=E7=AD=89=E5=89=8D=E9=9D=A2=E7=9A=84finished?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Controller/OperationController.cs | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/Assets/Scripts/Controller/OperationController.cs b/Assets/Scripts/Controller/OperationController.cs index 0992e08b..991c6527 100644 --- a/Assets/Scripts/Controller/OperationController.cs +++ b/Assets/Scripts/Controller/OperationController.cs @@ -124,18 +124,22 @@ public class OperationController : MonoSingleton { if (this.index < targetIndex) { + var seq = ActionKit.Sequence(); for (int i = this.index + 1; i < targetIndex; i++) { // ɶ ֱִ IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished); - if (finishAction != null) - { - finishAction.Start(this); - } TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished }); - + if (finishAction!=null) + { + seq.Append(finishAction); + } } - curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); + seq.Start(this,() => + { + curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); + RunCurAction(curAction, targetIndex); + }); } else if (this.index > targetIndex) { @@ -151,28 +155,35 @@ public class OperationController : MonoSingleton } curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); + RunCurAction(curAction, targetIndex); } else { curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); + RunCurAction(curAction, targetIndex); } - if (curAction != null) + + } + } + + public void RunCurAction(IAction curAction,int targetIndex) + { + if (curAction != null) + { + this.index = targetIndex; + isStepRun = true; + TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Start }); + curAction.Start(this, () => { - this.index = targetIndex; - isStepRun = true; - TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Start }); - curAction.Start(this, () => - { - isStepRun = false; - TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished }); - }); - } - else - { - this.index = targetIndex; + isStepRun = false; TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished }); - Execute(this.index + 1); - } + }); + } + else + { + this.index = targetIndex; + TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished }); + Execute(this.index + 1); } } }