Exemplo n.º 1
0
    public void AddState(ISMState state)
    {
        _states.Add(state.GetType(), state);
        var stateData = StateData.FirstOrDefault(s => s.GetStateType() == state.GetType());

        state.SetData(stateData);
    }
Exemplo n.º 2
0
    public bool ShouldOverrideCurrentState(ISMState currentState)
    {
        var hearing = _entityContainer.GetEntity <HearingEntity>();

        return(hearing.NoiseEntities.Count > 0 &&
               currentState.GetType() != typeof(ChaseState) &&
               currentState.GetType() != typeof(ClickerChaseState));
    }
Exemplo n.º 3
0
 public void ChangeState(Type stateType)
 {
     if (_currentState != null)
     {
         Debug.LogFormat("({1}) Exit [{0}]", _currentState.GetType().Name, gameObject.name);
         _currentState.OnStateExit();
         StopCoroutine(_currentStateExecute);
     }
     _currentState = _states[stateType];
     Debug.LogFormat("({1}) Enter [{0}]", _currentState.GetType().Name, gameObject.name);
     _currentState.OnStateEnter();
     Debug.LogFormat("({1}) Execute [{0}]", _currentState.GetType().Name, gameObject.name);
     _currentStateExecute = StartCoroutine(_currentState.OnStateExecute(this));
 }