public void ChangeState(Translate tr) { if (tr == Translate.NullTrans) { Debug.LogError("can't find the state"); } StateID statusID = currentState.GetOutState(tr); foreach (FMS_State state in states) { if (statusID == state.ID) { currentState.DoBeforeLeave(); currentState = state; currentState.DoBeforeEnter(); break; } } }
private void AddFSMState(FMS_State s) { if (s == null) { Debug.LogError(" Null reference is not allowed"); } if (states.Count == 0) { states.Add(s); //设置默认状态(important); currentState = s; currentStateID = s.ID; return; } foreach (FMS_State state in states) { if (state == s) { Debug.LogError(s.ID.ToString() + "has already been added"); return; } } states.Add(s); }