/// <summary> /// Changes the player's attack state to target input player attack state type. IMPORTANT: Also calls the previous state's ExitState before switching. /// </summary> /// <typeparam name="TargetStateType">The intended attack state.</typeparam> public virtual void ChangeAttackState <TargetStateType>() where TargetStateType : PlayerAState { if (CurrentAttackState) { CurrentAttackState.ExitState(); Destroy(CurrentAttackState); } _currentAttackState = gameObject.AddComponent <TargetStateType>(); }
protected void Update() { CurrentMoveState.PerformState(); CurrentMoveState.TransitionState(); CurrentAttackState.PerformState(); CurrentAttackState.TransitionState(); CurrentConditionState.PerformState(); CurrentConditionState.TransitionState(); }
public void Update() { UpdatePosition(); CurrentAttackState.Update(this); }