void ExecuteCommand(EnemyCommand queuedCommand) { switch (queuedCommand) { case EnemyCommand.SHOOT: if (!isRotating) { if (enemyShoot.PlayerInRange) { enemyShoot.ShootProjectile(target); } this.queuedCommand = EnemyCommand.NOTHING; } return; case EnemyCommand.ROOT: if (!isRotating) { this.queuedCommand = EnemyCommand.NOTHING; if (enemyRoot.PlayerInRange) { enemyRoot.ShootRootProjectile(target); } } return; default: return; } }
public EnemyEntityState GetNext(EnemyCommand command) { StateTransition transition = new StateTransition(CurrentState, command); EnemyEntityState nextState; if (!transitions.TryGetValue(transition, out nextState)) throw new Exception("Invalid transition: " + CurrentState + " -> " + command); return nextState; }
public EnemyEntityState GetNext(EnemyCommand command) { StateTransition transition = new StateTransition(CurrentState, command); EnemyEntityState nextState; if (!transitions.TryGetValue(transition, out nextState)) { throw new Exception("Invalid transition: " + CurrentState + " -> " + command); } return(nextState); }
public EnemyEntityState MoveNext(EnemyCommand command) { CurrentState = GetNext(command); return CurrentState; }
public StateTransition(EnemyEntityState currentState, EnemyCommand command) { CurrentState = currentState; Command = command; }
public EnemyEntityState MoveNext(EnemyCommand command) { CurrentState = GetNext(command); return(CurrentState); }
public void NewCommand(EnemyCommand command) { this.queuedCommand = command; }