Beispiel #1
0
    public void ChangeState(IPlayerState currentState, IPlayerState targetState)
    {
        m_PlayerPreviousState = currentState;
        currentState.OnStateExit();

        targetState.OnStateEnter();
        m_PlayerCurrentState = targetState;
    }
Beispiel #2
0
    public void OnStateChanged(IPlayerState state)
    {
        if (m_currentState != null)
        {
            m_currentState.OnStateExit();
        }

        m_currentState = state;
        m_currentState.OnStateEnter();
    }
Beispiel #3
0
    public void ChangeState(IPlayerState targetState)
    {
        if (m_PlayerCurrentState != null)
        {
            m_PlayerPreviousState = m_PlayerCurrentState;
            m_PlayerCurrentState.OnStateExit();
        }

        targetState.OnStateEnter();
        m_PlayerCurrentState = targetState;
    }
Beispiel #4
0
        async public Task ChangePlayerState(PlayerStates _state, PlayerStates stateToChange, IInteractableController interactableController = null)
        {
            previousState = currentState;
            if (previousState != null)
            {
                previousState.OnStateExit();
            }
            switch (_state)
            {
            case PlayerStates.AMBUSH:
                currentState = new PlayerAmbushState(playerView, this, playerService);

                break;

            case PlayerStates.DISGUISE:
                currentState = new PlayerDisguiseState(playerView, this, playerService);

                break;

            case PlayerStates.IDLE:
                currentState = new PlayerIdleState(playerView, this, playerService);

                break;

            case PlayerStates.SHOOTING:
                currentState = new PlayerShootingState(playerView, this, playerService);
                break;

            case PlayerStates.UNLOCK_DOOR:
                currentState = new PlayerDoorUnlock(playerView, this, playerService);
                break;

            case PlayerStates.WAIT_FOR_INPUT:
                currentState = new PlayerWaitingForInputState(playerView, this, playerService);
                break;

            case PlayerStates.THROWING:
                currentState = new PlayerThrowingState(playerView, this, playerService);
                break;

            case PlayerStates.END_TURN:
                currentState = new PlayerEndTurnState(playerView, this, playerService);
                break;

            case PlayerStates.INTERMEDIATE_MOVE:
                currentState = new PlayerIntermediateMoveState(playerView, this, playerService);
                break;

            default:
                currentState = new PlayerIdleState(playerView, this, playerService);
                break;
            }
            if (interactableController != null && stateToChange != PlayerStates.NONE)
            {
                await currentState.OnStateEnter(stateToChange, interactableController);
            }
            else
            {
                await currentState.OnStateEnter();
            }
        }