private void OnStateChange(CharacterBaseState previousState, CharacterBaseState newState) { if (OnStateChangeHandler != null) { OnStateChangeHandler.Invoke(previousState, newState); } }
public void ReturnStateAnyway(CharacterBaseState nextState) { CurrentState.OnExit(); CharacterBaseState tempState = PreviousState; PreviousState = CurrentState; CurrentState = tempState; CurrentState.NextState = nextState; OnStateChange(PreviousState, CurrentState); CurrentState.Initialize(); }
public void SetStateAnyway(CharacterBaseState newState, CharacterBaseState nextState) { if (CurrentState != newState) { CurrentState.OnExit(); PreviousState = CurrentState; CurrentState = newState; CurrentState.NextState = nextState; OnStateChange(PreviousState, CurrentState); CurrentState.Initialize(); } }
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(); } }
public void ReturnState() { if (CurrentState.CanExit) { CurrentState.OnExit(); CharacterBaseState tempState = PreviousState; PreviousState = CurrentState; CurrentState = tempState; CurrentState.NextState = null; OnStateChange(PreviousState, CurrentState); CurrentState.Initialize(); } }
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(); } } }
private void SetAttackingState(CharacterBaseState attackState) { if (attackState.IsAttacking) { if (CanAttack()) { if (_characterModel.IsWeaponInHands) { _stateMachine.SetStateOverride(attackState); } else { _stateMachine.SetStateOverride(_stateMachine._gettingWeaponState); } } } }
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); } }
public void SetStartState(CharacterBaseState startState) { PreviousState = startState; CurrentState = startState; }
private CharacterBaseState CreateState(CharacterBaseState newState) { _allStates.Add(newState); return(newState); }