private void UpdateRightActions() { if (actIdRight >= 0) { int exeId = actIdRight; for (int i = 0; i < targets.Count; i++) { if (i == 0) { if (actRetRight == Action.ReturnType.Done) { // is a new action, so Init rightActions[actIdRight].Init(owner, targets[0], null, null, gameObject); } actRetRight = rightActions[actIdRight].Execute(owner, targets[0], null, null, gameObject); if (actRetRight == Action.ReturnType.Done) { actIdRight++; if (actIdRight >= rightActions.Count) actRetRight = Action.ReturnType.Exit; } else if (actRetRight == Action.ReturnType.CallAgain) { // do nothing. will call again. // do not remove } else if (actRetRight == Action.ReturnType.SkipNext) { actIdRight += 2; actRetRight = Action.ReturnType.Done; if (actIdRight >= rightActions.Count) actRetRight = Action.ReturnType.Exit; } // ---------- note that the following should be last else if tests else if (actRetRight <= Action.ReturnType.ExecuteSpecificNext && actRetRight != Action.ReturnType.Exit) { Debug.LogError("There is no Action (0). Please specify a number higher than (0)."); actRetRight = Action.ReturnType.Exit; } else if (actRetRight > Action.ReturnType.ExecuteSpecificNext) { actIdRight = (int)actRetRight - (int)Action.ReturnType.ExecuteSpecificNext - 1; actRetRight = Action.ReturnType.Done; if (actIdRight >= rightActions.Count) actRetRight = Action.ReturnType.Exit; } // ---------- this should not be in else-if since the above code depends on something checking for Exit if (actRetRight == Action.ReturnType.Exit) { actIdRight = -1; // done with all actions } } else { rightActions[exeId].Execute(owner, targets[i], null, null, gameObject); } } } }
/// <summary>call this to use the skill (OnUse actions will run and timers started)</summary> public void Use(GameObject owner, List<GameObject> targets, Vector3 skillExeLocation) { // the skill must be moved to the locatio nfrom where it is executed so that // there is some kind of physical location that can be referenced by action transform.position = skillExeLocation; gameObject.SetActive(true); this.owner = owner; this.targets = targets; actRetLeft = Action.ReturnType.Done; actRetRight = Action.ReturnType.Done; timersRunning = true; castTimer = castTimeSetting; cooldownTimer = cooldownTimeSetting; if (onUseActions.Count > 0) actIdLeft = 0; else actIdLeft = -1; if (rightActions.Count > 0) actIdRight = 0; else actIdRight = -1; leftTarget = null; if (targets == null) actIdRight = -1; else if (targets.Count == 0) actIdRight = -1; else leftTarget = targets[0]; }
private void UpdateLeftActions() { // only run actions if id is not -1 if (actIdLeft >= 0) { if (actRetLeft == Action.ReturnType.Done) { // is a new action, so Init onUseActions[actIdLeft].Init(owner, leftTarget, null, null, gameObject); } actRetLeft = onUseActions[actIdLeft].Execute(owner, leftTarget, null, null, gameObject); if (actRetLeft == Action.ReturnType.Done) { actIdLeft++; if (actIdLeft >= onUseActions.Count) actRetLeft = Action.ReturnType.Exit; } else if (actRetLeft == Action.ReturnType.CallAgain) { // do nothing. will call again. // do not remove } else if (actRetLeft == Action.ReturnType.SkipNext) { actIdLeft += 2; actRetLeft = Action.ReturnType.Done; if (actIdLeft >= onUseActions.Count) actRetLeft = Action.ReturnType.Exit; } // ---------- note that the following should be last else if tests else if (actRetLeft <= Action.ReturnType.ExecuteSpecificNext && actRetLeft != Action.ReturnType.Exit) { Debug.LogError("There is no Action (0). Please specify a number higher than (0)."); actRetLeft = Action.ReturnType.Exit; } else if (actRetLeft > Action.ReturnType.ExecuteSpecificNext) { actIdLeft = (int)actRetLeft - (int)Action.ReturnType.ExecuteSpecificNext - 1; actRetLeft = Action.ReturnType.Done; if (actIdLeft >= onUseActions.Count) actRetLeft = Action.ReturnType.Exit; } // ---------- this should not be in else-if since the above code depends on something checking for Exit if (actRetLeft == Action.ReturnType.Exit) { actIdLeft = -1; // done with all actions } } }