예제 #1
0
    public override void TransitionState(SpearStates state)
    {
        if (currentState != null)
        {
            currentState.OnTransition(spear);
        }

        currentState     = GetSpearState(state);
        currentStateName = currentState.ToString();
        currentState.EnterState(spear);
    }
    public CharacterStateMachine(PlatformerController controller)
    {
        _controller = controller;

        IdleState      = new CharacterIdleState(this, _controller);
        MoveState      = new CharacterMoveState(this, _controller);
        JumpState      = new CharacterJumpState(this, _controller);
        FallingState   = new CharacterFallingState(this, _controller);
        WallSlideState = new CharacterWallSlideState(this, _controller);
        WallJumpState  = new CharacterWallJumpState(this, _controller);

        _state = IdleState;
    }
 public void ChangeState(CharacterBaseState newState)
 {
     _state.OnStateExit();
     _state = newState;
     _state.OnStateEnter();
 }