public void SetCurrentState(E key) { IQState <T> state = Get(key); currentState = state; currentState.Enter(); }
public void ChangeState(E key) { IQState <T> state = Get(key); if (state == null) { Debug.LogError("该状态不存在: " + key); return; } if (currentState == state) { Debug.LogError("该状态已存在: " + key); return; } //退出之前状态 if (currentState != null) { currentState.Exit(); } //设置当前状态 currentState = state; //进入当前状态 if (currentState != null) { currentState.Enter(); } }
public void SetGlobalState(E key) { IQState <T> state = Get(key); if (!globalStates.Contains(state)) { state.Enter(); globalStates.Add(state); } }