コード例 #1
0
ファイル: FSM.cs プロジェクト: SpiritWolf2015/imooc_Ten
 public FSM()
 {
     State root = new State();
     root.name = "root";
     this.states_["root"]  = root;
     this.currState_.Add(root);
 }
コード例 #2
0
ファイル: FSM.cs プロジェクト: JackieRen/GameJam2016
		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;

		}
コード例 #3
0
ファイル: FSM.cs プロジェクト: kinglion/GDGeekByGDGeek
        /// <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;
        }
コード例 #4
0
ファイル: FSM.cs プロジェクト: gdgeek/fly
 public FSM(bool debug = false)
 {
     debug_ = debug;
     State root = new State();
     root.name = "root";
     this.states_["root"]  = root;
     this.currState_.Add(root);
 }
コード例 #5
0
ファイル: FSM.cs プロジェクト: SpiritWolf2015/imooc_Ten
        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;
        }
コード例 #6
0
ファイル: FSM.cs プロジェクト: SpiritWolf2015/imooc_Ten
 public void addState(string stateName, State state)
 {
     this.addState (stateName, state, "");
 }
コード例 #7
0
ファイル: FSM.cs プロジェクト: JackieRen/GameJam2016
		public void addState(string stateName, string defSubState, State state, string fatherName){
			this.addState (stateName, state, fatherName);		
			state.defSubState = defSubState;
		}
コード例 #8
0
ファイル: FSM.cs プロジェクト: JackieRen/GameJam2016
		public void addState(string stateName, string defSubState, State state){
			this.addState (stateName, state, "");		
			state.defSubState = defSubState;
		}