예제 #1
0
 private void OnStateChange(CharacterBaseState previousState, CharacterBaseState newState)
 {
     if (OnStateChangeHandler != null)
     {
         OnStateChangeHandler.Invoke(previousState, newState);
     }
 }
예제 #2
0
        public void ReturnStateAnyway(CharacterBaseState nextState)
        {
            CurrentState.OnExit();
            CharacterBaseState tempState = PreviousState;

            PreviousState          = CurrentState;
            CurrentState           = tempState;
            CurrentState.NextState = nextState;
            OnStateChange(PreviousState, CurrentState);
            CurrentState.Initialize();
        }
예제 #3
0
 public void SetStateAnyway(CharacterBaseState newState, CharacterBaseState nextState)
 {
     if (CurrentState != newState)
     {
         CurrentState.OnExit();
         PreviousState          = CurrentState;
         CurrentState           = newState;
         CurrentState.NextState = nextState;
         OnStateChange(PreviousState, CurrentState);
         CurrentState.Initialize();
     }
 }
예제 #4
0
 public void ReturnStateOverride(CharacterBaseState nextState)
 {
     if (CurrentState.CanBeOverriden)
     {
         CurrentState.OnExit();
         CharacterBaseState tempState = PreviousState;
         PreviousState          = CurrentState;
         CurrentState           = tempState;
         CurrentState.NextState = nextState;
         OnStateChange(PreviousState, CurrentState);
         CurrentState.Initialize();
     }
 }
예제 #5
0
 public void ReturnState()
 {
     if (CurrentState.CanExit)
     {
         CurrentState.OnExit();
         CharacterBaseState tempState = PreviousState;
         PreviousState          = CurrentState;
         CurrentState           = tempState;
         CurrentState.NextState = null;
         OnStateChange(PreviousState, CurrentState);
         CurrentState.Initialize();
     }
 }
예제 #6
0
 public void SetStateOverride(CharacterBaseState newState)
 {
     if (CurrentState != newState)
     {
         if (CurrentState.CanBeOverriden)
         {
             CurrentState.OnExit();
             PreviousState          = CurrentState;
             CurrentState           = newState;
             CurrentState.NextState = null;
             OnStateChange(PreviousState, CurrentState);
             CurrentState.Initialize();
         }
     }
 }
예제 #7
0
 private void SetAttackingState(CharacterBaseState attackState)
 {
     if (attackState.IsAttacking)
     {
         if (CanAttack())
         {
             if (_characterModel.IsWeaponInHands)
             {
                 _stateMachine.SetStateOverride(attackState);
             }
             else
             {
                 _stateMachine.SetStateOverride(_stateMachine._gettingWeaponState);
             }
         }
     }
 }
예제 #8
0
        private void OnStateChange(CharacterBaseState previousState, CharacterBaseState currentState)
        {
            if (currentState.Type == StateType.Battle && !_characterModel.IsWeaponInHands)
            {
                _characterModel.CharacterSphereCollider.radius *= _characterModel.CharacterCommonSettings.SphereColliderRadiusIncrease;
                _stateMachine.SetStateOverride(_stateMachine._gettingWeaponState);
            }

            if (currentState.Type != StateType.Battle && _characterModel.IsWeaponInHands)
            {
                _characterModel.CharacterSphereCollider.radius = _characterModel.CharacterCommonSettings.SphereColliderRadius;
                _stateMachine.SetStateOverride(_stateMachine._removingWeaponState);
            }

            if (!previousState.IsTargeting && currentState.IsTargeting && !_stateMachine.CurrentState.IsAttacking)
            {
                _services.CameraService.SetActiveCamera(_services.CameraService.CharacterTargetCamera);
            }
            else if (previousState.IsTargeting && !currentState.IsTargeting && !_stateMachine.CurrentState.IsAttacking)
            {
                _services.CameraService.SetActiveCamera(_services.CameraService.CharacterFreelookCamera);
            }
        }
예제 #9
0
 public void SetStartState(CharacterBaseState startState)
 {
     PreviousState = startState;
     CurrentState  = startState;
 }
예제 #10
0
 private CharacterBaseState CreateState(CharacterBaseState newState)
 {
     _allStates.Add(newState);
     return(newState);
 }