Ejemplo n.º 1
0
    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;
        }
    }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
 public EnemyEntityState MoveNext(EnemyCommand command)
 {
     CurrentState = GetNext(command);
     return CurrentState;
 }
Ejemplo n.º 5
0
 public StateTransition(EnemyEntityState currentState, EnemyCommand command)
 {
     CurrentState = currentState;
     Command = command;
 }
Ejemplo n.º 6
0
 public EnemyEntityState MoveNext(EnemyCommand command)
 {
     CurrentState = GetNext(command);
     return(CurrentState);
 }
Ejemplo n.º 7
0
 public StateTransition(EnemyEntityState currentState, EnemyCommand command)
 {
     CurrentState = currentState;
     Command      = command;
 }
Ejemplo n.º 8
0
 public void NewCommand(EnemyCommand command)
 {
     this.queuedCommand = command;
 }