public FSM() { State root = new State(); root.name = "root"; this.states_["root"] = root; this.currState_.Add(root); }
public void addState(string stateName, State state, string fatherName){ if(fatherName == ""){ state.fatherName = "root"; }else{ state.fatherName = fatherName; } state.getCurrState = delegate (string name){ for(int i = 0; i< this.currState_.Count; ++i){ State s = this.currState_[i] as State; if(s.name == name) { return s; } } return null; }; if (this.states_.ContainsKey (state.fatherName)) { if(string.IsNullOrEmpty(this.states_[state.fatherName].defSubState)){ this.states_[state.fatherName].defSubState = stateName; } } this.states_[stateName] = state; }
/// <summary> /// 状态的注册 /// </summary> /// <param name="stateName"></param> /// <param name="state"></param> /// <param name="fatherName"></param> public void addState(string stateName, State state, string fatherName) { if(fatherName == ""){ state.fatherName = "root"; } else{ state.fatherName = fatherName; } //根据名字获得该状态,如果当前状态列表中有的话直接返回没有返回为null state.getCurrState = delegate (string name){ for(int i = 0; i< this.currState_.Count; ++i){ State s = this.currState_[i] as State; Debug.Log(s.name +":"+name); if(s.name == name) { return s; } } return null; }; this.states_[stateName] = state; }
public FSM(bool debug = false) { debug_ = debug; State root = new State(); root.name = "root"; this.states_["root"] = root; this.currState_.Add(root); }
public void addState(string stateName, State state, string fatherName) { if(fatherName == ""){ state.fatherName = "root"; } else{ state.fatherName = fatherName; } state.getCurrState = delegate (string name){ for(int i = 0; i< this.currState_.Count; ++i){ State s = this.currState_[i] as State; if(s.name == name) { return s; } } return null; }; this.states_[stateName] = state; }
public void addState(string stateName, State state) { this.addState (stateName, state, ""); }
public void addState(string stateName, string defSubState, State state, string fatherName){ this.addState (stateName, state, fatherName); state.defSubState = defSubState; }
public void addState(string stateName, string defSubState, State state){ this.addState (stateName, state, ""); state.defSubState = defSubState; }