Ejemplo n.º 1
0
        public void ChangeState(MonoState <T> pNewState)
        {
            if (pNewState == null)
            {
                Debug.LogError("该状态不存在");
            }

            if (currentState != pNewState)
            {
                //退出之前状态
                if (currentState != null)
                {
                    currentState.Exit(root);
                }

                //保存之前状态
                previousState = currentState;

                //设置当前状态
                currentState = pNewState;

                //进入当前状态
                if (currentState != null)
                {
                    currentState.Enter(root);
                }
            }
        }
Ejemplo n.º 2
0
 public void SetGlobalState(MonoState <T> state)
 {
     if (!globalStates.Contains(state))
     {
         state.Enter(root);
         globalStates.Add(state);
     }
 }
Ejemplo n.º 3
0
 public void SetCurrentState(MonoState <T> state)
 {
     currentState = state;
     currentState.Enter(root);
 }