public void RegisterCombo(ComboActionNode comboNode, params ComboActionType[] actions) { Debug.AssertFormat(comboNode != null, "cannot register null combo node"); Debug.AssertFormat(actions.Length != 0, "cannot register combo with no actions"); ComboActionNode curNode = initialNode; string comboString = ""; // walk till the last node for (int i = 0; i < actions.Length - 1; ++i) { ComboActionType action = actions[i]; #if DEBUG comboString += action.ToString() + ", "; Debug.AssertFormat(curNode.next[(int)action] != null, this.name + " combo ({0}) is null, please register this combo first", comboString); #endif curNode = curNode.next[(int)action]; } ComboActionType lastAction = actions[actions.Length - 1]; // get the last action #if DEBUG comboString += lastAction.ToString(); // need to separate it like this, because we're checking for null // but we will grab the value from the null for the call to Debug.assertformat as a parameter // so need to make sure that it's not null first if (curNode.next[(int)lastAction] != null) { Debug.AssertFormat(false, this.name + " combo ({0}) already exist: {1}", comboString, curNode.next[(int)lastAction].GetType().ToString()); } #endif // set the next action to be the given node curNode.next[(int)lastAction] = comboNode; // set the previous action node of the given to be the current node comboNode.prev = curNode; // save the manager comboNode.manager = this; Debug.Log(String.Format("{0} registered combo [{1}] -> [{2}]", this.name, comboString, comboNode.GetType().ToString())); }
public void DoAction(ComboActionType action) { // if busy dont bother if (status == Status.RunningCombo) { return; } // get the next action var nextAction = currentNode.next[(int)action]; // check if action possible if (nextAction == null) { // action not possible, reset Debug.Log("no more action available, Resetting"); Reset(); return; } // move current node to the next action actionsBuffer.Add(action); currentNode = nextAction; isBusy = true; Debug.Log(String.Format(this.name + " combo: [{0}] -> {1}", GetActionsBufferString(), currentNode.GetType().ToString())); // begin the action currentNode.Begin(); // begin the animation switch (action) { case ComboActionType.LightAttack: { animator.SetTrigger("lightAttack"); break; } case ComboActionType.HeavyAttack: { animator.SetTrigger("heavyAttack"); break; } } }