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); } } }