// Add Transition public void AddTransition(Transition trans, StateID id) { //check if transition exist if(trans == Transition.NULL) { Debug.LogError("Trying to add a null transition"); return; } if(id == StateID.NULL) { Debug.LogError("Trying to add a null state"); return; } if(trans == Transition.E_NOHP) { Debug.Log("trans: " + trans.ToString() + " StateID: " + id.ToString()); } // check if current map already contains key if(map.ContainsKey(trans)) { Debug.LogError(trans.ToString() + " transition Exist, unable to have duplicate transitions for State: " + id.ToString()); return; } map.Add(trans, id); Debug.Log("Sucessfully added: " + trans.ToString() + " id extract: " + map[trans] + " Current StateID: " + STATE_ID.ToString()); }
public void AddState(NPCState newState) { if (newState == null) { Debug.LogError("StateManager AddState(): Null state"); } if (states.Count == 0) { states.Add(newState); currentState = newState; currentStateID = newState.ID; return; } foreach (NPCState state in states) { if (state.ID == newState.ID) { Debug.LogError("StateManager AddState(): " + newState.ID.ToString() + " already exists"); return; } } states.Add(newState); }
public void UpdateStateMachine() { StateID nextStateID = stateDictionary[stateMachine.GetCurrentAnimatorStateInfo(0).fullPathHash]; if (nextStateID != currentStateID) //If state has changed { currentStateID = nextStateID; foreach (FSMState state in states) //Get state { if (state.GetStateID() == currentStateID) { if (currentState != null) { currentState.ResetState(); } currentState = state; break; } } } if (currentState != null) { currentState.UpdateState(); //update current state } }
// Add State public void AddState(FSMState tstate) { if(tstate == null) { Debug.LogError("Null reference when adding State"); return; } // Initial State if(states.Count == 0) { states.Add(tstate); curState = tstate; curStateID = tstate.STATE_ID; return; } // Check for duplicate State before adding foreach(FSMState s in states) { if(s.STATE_ID == tstate.STATE_ID) { Debug.LogError("Trying to add Duplicate state: " + tstate.STATE_ID.ToString()); return; } } states.Add(tstate); }
public void AddTransition(Transition trans, StateID id) { // Check if anyone of the args is invalid if (trans == Transition.NullTransition) { Debug.LogError("FSMState ERROR: NullTransition is not allowed for a real transition"); return; } if (id == StateID.NullStateID) { Debug.LogError("FSMState ERROR: NullStateID is not allowed for a real ID"); return; } // Since this is a Deterministic FSM, // check if the current transition was already inside the map if (map.ContainsKey(trans)) { Debug.LogError("FSMState ERROR: State " + stateID.ToString() + " already has transition " + trans.ToString() + "Impossible to assign to another state"); return; } map.Add(trans, id); }
public void AddState(FSMState s) { if(s==null) { Debug.LogError("FSM ERROR:添加的状态不允许为空"); return; } //第一次添加状态的时候完成初始化 if(states.Count==0) { states.Add(s); s.StateChange+=StateChange; CurrentState=s; CurrentStateID=s.ID; return; } foreach(FSMState state in states) { if(state.ID==s.ID) { Debug.LogError("FSM ERROR:不能向状态机里面重复添加相同的状态"); return; } } states.Add (s); s.StateChange += StateChange; }
/// <summary> /// This method places new states inside the FSM, /// or prints an ERROR message if the state was already inside the List. /// First state added is also the initial state. /// </summary> public void AddState(FSMState s) { // Check for Null reference before deleting if (s == null) { Debug.LogError("FSM ERROR: Null reference is not allowed"); } // First State inserted is also the Initial state, // the state the machine is in when the simulation begins if (states.Count == 0) { states.Add(s); currentState = s; currentStateID = s.ID; return; } // Add the state to the List if it's not inside it foreach (FSMState state in states) { if (state.ID == s.ID) { Debug.LogError("FSM ERROR: Impossible to add state " + s.ID.ToString() + " because state has already been added"); return; } } states.Add(s); }
public void AddTransition(Transition trans, StateID id) { //first step of the fsm //check the args and see if they are invalid if (trans == Transition.NullTransition) { Debug.LogError("FSM had a pretty bad error. Null transition is not allowed for a real tranisition. \n You have a shit ton of work david"); return; } if (id == StateID.NullStateID) { Debug.LogError("FSM had a pretty bad error. Null STATE id is not allowed for a real ID"); return; } // deterministic FSM // check if current transition was already inside the map if (map.ContainsKey(trans)) { // f**k, if this hits ive hit a transition that already has a transition // Enum enumerations = RuntimeTypeHandle.ReferenceEquals(StateID); Debug.LogError("FSM had a pretty bad error" + stateID.ToString() + " Already has a transition" +trans.ToString() + " Impossible to assign to another state"); return; } map.Add(trans, id); }
private State createState(StateID stateID) { //StateConstructor found = mFactories[stateID]; //State state = found(); State state = null; try { switch (stateID) { case StateID.Menu: state = new MenuState(this, mContext); break; case StateID.Title: state = new TitleState(this, mContext); break; case StateID.Game: state = new GameState(this, mContext); break; case StateID.Pause: state = new PauseState(this, mContext); break; case StateID.Setting: state = new SettingState(this, mContext); break; } } catch (Exception e) { Console.WriteLine(e.Message + " In state creation"); } return state; }
public EnemyRandomWalk(StateID stateID, NPCBreadcrumb enemyReference) { this.stateID = stateID; this.enemyReference = enemyReference; NPCBreadcrumb.FoundPlayer += FoundPlayer; }
/// <summary> /// Adds a new State into the FSM if it isn't already inside. /// The first state is also the initial state. /// </summary> /// <param name="state">State which will be added.</param> public void AddState(FSMState state) { if (state == null) Debug.LogError("FSMSystem: Null reference is not allowed!"); else if (states.Count == 0) // Set initial state if it is the first state. { states.Add(state); currentState = state; currentStateID = state.ID; } else { bool added = false; // Check if the state aready has been added. foreach (FSMState s in states) { if (s.ID == state.ID) { added = true; Debug.LogError("FSMSystem: State " + state.ID.ToString() + " has already been added."); } } if (!added) states.Add(state); } }
/// <summary> /// Add New State into the list /// </summary> public void AddFSMState(FSMState fsmState) { // Check for Null reference before deleting if (fsmState == null) { Debug.LogError("FSM ERROR: Null reference is not allowed"); } // First State inserted is also the Initial state // the state the machine is in when the simulation begins if (fsmStates.Count == 0) { fsmStates.Add(fsmState); currentState = fsmState; currentStateID = fsmState.ID; return; } // Add the state to the List if it´s not inside it foreach (FSMState state in fsmStates) { if (state.ID == fsmState.ID) { Debug.LogError("FSM ERROR: Trying to add a state that was already inside the list"); return; } } //If no state in the current then add the state to the list fsmStates.Add(fsmState); }
public StateTransition(TransitionID transitionID, StateID nextStateID) { this.TransitionID = transitionID; this.NextStateID = nextStateID; this.EventsRunning = false; RemoveAllEvents(); }
public void SetState(StateID stateID) { if(!states.ContainsKey(stateID)) return; if(currentState != null) currentState.Leave(); currentState = states[stateID]; currentState.Enter(); }
//Function to handle statemachine public void ChangeState( State<EnemySniperScript> s ) { if(s.GetType().Name == "Sniper_AttackPlayer"){ CurrentState = StateID.attacking; } if(s.GetType().Name == "Sniper_MoveToPlayer"){ CurrentState = StateID.moving; } StateMachine.ChangeState ( s ); }
public void AddTransition(Transition newTransition, StateID newId) { if (map.ContainsKey (newTransition)) { Debug.LogError("Error: Transition " + newTransition + " already in map."); return; } map.Add (newTransition, newId); Debug.Log ("Added transition: " + newTransition); }
/// <summary> /// Adds a transition with the corresponding state. /// </summary> /// <param name="transition">Transition</param> /// <param name="id">State</param> public void AddTransition(Transition transition, StateID id) { // Check if the params are invalid, if valid --> add Transition to the map. if (transition == Transition.NullTransition) Debug.LogError("FSMState: NullTransition!"); else if (id == StateID.NullStateID) Debug.LogError("FSMState: NullStateID!"); else if (map.ContainsKey(transition)) Debug.LogError("FSMState: State " + stateID.ToString() + " already has transition " + transition.ToString() + "!"); else map.Add(transition, id); }
public FSMState GetFSMState(StateID stateId) { int numFSMStates = allFSMStates.Count; for(int i = 0; i < numFSMStates; ++i) { FSMState fsmState = allFSMStates[i]; if (fsmState != null && fsmState.GetStateId() == stateId) { return fsmState; } } return null; }
public override void ChangeState(StateID stateID) { // Cambio la animacion ChangeAnimation(stateID == StateID.Stop ? StateID.Forward : stateID); // Paro el sonido anterior Sounds[(int)CurrentState.ID].Stop(); // Cambio el estado base.ChangeState(stateID); // Cambio el sonido en reproduccion Sounds[(int)CurrentState.ID].Play(); }
/// <summary> /// Class constructor. /// <param name="id">State identifier</param> /// </summary> protected State(StateID id) { //Set identifier m_ID = id; //Set default value m_Active = true; m_PopUp = false; m_VisibleCursor = false; //Create layers m_Layer = SpriteManager.AddLayer(); m_Panel = new List<Control>(); }
public bool GotoFSMState(StateID stateId) { FSMState fsmState = this.GetFSMState(stateId); if(fsmState == null) { return false; } if(this.currentFSMState != null) { this.currentFSMState.Exit(); } this.currentFSMState = fsmState; this.currentFSMState.Enter(); return true; }
/// <summary> /// Method om de state te wijzigen /// </summary> public void SetState(StateID stateID) { /** als we de stateID niet kennen als state: stop deze functie dan */ if(!states.ContainsKey(stateID)) return; /** als we ons al in een state bevinden: geef de state de mogelijkheid zich op te ruimen */ if(currentState != null) currentState.Leave(); /** we stellen de nieuwe currentState in */ currentState = states[stateID]; /** we geven de nieuwe state de mogelijkheid om zich zelf in te stellen */ currentState.Enter(); }
/// <summary> /// Create a new state based on state identifier. /// </summary> /// <param name="id">State type identifier.</param> /// <param name="parameters">Parameter that is needed by the state constructor</param> /// <returns></returns> public State CreateState(StateID id, object[] parameters) { //Return state based on ID switch (id) { case StateID.Title: return new StateTitle(); case StateID.Story: return new StateStory(parameters[0] as string, parameters[1] as string); case StateID.Config: return new StateConfig(); case StateID.Game: return new StateGame((Player)parameters[0], parameters[1] as Game.GameData); case StateID.GameOver: return new StateGameOver((int)parameters[0], (TimeSpan)parameters[1], (int)parameters[2], (int)parameters[3]); case StateID.Pause: return new StatePause((bool)parameters[0]); case StateID.InitEditor: return new StateInitEditor(); case StateID.Editor: return new StateEditor((int)parameters[0], (int)parameters[1]); case StateID.Credit: return new StateStory(parameters[0] as string, parameters[1] as string); default: throw new Exception(Global.UNKNOWNSTATE_ERROR); } }
public void DeleteState(StateID id) { if (id == StateID.NullStateID) { Debug.LogError("StateManager DeleteState(): NullStateID!"); return; } foreach (NPCState state in states) { if (state.ID == id) { states.Remove(state); return; } } Debug.LogError("StateManager DeleteState(): " + id.ToString() + " not in list"); }
public void DelateFsmState(StateID id)//移除状态 { if (id == StateID.NullStateId) { Debug.LogError("NullStateID is not allowed for a real state"); return; } foreach (FSM_State state in states) { if (state.ID == id) { states.Remove(state); return; } } Debug.LogError("FSM ERROR: Impossible to delete state " + id.ToString() + ". It was not on the list of states"); }
public override void UpdateController() { if (this.fsm != null && this.fsm.CurrentState != null) { if (LastStateID != CurrentStateID) { Debug.LogWarning("CurrentState :" + CurrentStateID.ToString()); LastStateID = CurrentStateID; } this.fsm.CurrentState.DoCheck(); this.fsm.CurrentState.DoAct(); } if (this.aniController != null) { this.aniController.UpdateAnimation(); } this.aniController.sprite_main.SortingOrder = 10000 - (int)this.myTransform.position.y; }
public void DeleteState(StateID id) { if (id == StateID.NULL) { Debug.LogError("id is not allowed null"); return; } foreach (FSMState fsmState in states) { if (fsmState.ID == id) { states.Remove(fsmState); break; } } Debug.LogError("you will delete" + id.ToString() + "is not exist"); }
public void AddTransition(Transition trans, StateID stateID) { if (trans == Transition.NullTransition) { Debug.LogError("添加转换条件失败,不可为空条件"); return; } if (stateID == StateID.NullState) { Debug.LogError("添加转换状态失败,不可为空状态"); return; } if (_Map.ContainsKey(trans)) { Debug.LogError("添加转换条件失败,以添加过条件"); return; } _Map.Add(trans, stateID); }
// next method deletes a state from FSM list if it already exists // or prints an error message if the state should exist but doesnt. public void DeleteState(StateID id) { // check if its a null state // if so, someone f****d up, make sure that the state is instanciated at some point if you want to delete it if (id == StateID.NullStateID) { Debug.LogError("FSM error, the id passed in is not a real state"); return; } foreach (FSMState state in states) { if (state.ID == id) { states.Remove(state); return; } } Debug.LogError("FRM error. impossible to delete state " + id.ToString() + ". it was not in the list of states."); }
public void AddTransition(Transition trans,StateID id) { if(trans==Transition.NullTransition) { Debug.LogError("FSM ERROR:map中转换不能为NullTransition"); return; } if(id==StateID.NullStateID) { Debug.LogError("FSM ERROR:空状态标签不能添加到map中,而且一个实际的状态标签不能为空"); return; } if(map.ContainsKey(trans)) { Debug.LogError(id.ToString()+"FSM ERROR:已经存在"+trans.ToString()+"的转换了"); return; } map.Add(trans,id); }
public void DeleteState(StateID id) { if(id==StateID.NullStateID) { Debug.LogError("FSM ERROR:状态机中不可能存在空状态"); return; } foreach(FSMState state in states) { if(state.ID==id) { states.Remove(state); state.StateChange-=StateChange; return; } } Debug.LogError ("FSM ERROR:状态机中的不存在ID为"+id.ToString()+"的状态"); return; }
/// <summary> /// 트랜지션 확인. /// </summary> public void PerformTransition(Transition trans) { // Check for NullTransition before changing the current state if (trans == Transition.NullTransition) { Debug.LogError("FSM ERROR: NullTransition is not allowed for a real transition"); return; } // Check if the currentState has the transition passed as argument StateID id = currentState.GetOutputState(trans); if (id == StateID.NULLSTATEID) { if (currentState.controller == null) { Debug.LogError("FSM ERROR: State " + currentStateID.ToString() + " does not have a target state " + " for transition " + trans.ToString()); } else { Debug.LogError("FSM ERROR: State " + currentStateID.ToString() + " does not have a target state " + " for transition " + trans.ToString() + " at " + currentState.controller.gameObject.name); } return; } // Update the currentStateID and currentState currentStateID = id; foreach (FSMState state in states) { if (state.ID == currentStateID) { // Do the post processing of the state before setting the new one currentState.DoBeforeLeaving(); currentState = state; // Reset the state to its desired condition before it can reason or act currentState.DoBeforeEntering(); break; } } } // PerformTransition()
//删除状态 public void DeleteState(StateID id) { if (id == StateID.NullStateID) { Debug.LogError("FSM ERROR: NullStateID is not allowed for a real state"); return; } //遍历列表,若存在该状态则删除 foreach (FSMstate state in states) { if (state.ID == id) { states.Remove(state); return; } } //否则打印错误信息 Debug.LogError("FSM ERROR: Impossible to delete state " + id.ToString() + ". It was not on the list of states"); }
/// <summary> /// Deletes a state if it exists. /// </summary> /// <param name="id">State id</param> public void DeleteState(StateID id) { if (id == StateID.NullStateID) { Debug.LogError("FSMSystem: NullStateID not allowed!"); } else { //Search for the state. foreach (FSMState state in states) { if (state.ID == id) { states.Remove(state); return; // :( } } Debug.LogError("FSMState: State with the id " + id.ToString() + " was not found."); } }
/// <summary> /// Change state /// </summary> public void SetState(StateID stateID) { /** If we don't know the state, stop this function */ if (!states.ContainsKey(stateID)) { return; } /** If we already have a state, give the state a chance to clear itself */ if (currentState != null) { currentState.Leave(); } /** set new 'CurrentState' */ currentState = states[stateID]; /** Give the new state a chance to set up */ currentState.Enter(); }
/// <summary> /// Returns other values related to this form control. /// </summary> /// <returns>Returns an array where first dimension is attribute name and the second dimension is its value.</returns> public override object[,] GetOtherValues() { if (!String.IsNullOrEmpty(StateIDColumnName)) { // Set properties names object[,] values = new object[1, 2]; values[0, 0] = StateIDColumnName; if (StateID > 0) { values[0, 1] = StateID.ToString(); } else { values[0, 1] = null; } return(values); } return(null); }
/// <summary> /// This method delete a state from the FSM List if it exists, /// or prints an ERROR message if the state was not on the List. /// </summary> public void DeleteState(StateID fsmState) { // Check for NullState before deleting if (fsmState == StateID.None) { Debug.LogError("FSM ERROR: bull id is not allowed"); return; } // Search the List and delete the state if it´s inside it foreach (FSMState state in fsmStates) { if (state.ID == fsmState) { fsmStates.Remove(state); return; } } Debug.LogError("FSM ERROR: The state passed was not on the list. Impossible to delete it"); }
/// <summary> /// Adds a transition with the corresponding state. /// </summary> /// <param name="transition">Transition</param> /// <param name="id">State</param> public void AddTransition(Transition transition, StateID id) { // Check if the params are invalid, if valid --> add Transition to the map. if (transition == Transition.NullTransition) { Debug.LogError("FSMState: NullTransition!"); } else if (id == StateID.NullStateID) { Debug.LogError("FSMState: NullStateID!"); } else if (map.ContainsKey(transition)) { Debug.LogError("FSMState: State " + stateID.ToString() + " already has transition " + transition.ToString() + "!"); } else { map.Add(transition, id); } }
public void AddTransition(FSMTransition transition, StateID id) { // Check if anyone of the args is invallid if (transition == FSMTransition.None || id == StateID.None) { Debug.LogWarning("FSMState : Null transition not allowed"); return; } //Since this is a Deterministc FSM, //Check if the current transition was already inside the map if (map.ContainsKey(transition)) { Debug.LogWarning("FSMState ERROR: transition is already inside the map"); return; } map.Add(transition, id); // Debug.Log("Added : " + transition + " with ID : " + id); }
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; } } }
/// 删除状态 public void DeleteState(StateID id) { // 空值检验 if (id == StateID.NullStateID) { Debug.LogError("FSM ERROR: 状态ID 不可为空ID"); return; } // 遍历并删除状态 foreach (FSMState state in states) { if (state.ID == id) { states.Remove(state); return; } } Debug.LogError("FSM ERROR: 无法删除状态 " + id.ToString() + ". 状态列表中不存在"); }
public void SetTransition(Transition t) { StateID NextActionStateID = fsm.CurrentState.GetOutputState(t); //only attack action need to check attack AI strategy if (StateIDToActionID.ContainsKey(NextActionStateID)) { Action NextAction = StateIDToActionID[NextActionStateID]; float ActionValue = DragonKnowledge.GetStateActionValue(fsm.CurrentState.MDPQstate.EndState, NextAction); if (ActionValue < -0.006 || DragonKnowledge.GetStateLearningInfo(fsm.CurrentState.MDPQstate.EndState)) { //performing UCB and find the next action StateID NextStateID = DragonKnowledge.UCBPolicy(fsm.CurrentState.MDPQstate.EndState); fsm.PerformAITransition(NextStateID); return; } } fsm.PerformTransition(t); }
// Delete State public void DeleteState(StateID id) { if(id == StateID.NULL) { Debug.LogError("Unable to Delete Null State"); return; } foreach(FSMState s in states) { if(s.STATE_ID == id) { states.Remove(s); return; } } // Unable to locate State Debug.LogError("Unable to locate state with StateID: " + id.ToString()); }
/// <summary> /// Method om de state te wijzigen /// </summary> public void SetState(StateID stateID) { /** als we de stateID niet kennen als state: stop deze functie dan */ if (!states.ContainsKey(stateID)) { return; } /** als we ons al in een state bevinden: geef de state de mogelijkheid zich op te ruimen */ if (currentState != null) { currentState.Leave(); } /** we stellen de nieuwe currentState in */ currentState = states[stateID]; /** we geven de nieuwe state de mogelijkheid om zich zelf in te stellen */ currentState.Enter(); }
public void AddTransition(Transition trans, StateID id) { if (trans == Transition.NullTransition || id == StateID.NullStateID) { Debug.LogError("transition or id is null"); return; } if (map == null) { Debug.LogError("map is null"); } if (map.ContainsKey(trans)) { Debug.LogError("transition is already in dictionary"); return; } map.Add(trans, id); }
public void AddTrantision(Transition transition, StateID stateID) { if (transition == Transition.NullTransition) { Debug.LogError("FSMState Error: transition 不允许为空"); return; } if (stateID == StateID.NullStateID) { Debug.LogError("FSMState Error: stateID 不允许为空"); return; } if (map.ContainsKey(transition)) { Debug.Log("FSMState Error: transition 已经存在map中"); return; } map.Add(transition, stateID); }
public void EndCurrentStateToOtherState(StateID id) { if (!IsAlive) { return; } if (NpcControl.Fsm.CurrentStateID != id) { switch (id) { case StateID.Idle: NpcControl.SetTransition(Transition.Idle, this); break; case StateID.Walk: NpcControl.SetTransition(Transition.FreeWalk, this); break; case StateID.Acct: NpcControl.SetTransition(Transition.Acct, this); break; case StateID.Skill: NpcControl.SetTransition(Transition.Skill, this); break; case StateID.Switch: NpcControl.SetTransition(Transition.Switch, this); break; case StateID.CrashPlayer: NpcControl.SetTransition(Transition.CrashPlayer, this); break; case StateID.Dead: ItemDropMgr.Instance.DropRareItem(CacheModel.position, Attribute.Score, GameMgr.Instance.ItemRoot); NpcControl.SetTransition(Transition.Dead, this); break; } } }
//从系统中删除状态 public void DeleteState(StateID id) { if (id == StateID.NullStateID) { Debug.LogError("FSM ERROR: NullState is not allowed for a real state"); return; } foreach (FSMState state in states) { if (state.ID != id) { continue; } states.Remove(state); return; } Debug.LogError("FSM ERROR: Impossible to delete state " + id + ". It was not on the list of states"); }
//控制状态之间的转换 public void PreformTransition(Transition trans) { if (trans == Transition.NullTransition) { Debug.LogError("NullTransition is not allowed for real transition "); return; } StateID id = currentState.GetOutputState(trans); if (id == StateID.NullStateID) { Debug.Log("Transition is not to be happened!没有符合条件的转换"); return; } FSMState state; states.TryGetValue(id, out state); currentState.DoBeforeLeaving(); currentState = state; currentState.DoBeforeEntering(); }
/// <summary> /// 基于转换参数,改变现在的状态 /// </summary> /// <param name="trans"></param> public void PerformTransition(Transition trans) { // 根绝当前的状态类,以Trans为参数调用它的 GetOutputState 方法 StateID id = currentState.GetNextState(trans); // 更新现在的状态 currentStateID = id; FSMState fs; if (states.TryGetValue(currentStateID, out fs)) { currentState.DoBeforeLeaving(); currentState = fs; currentState.DoBeforeEntering(); } else { Debug.LogError("FSM CHANGE ERROR: The FsmSystem is not contain the FsmState."); return; } }
private void SwitchState(StateID state) { switch (state) { case StateID.Follow: Follow(); break; case StateID.Attack: Attack(); break; case StateID.Idle: Idle(); break; default: Idle(); break; } }
/// <summary>Finds the Main Animal used as Player on the Active Scene</summary> void FindMainAnimal() { var animal = MAnimal.MainAnimal; if (animal) { activePlayer = animal.gameObject; //Set the Current Player activeAnimal = animal; //Set the Current Controller animal.OnStateChange.AddListener(OnCharacterDead); //Listen to the Animal changes of states animal.TeleportRot(transform); //Move the Animal to is Start Position RespawnState = RespawnState ?? animal.OverrideStartState; animal.OverrideStartState = RespawnState; } else if (activePlayer == null && player != null) { InstantiateNewPlayer(); } }
private Dictionary <Translate, StateID> map = new Dictionary <Translate, StateID>(); //在某一状态下,事件引起了触发进入另一个状态 // 于是我们定义了一个字典,存储的便是触发的类型,以及对应要进入的状态 public void addDictionary(Translate tr, StateID id1) //向字典里添加 { if (tr == Translate.NullTrans) { Debug.LogError("Null Trans is not allower to adding into"); return; } if (ID == StateID.NullState) { Debug.LogError("Null State id not ~~~"); return; } if (map.ContainsKey(tr)) //NPC 任何时候都只能出于一种状态,所以一旦定义了一个触发的枚举类型,对应的只能是接下来的一种状态 { Debug.LogError(id1.ToString() + "is already added to"); return; } map.Add(tr, id1); }
public void AddTRANSITION(Transition trans, StateID id) { if (trans == Transition.NullTransition) { Debug.LogError("The Transition is error"); return; } if (id == StateID.NullStateID) { Debug.LogError("The State is error"); return; } if (map.ContainsKey(trans)) { Debug.LogError("The FSM already have this transition for state"); return; } map.Add(trans, id); }
} // PerformTransition() public State GetState(StateID id) { // Check for NullState before deleting if (id == StateID.eStateID_Null) { Debug.LogError("FSM ERROR: NullStateID is not allowed for a real state"); return(null); } // Search the List and delete the state if it's inside it foreach (State state in _states) { if (state.ID == id) { return(state); } } Debug.LogError("FSM ERROR: Impossible to get state " + id.ToString() + ". It was not on the list of states"); return(null); }
/// <summary> /// This method delete a state from the FSM List if it exists, /// or prints an ERROR message if the state was not on the List. /// </summary> public void DeleteState(StateID id) { // Check for NullState before deleting if (id == StateID.NullStateID) { Debug.LogError("FSM ERROR: NullStateID is not allowed for a real state"); return; } // Search the List and delete the state if it's inside it foreach (FSMState state in states) { if (state.ID == id) { states.Remove(state); return; } } Debug.LogError("FSM ERROR: Impossible to delete state " + id.ToString() + ". It was not on the list of states"); }
protected void CountryID_SelectedIndexChanged(object sender, EventArgs e) { System.Data.DataView dv = (System.Data.DataView) this.HasStateDataSource.Select(DataSourceSelectArguments.Empty); string hasState = dv[0][0].ToString(); if (hasState == "True") { this.lblStateID.Style.Add("display", ""); StateID.Style.Add("display", ""); StateID.DataBind(); StateID.Items.Insert(0, new ListItem("--Select--", "0")); StateID.SelectedIndex = -1; StateValidator.Enabled = true; } else { this.lblStateID.Style.Add("display", "none"); StateID.Style.Add("display", "none"); StateValidator.Enabled = false; } }
/// <summary> /// State manager class constructor /// </summary> public StateManager(StateID id, object[] parameters) { //Save starting state data m_StartState = id; m_StartParameters = parameters; //Set device m_SpriteBatch = null; m_Device = new GraphicsDeviceManager(this); //Configure engine #region Engine configuration Content.RootDirectory = CONTENT_ROOT; IsMouseVisible = SHOW_CURSOR; IsFixedTimeStep = FIXED_STEP; m_Device.IsFullScreen = Global.APP_FULLSCREEN; m_Device.PreferMultiSampling = Global.APP_ANTIALIAS; m_Device.PreferredBackBufferWidth = Global.APP_WIDTH; m_Device.PreferredBackBufferHeight = Global.APP_HEIGHT; #endregion //Create GUI Manager #region Global GUI manager instantiation Global.GUIManager = new Manager(this, m_Device, GUI_SKIN, false); Global.GUIManager.RenderTargetUsage = RenderTargetUsage.DiscardContents; #endregion //Create other global engines Global.SoundManager = new SoundManager(); Global.Logger = new Logger(Global.APP_NAME); //Create state list m_Depth = 0; m_StateList = new LinkedList<State>(); m_StateList.Clear(); //Logging Global.Logger.AddLine("Engine started."); }
public void AddTransition(Transition trans, StateID id) { if(trans == Transition.NullTransition) { Debug.LogError("FSMState Error: NullTransition is not allowed for a real transition"); return; } if(id == StateID.NullStateID) { Debug.LogError("FSMState Error: NullStateID is not allowed for a real ID"); return; } if(map.ContainsKey(trans)) { Debug.LogError("FSMState Error: State " + stateID.ToString() + " already has transition " + trans.ToString() + ". Impossible to assign to another state"); return; } map.Add(trans, id); }