Exemple #1
0
    private void UpdateState()
    {
        AbstractEnemyState newState = null;

        if (idleState.conditionsMet(this) && currentState.Name != idleState.Name)
        {
            newState = idleState;
        }

        if (patrolState.conditionsMet(this) && currentState.Name != patrolState.Name)
        {
            newState = patrolState;
        }

        if (chaseState.conditionsMet(this) && currentState.Name != chaseState.Name)
        {
            newState = chaseState;
        }

        if (attackState.conditionsMet(this) && currentState.Name != attackState.Name)
        {
            newState = attackState;
        }

        if (newState != null && newState != currentState)
        {
            newState.init();
            lastState    = currentState;
            currentState = newState;
        }
    }
Exemple #2
0
    private void UpdateState()
    {
        AbstractEnemyState newState = null;

        if (idleState.conditionsMet(this) && currentState.Name != idleState.Name)
        {
            newState = idleState;
        }

        if (patrolState.conditionsMet(this) && currentState.Name != patrolState.Name)
        {
            newState = patrolState;
        }

        if (runnerState.conditionsMet(this) && currentState.Name != runnerState.Name)
        {
            newState = runnerState;
        }

        if (summonerState.conditionsMet(this) && currentState.Name != summonerState.Name)
        {
            newState = summonerState;
        }


        if (newState != null && newState != currentState)
        {
            newState.init();
            lastState    = currentState;
            currentState = newState;
        }
    }