/// <summary> /// 如果要判断为同一状态,不进行切换,调用,true 判断,false 不判断 /// </summary> /// <param name="nextState"></param> /// <param name="ignor">是否判断为同一状态</param> /// <returns></returns> public virtual bool ChangeState(MState <T> nextState, bool isSame) { if (LockCurrentState) { return(false); } if (nextState == null) { Debug.Log("State Machine ===> nextState is null State"); return(false); } //if (CurrenState == null) //{ } if (isSame && nextState.Name == CurrenState.Name) { //Debug.Log(CurrenState.Name + " <<=======>> " + nextState.Name); return(false); } previousState = (CurrenState == null) ? nextState : CurrenState; CurrenState.Exit(); //Debug.Log("_currenState = " + _currenState.Name); //Debug.Log("nextState = " + _currenState.Name); CurrenState = nextState; CurrenState.Enter(); return(true); }
public void SetGolbalState(MState <T> state) { if (golbalState != null) { golbalState.Exit(); } golbalState = state; if (golbalState != null) { golbalState.Enter(); } }