// Select the next attack based on the current action and input (Melee / Magic) // Return the current action if there is no match or if there is no moveset // Note: The time complexity of this algorithm is O(n^4), but since the move size is typically less than 15 moves (<1 ms runtime), it should be okay public bool ChooseMove(PlayerInput.Action moveType) { foreach (Moveset moveset in movesets) { if (moveset == null) { continue; } // Moveset: Melee, Magic or Utility? if (moveType == moveset.moveType) { foreach (Move move in moveset.moves) { bool skip = false; // Iterate through each equipped move's transitions to find one that matches the current action foreach (string transition in move.canTransitionFrom) { // If a valid transition matches the current action, return the corresponding move if (transition == playerStateName) { if (InCorrectPosition(move)) { selectedMoveset = moveset; selectedMove = move; return(true); } } } if (move.canTransitionFrom[0] == "All") { // Exceptions to any transitions foreach (string nonTransition in move.cannotTransitionFrom) { if (nonTransition == playerStateName) { skip = true; break; } } if (!skip && InCorrectPosition(move)) { selectedMoveset = moveset; selectedMove = move; return(true); } } } } } return(false); }
void HandleInput(PlayerInput.Action action) { if (stateManager.canAttack) { stateManager.playerState.HandleInput(action); } else if (attackTimer.timer >= (stateManager.selectedMove.recoverFrame - 1f) / AttackTimer.FPS && attackTimer.timer <= stateManager.selectedMove.recoverFrame / AttackTimer.FPS) { // Attack buffering attackTimer.isQueued = true; attackTimer.action = action; } }
public override void HandleInput(PlayerInput.Action action) { if (action == PlayerInput.Action.Jump) { Jump(); } else { // TODO: Rename "ChooseMove" to something better bool canAttack = stateManager.ChooseMove(action); if (canAttack) { stateManager.controller.attackTimer.StartMove(); Attacks(stateManager.selectedMove); } } }
public virtual void HandleInput(PlayerInput.Action action) { }