public void ReceiveQuestCompletion(int questID) { if (currentState == FSM_State.WAITFORCALL) { currentState = stateBeforeWait; } GOAP_QuestBoard.instance.CompleteQuest(questID); }
public virtual void SetState(FSM_State _state) { if (state != null) { state.Exit(); } state = _state; state.Enter(); }
public void SetState(FSM_State state) { if (CurrentState != null) { CurrentState.ExitStack(); } state.EnterStack(); // enter state CurrentState = state; }
private void WaitForCallUpdate(float deltaTime) { if (timeWaitingForCall >= waitForCallTimer) { currentState = stateBeforeWait; } View.PrintMessage("Called"); timeWaitingForCall += deltaTime; }
public virtual void NextState() { state.Exit(); state = state.next; if (state == null) { Debug.Log("ERROR: Next state is null"); } state.Enter(); }
public void SetState(FSM_State state) { if (currentState != null) { currentState.End(); } currentState = state; currentState.Start(); }
private void ChangeState(FSM_State newState) { //EndStateActions switch (currentState) { case FSM_State.IDLE: break; case FSM_State.PLANNING: timeSincePlanned = 0.0f; break; case FSM_State.MOVETO: break; case FSM_State.PERFORMACTION: break; case FSM_State.WAITFORCALL: break; } //StartStateActions switch (newState) { case FSM_State.IDLE: break; case FSM_State.PLANNING: break; case FSM_State.MOVETO: break; case FSM_State.PERFORMACTION: break; case FSM_State.WAITFORCALL: if (currentState != FSM_State.WAITFORCALL) { stateBeforeWait = currentState; } timeWaitingForCall = 0.0f; break; } currentState = newState; }
public FSM_Square(int fsmId) : base(fsmId) { //create State ////WaitState //FSM_State waitState = new FSM_State((int)SquareState_ID.Wait); //waitState.Initialize(this, null, () => { }); FSM_State moveState = new FSM_State((int)SquareState_ID.Move); moveState.Initialize(this, null, () => { }); DisappearState disappearState = new DisappearState((int)SquareState_ID.Disappear); disappearState.Initialize(this, null, () => { }); }
public FSM_Block(int fsmId) : base(fsmId) { //create State //UpdateDownTimerState UpdateDownTimerState updateDownTimerState = new UpdateDownTimerState((int)BlockState_ID.UpdateDownTimer); updateDownTimerState.Initialize(this, null, () => { }); //JudgeDownState JudgeDownState judgeDownState = new JudgeDownState((int)BlockState_ID.JudgeDown); judgeDownState.Initialize(this, null, () => { }); //WaitState FSM_State waitState = new FSM_State((int)BlockState_ID.Wait); waitState.Initialize(this, null, () => { }); }
public void ChangeFsmState(Transition tr)//状态更改,performTransition { if (tr == Transition.NullTransition) { Debug.LogError("NullTransition is not allowed for a real transition"); return; } StateID id = CurrentState.GetOutPutState(tr); //当前状态会进入的新的状态 currentStateID = id; foreach (FSM_State state in states) //通过添加的所有状态,进行搜索来获取要进入的状态实例 { if (currentStateID == state.ID) { CurrentState.DoBeforeMoveing(); //退出状态前,留下点什么,比如挥舞下手臂 currentState = state; CurrentState.DoBeforeEnter(); //进入状态 break; } } }
public void AddFsmState(FSM_State s)//添加状态 { if (s == null) { Debug.LogError(" Null reference is not allowed"); } if (states.Count == 0) { states.Add(s); //设置默认状态; currentState = s; currentStateID = s.ID; return; } foreach (FSM_State state in states) { if (state == s) { Debug.LogError(s.ID.ToString() + "has already been added"); return; } } states.Add(s); }
public FSM() { currentState = null; }
// 상태변경 public void ChangeState(FSM_State<Slime> _State) { state.ChangeState(_State); }