Exemple #1
0
 public FSM()
 {
     State root = new State();
     root.name = "root";
     this.states_["root"]  = root;
     this.currState_.Add(root);
 }
Exemple #2
0
		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;

		}
Exemple #3
0
        /// <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;
        }
Exemple #4
0
 public FSM(bool debug = false)
 {
     debug_ = debug;
     State root = new State();
     root.name = "root";
     this.states_["root"]  = root;
     this.currState_.Add(root);
 }
Exemple #5
0
        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;
        }
Exemple #6
0
 public void addState(string stateName, State state)
 {
     this.addState (stateName, state, "");
 }
Exemple #7
0
		public void addState(string stateName, string defSubState, State state, string fatherName){
			this.addState (stateName, state, fatherName);		
			state.defSubState = defSubState;
		}
Exemple #8
0
		public void addState(string stateName, string defSubState, State state){
			this.addState (stateName, state, "");		
			state.defSubState = defSubState;
		}