//State Related Methods////////////////////
 public void SetState(Type state)
 {
     if (_currentState.GetType() == state)
     {
         return;
     }
     Debug.Log("Player Changing from: " + _currentState.GetType() + " to: " + state);
     _currentState.EndState();
     _currentState = _states[state];
     _currentState.BeginState();
 }
Exemple #2
0
    //添加新状态到集合
    void AddState <T>() where T : PlayerStateBase
    {
        //添加状态类脚本到物体
        PlayerStateBase state = gameObject.AddComponent <T>();

        state.OnInit();                     //初始化状态
        states.Add(state.GetType(), state); //添加到状态集合
    }
Exemple #3
0
 public Type GetStateType() =>
 state.GetType();