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) {