Ejemplo n.º 1
0
    /// <summary>
    /// Changes the player's movement state to target input player movement state type. IMPORTANT: Also calls the previous state's ExitState before switching.
    /// </summary>
    /// <typeparam name="TargetStateType">The intended movement state. MUST BE "PlayerMState"</typeparam>
    public virtual void ChangeMoveState <TargetStateType>() where TargetStateType : PlayerMState
    {
        if (CurrentMoveState)
        {
            CurrentMoveState.ExitState();
            Destroy(CurrentMoveState);
        }

        _currentMovementState = gameObject.AddComponent <TargetStateType>();
    }
Ejemplo n.º 2
0
    protected void Update()
    {
        CurrentMoveState.PerformState();
        CurrentMoveState.TransitionState();

        CurrentAttackState.PerformState();
        CurrentAttackState.TransitionState();

        CurrentConditionState.PerformState();
        CurrentConditionState.TransitionState();
    }