private void ChangeState(eCampaignCharacterState newState, bool ignoreDeath = false) { eCampaignCharacterState previousState = _state; _state = newState; if (_currentHandler != null && !_currentHandler.IsFinished) { _currentHandler.End(newState); CodeObjectManager.GetCharacterStateManager(_currentHandler.GetType()).Destroy(_currentHandler); } System.Type handlerType = _stateHandlers[State]; _currentHandler = (CharacterStateHandler)CodeObjectManager.GetCharacterStateManager(handlerType).GetNext(); _currentHandler.Controller = _controller; _currentHandler.MoveController = _moveController; //_currentHandler.Stats = _statsComponent; _currentHandler.Locomotion = LocomotionComponent; _currentHandler.Combat = _combatController; _currentHandler.ViewRPC = _viewRPC; //_currentHandler.EffectReceiver = _effectReceiver; _currentHandler.Conditions = _conditionComponent; _currentHandler.Targeting = _targetingComponent; _currentHandler.Character = this; _currentHandler.Begin(previousState); _moveController.SetPlaybackSpeed(1.0f); }
void OnDisable() { CharacterComponentManager.sCharacterComponents.Remove(this); if (_currentHandler != null) { _currentHandler.End(eCampaignCharacterState.Idle); CodeObjectManager.GetCharacterStateManager(_currentHandler.GetType()).Destroy(_currentHandler); _currentHandler = null; } }
private void Awake() { instance = this; myCameraOriginalPosition = Camera.main.transform.position; originalPosition = transform.position; originalRotation = transform.rotation; manipulator = GetComponentInChildren <CharacterManipulatorScript>(); stateHandler = GetComponentInChildren <CharacterStateHandler>(); freefallControls = GetComponentInChildren <FreefallControls>(); parachuteControls = GetComponentInChildren <ParachuteControls>(); }
protected virtual void Awake() { stateHandler = GetComponent<CharacterStateHandler>(); stateHandler.onTakeDamage += CalculateHealth; stateHandler.onHealing += CalculateHealth; }
public void MakeMonsterIfRequired( ) { if (stateHandler == null) { stateHandler = GetComponent<CharacterStateHandler>( ); } stateHandler.MakeMonsterIfRequired( ); }
private void Setup( ) { characterAnimator = GetComponent<Animator>( ); stateHandler = GetComponent<CharacterStateHandler>( ); currentPlayerState = stateHandler.currentState; if (!isAMonster) { inventory = GetComponent<PlayerInventory>( ); } StartCoroutine( AssignObserverWhenReady( ) ); if (isLocalPlayer) { screenOverlay = GetComponentInChildren<ScreenOverlay>( ); } setupRun = true; }