public void AddState(FSMState state) { if (state == null) { Debug.LogError("FSM ERROR: Null State reference"); return; } if (stateList.Count == 0) { stateList.Add(state); currentState = state; currentStateId = state.StateID; return; } foreach (FSMState tempState in stateList) { if (state.StateID == tempState.StateID) { Debug.LogError("state [" + state.StateID.ToString() + "] already added."); return; } } stateList.Add(state); }
public void AddFSMState(FSMState fsmState) { if(fsmState != null) { if(fsmStates.Count == 0) { fsmStates.Add(fsmState); currentState = fsmState; currentStateId = fsmState.ID; } else { foreach(FSMState state in fsmStates) { if(state.ID == fsmState.ID) { Debug.LogWarning("The FSM State was already in the list"); return; } } fsmStates.Add(fsmState); } } else { Debug.LogError("The FSM State is null"); } }
public void initializeDefStates() { FSMState fall = new FSMState(PlayerStates.FALLING); fall.addTransition(PlayerActions.RUN, PlayerStates.RUNNING); fall.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.FALL_JUMP); fsmStates.Add(fall); FSMState run = new FSMState(PlayerStates.RUNNING); run.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.JUMPING); run.addTransition(PlayerActions.FALL, PlayerStates.FALLING); fsmStates.Add(run); FSMState jump = new FSMState(PlayerStates.JUMPING); jump.addTransition(PlayerActions.FALL, PlayerStates.FALLING); jump.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.DOUBLE_JUMPING); jump.addTransition(PlayerActions.WALL_SLIDE, PlayerStates.WALL_SLIDING); fsmStates.Add(jump); FSMState doubleJump = new FSMState(PlayerStates.DOUBLE_JUMPING); doubleJump.addTransition(PlayerActions.FALL, PlayerStates.FALLING); doubleJump.addTransition(PlayerActions.WALL_SLIDE, PlayerStates.WALL_SLIDING); fsmStates.Add(doubleJump); FSMState fallJump = new FSMState(PlayerStates.FALL_JUMP); fallJump.addTransition(PlayerActions.FALL, PlayerStates.RUNNING); fsmStates.Add(fallJump); FSMState wallSliding = new FSMState(PlayerStates.WALL_SLIDING); wallSliding.addTransition(PlayerActions.RUN, PlayerStates.RUNNING); wallSliding.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.JUMPING); fsmStates.Add(wallSliding); }
protected override void Initialize() { player = GameObject.FindGameObjectWithTag("Player"); playercontroller = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); curState = FSMState.Idle; isDirection(); }
public void AddFSMState(FSMState fsmState) { if (fsmState == null) { Debug.LogError("state is null"); return; } if (fsmStates.Count == 0) { fsmStates.Add(fsmState); curState = fsmState; curStateID = fsmState.ID; return; } foreach (var state in fsmStates) { if (state.ID == fsmState.ID) { Debug.LogError("state has exist"); return; } } fsmStates.Add(fsmState); }
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; }
public override void EnterState(FSMState prevState) { base.EnterState(prevState); if((HeroState)prevState.StateId == HeroState.Seek) _destination = (prevState as HeroSeekState).Destination; }
public void AddToQueue(FSMState state) { if (state) { m_StateQueue.Enqueue(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 ChangeState(FSMTransition stateTransition) { Enum nextStateId = stateTransition.NextStateId; FSMState prevState = CurrentState; if(nextStateId == null) { CurrentState = _stateStack.Pop(); } else { FSMState nextState = GetState(nextStateId); if(nextState == null) throw new Exception("State " + nextStateId.ToString() + " has not been defined."); if(stateTransition.PushCurrentState) _stateStack.Push(CurrentState); CurrentState = nextState; CurrentState.InitState(stateTransition); } Debug.Log("Changed state to: " + CurrentState.StateId.ToString()); CurrentState.EnterState(stateTransition); if(prevState != null && !stateTransition.PushCurrentState) prevState.Dispose(); }
public void UpdateFSMMachine(float fDelta) { if (this.allFSMStates.Count != 0) { if (this.currentFSMState == null) { this.currentFSMState = this.GetFSMState(this.defaultStateId); if(this.currentFSMState != null) { this.currentFSMState.Enter(); } } if (this.currentFSMState != null) { StateID stateId = this.currentFSMState.GetStateId(); StateID transitionStateId = this.currentFSMState.CheckTransitions(); if (transitionStateId != stateId) { FSMState fsmState = this.GetFSMState(transitionStateId); if (fsmState != null) { this.currentFSMState.Exit(); this.currentFSMState = fsmState; this.currentFSMState.Enter(); } } this.currentFSMState.Update(fDelta); } } }
/// <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); }
protected void UpdateAttackingState() { SendMessage("Shoot"); currentState = FSMState.Evading; evadingRotation = Random.rotation; }
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 } }
public void Update() { if (!this.isWorking) { return; } this.CheckCooldowns(); if (this.currentState.isFinalState) { this.StopMachine(); // Debug.Log("Ending Machine with " + this.currentState.state); this.currentState.OnExit(ref this.variables, this.previousStateName, null); } else { this.currentState.Update(ref this.variables, this.previousStateName); foreach (FSMTransition transition in this.transitions[this.currentState.state]) { string toState = transition.toState; if (transition.TransitionValid(this.variables) && states.ContainsKey(toState)) { this.currentState.OnExit(ref this.variables, this.previousStateName, toState); // Debug.Log("Transitioning FROM " + this.currentState.state + " TO " + toState); if (this.OnTransition != null) { this.OnTransition(toState); } this.previousStateName = this.currentState.state; this.currentState = this.states[toState]; this.currentState.OnStart(ref this.variables, this.previousStateName); foreach (FSMTransition newStateTransition in this.transitions[toState]) { newStateTransition.UpdateConditions(); } break; } } } }
/// <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); }
/// <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); } }
public void AddState(FSMState state) { if(HasState(state.StateId)) throw new Exception("State " + state.StateId.ToString() + " is already defined."); _states.Add(state); }
public void initializeDefStates() { //should this be hardcoded? FSMState fall = new FSMState(PlayerStates.FALLING); fall.addTransition(PlayerActions.LAND,PlayerStates.STANDING); fsmStates.Add(fall); FSMState stand = new FSMState(PlayerStates.STANDING); stand.addTransition(PlayerActions.WALK_INPUT,PlayerStates.WALKING); stand.addTransition(PlayerActions.RUN_INPUT,PlayerStates.RUNNING); stand.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING); fsmStates.Add(stand); FSMState walk = new FSMState(PlayerStates.WALKING); walk.addTransition(PlayerActions.RUN_INPUT,PlayerStates.RUNNING); walk.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING); walk.addTransition(PlayerActions.STOP,PlayerStates.STANDING); walk.addTransition(PlayerActions.FALL,PlayerStates.FALLING); fsmStates.Add(walk); FSMState run = new FSMState(PlayerStates.RUNNING); run.addTransition(PlayerActions.WALK_INPUT,PlayerStates.WALKING); run.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING); run.addTransition(PlayerActions.STOP,PlayerStates.STANDING); run.addTransition(PlayerActions.FALL,PlayerStates.FALLING); fsmStates.Add(run); FSMState jump = new FSMState(PlayerStates.JUMPING); jump.addTransition(PlayerActions.FALL,PlayerStates.FALLING); jump.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING); fsmStates.Add(jump); }
protected void ExecuteLookState() { //Debug.Log ("LookState"); Quaternion targetRotation = Quaternion.LookRotation(objPlayer.transform.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 10.0f); curState = (Vector3.Distance (transform.position, objPlayer.transform.position) < 10.0f) ? FSMState.Attack : FSMState.Look; }
public void StartMachine(FSMState initialState) { this.RegisterState(initialState); this.initialState = initialState; this.currentState = initialState; this.currentState.OnStart(ref this.variables, this.previousStateName); this.isWorking = true; }
public void AddState( string name, FSMState.UpdateDelegate updateDelegate = null ) { _states.Add( name, new FSMState( name, updateDelegate ) ); if ( _states.Count == 1 ) { _currentState = _states[name]; } }
private void CheckForNecessaryStateChange() { if(IsPlayerStuckForTooLong()) state = FSMState.ARRIVE; if (StuckOnAState()) state = FSMState.ARRIVE_SIDE; }
public void RemoveState(FSMState item) { this.DeleteState (item.ID); foreach(FSMState state in fsmStates) { state.DeleteTransition(item.RequiredTransition); } }
/// <summary> /// Change the specified name. /// </summary> /// <param name="name">Name.</param> public virtual void change (string name) { if (states.ContainsKey (name)) { if (currentState != null) currentState.exit (this); currentState = states [name]; currentState.enter (this); } }
public void CollisionCallback(Collision col) { if(col.collider.transform.root.tag == playerTransform.tag) { // Low chance of deciding to evade int r = Random.Range(0, 300); if(r==0) this.state = FSMState.EVADE; } }
protected void ExecuteNoneState() { //Debug.Log ("NoneState"); if (Vector3.Distance(transform.position, objPlayer.transform.position) < 13.0f) { curState = FSMState.Look; } }
protected override void Initialize() { //StartPosition ?? currentState = FSMState.Spawn; //Casually orbiting the player target = GameObject.FindGameObjectWithTag ("Player").transform; }
public void SetState( string newState ) { if ( _states.ContainsKey(newState) ) { _currentState = _states[newState]; } else { Debug.LogWarning("FSM: Trying to set state that doesn't exist: " + newState); } }
protected void ExecuteChaseState() { //Debug.Log ("ChaseState"); if (Vector3.Distance (transform.position, objPlayer.transform.position) < 11.0f) { Quaternion targetRotation = Quaternion.LookRotation(objPlayer.transform.position - transform.position); transform.rotation = Quaternion.Slerp (transform.rotation, targetRotation, Time.deltaTime * 5.0f); transform.Translate (Vector3.forward * Time.deltaTime * speed); } else { curState = FSMState.Look; } }
public MoveAction(FSMState owner) : base(owner) { }
//ステートの初期設定メソッド、ownerと初期ステートを確定させる。 public void Configure(T owner, FSMState <T> InitialState) { Owner = owner; ChangeState(InitialState); }
public TextAction(FSMState owner) : base(owner) { }
public void DeleteState(FSMState state) { //安全检查 states.Remove(state.State); }
public void Configure(T newOwner, FSMState <T> initialState) { owner = newOwner; ChangeState(initialState); }
void SetInitState(e_State state) { _fsmState = _fsm.GetState(state); _fsmState.OnEnter(); }
/// <summary> /// 添加状态 /// </summary> /// <param name="state">State.</param> public void AddState(string name) { StateDict[name] = new FSMState(name); }
public override void Enter(FSMState lastState) { // base.Enter(lastState); elapsedTime = 0F; Messenger.Broadcast(CurrentMemeko.gameObject.GetInstanceID() + "EnterIdle"); }
/// <summary> /// Initializes a new instance of the <see cref="FSMTransition"/> class. /// </summary> /// <param name='toState'> /// State to trnasition to. /// </param> /// <param name='delegateFunction'> /// Code to execute on transition. /// </param> public FSMTransition(FSMState toState, OnTransitionDelegate delegateFunction) { _toState = toState; _delegate = delegateFunction; }
void changeState(FSMState <SelectDragonController> e) { FSM.Change(e); runResources(); }
protected override void MakeTransitions(FSMState state, E_HunterState e) { state.ClearTransitions(); switch (e) { case E_HunterState.IDLE: state.AddTransitions( new MyTransition( () => { bool hasCommision = true; //캐릭터 틀에서 수임 여부 hasCommision = CharactorFrame.GetInstance().hunterIdea.hasCommission; if (hasCommision) { return(true); } else { return(false); } }, GetState(E_HunterState.HUNT_REWARD), GetState(E_HunterState.INQUIRE_QUEST) ) ); break; case E_HunterState.INQUIRE_QUEST: state.AddTransitions(new PlayerChoiceTransition( GetState(E_HunterState.INQUIRE_QUEST_SELECT_START) , GetState(E_HunterState.INQUIRE_QUEST_CANCEL))); break; case E_HunterState.INQUIRE_QUEST_SELECT_START: //퀘스트 인콰이;어 ui에서 플레이어초이스에 퀘스트 선택 여부를 담음. state.AddTransitions( new PlayerChoiceTransition( GetState(E_HunterState.INQUIRE_QUEST_ACCEPT), GetState(E_HunterState.INQUIRE_QUEST_CANCEL))); /* 무기렌탈 로직을 퀘스트 인콰이어와 합쳤음. * , * new MyTransition( * ()=> * { * bool pc = EventParameterStorage.GetInstance().PlayerChoice; * * if (pc == true)//퀘스트 선택창의 제출 버튼을 누른것. * { * //요구능력 치에 따라서 징징과 어셉트를 구분해야함. #if DEBUG_TEST * if (fsmTestHunter.GetInstance().isHuntersPowerMoreThanQuest) * { * return true; * } #else * if ( * QuestManager.GetInstance().GetQuest( * EventParameterStorage.GetInstance().selectedQuestKey) * .GetWeight() * <= * CharactorFrame.GetInstance().hunterIdea.HuntingCapabillity * * ) //만약 헌터의 능력치가 퀘스트의 요구 능력치를 상회한다면. ) * { * return true; * } #endif * else return false;//헌터의 능력치가 퀘스트의 요구 능력치에 못미침. * } * return false; //의미 없음. * } * ,GetState(E_HunterState.INQUIRE_QUEST_ACCEPT), * GetState(E_HunterState.INQUIRE_QUEST_RENTAL_REQUIRE) * ) * */ break; case E_HunterState.INQUIRE_QUEST_ACCEPT: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); break; /*무기 렌탈 로직을 퀘스트 인콰이어와 합침. * case E_HunterState.INQUIRE_QUEST_RENTAL_REQUIRE: * state.AddTransitions(new PlayerChoiceTransition(GetState(E_HunterState.INQUIRE_QUEST_RENTAL_START), * GetState(E_HunterState.INQUIRE_QUEST_ACCEPT)//징징 했으나 무시해서 그냥 의뢰만 받아감. * )); * break; * * case E_HunterState.INQUIRE_QUEST_RENTAL_START: * state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); * //무기를 빌려주든 말든 그 로직처리는 ui 제출 버튼 쪽에서 할테니까. * //그냥 리브 해주면 됨. * break; */ case E_HunterState.INQUIRE_QUEST_CANCEL: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); break; case E_HunterState.HUNT_REWARD: state.AddTransitions( new MyTransition( () => { bool rentalSth = true; //캐릭터 틀이든 뭐든 대여한 무기가 있는지, 없는지 검사함. bool isRentalBroken = true; //무기의 내구도 도 조건이야... HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; rentalSth = hunter.DidRentalWeapon(); if (rentalSth) { isRentalBroken = hunter.IsBrokenRental(); } if (rentalSth && isRentalBroken) //빌린게 있음. 그리고 그것은 부서진 것이 존재한다. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_RETURN_OF_RENTAL_BROKEN), null ) , new MyTransition( () => { bool rentalSth = true; //캐릭터 틀이든 뭐든 대여한 무기가 있는지, 없는지 검사함. bool isRentalBroken = true; //무기의 내구도 도 조건이야... HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; rentalSth = hunter.DidRentalWeapon(); if (rentalSth) { isRentalBroken = hunter.IsBrokenRental(); } if (rentalSth && !isRentalBroken) //빌린게 있음. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_RETURN_OF_RENTAL_NOT_BROKEN), null ) , new MyTransition( () => { bool rentalSth = true; //캐릭터 틀이든 뭐든 대여한 무기가 있는지, 없는지 검사함. bool expired = true; //만기에 늦었는지. HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; rentalSth = hunter.DidRentalWeapon(); expired = hunter.haveComeBeforeExpire; if (!rentalSth && expired) //빌린게 있음. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_EXPIRED), null ) , new MyTransition( () => { bool rentalSth = true; //캐릭터 틀이든 뭐든 대여한 무기가 있는지, 없는지 검사함. bool expired = true; //만기에 늦었는지. HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; rentalSth = hunter.DidRentalWeapon(); expired = hunter.haveComeBeforeExpire; if (!rentalSth && !expired) //빌리지 않았고, 만기에 늦지도 않았음. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_START), null ) ); break; case E_HunterState.HUNT_REWARD_RETURN_OF_RENTAL_NOT_BROKEN: state.AddTransitions( new MyTransition( () => { bool expired = true; //만기 전에 왔었는지 어쟀는지. HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; expired = hunter.haveComeBeforeExpire; if (expired) //만지 전에 왔었다가 그냥 갔음. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_EXPIRED), GetState(E_HunterState.HUNT_REWARD_START) )); break; case E_HunterState.HUNT_REWARD_RETURN_OF_RENTAL_BROKEN: state.AddTransitions( new MyTransition( () => { bool expired = true; //만기 전에 왔었는지 어쟀는지. HunterIdea hunter = CharactorFrame.GetInstance().hunterIdea; expired = hunter.haveComeBeforeExpire; if (expired) //만지 전에 왔었다가 그냥 갔음. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_EXPIRED), GetState(E_HunterState.HUNT_REWARD_START) )); break; case E_HunterState.HUNT_REWARD_EXPIRED: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.HUNT_REWARD_START))); break; case E_HunterState.HUNT_REWARD_START: state.AddTransitions( new MyTransition( () => { int pmc = EventParameterStorage.GetInstance().PlayerMultipleChoice; if (pmc == 0) //완전지불이면 { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_ALL_PAYMENT), null ), new MyTransition( () => { int pmc = EventParameterStorage.GetInstance().PlayerMultipleChoice; if (pmc == 2) //지불 거부, 거래쫑이면. { return(true); } else { return(false); } } , GetState(E_HunterState.HUNT_REWARD_DENIED), null ), new MyTransition( () => { int pmc = EventParameterStorage.GetInstance().PlayerMultipleChoice; bool beSulk = true; beSulk = CharactorFrame.GetInstance().hunterIdea.IsSulked(); if (pmc == 1) //부분지불이면 { if (false == beSulk) //성격 등등을 통해 갬블하고 //삐쳤으면 거래 거부 해버림. //안 삐쳤으면 부분 지불 받고 감. { return(true); } else { return(false); } } else { Debug.LogError("EPS에러." + pmc); return(false); } } , GetState(E_HunterState.HUNT_REWARD_PARTIAL_PAYMENT), GetState(E_HunterState.HUNT_REWARD_DENIED) ) ); break; case E_HunterState.HUNT_REWARD_ALL_PAYMENT: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); break; case E_HunterState.HUNT_REWARD_PARTIAL_PAYMENT: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); break; case E_HunterState.HUNT_REWARD_DENIED: state.AddTransitions(new TriggerTransition(GetState(E_HunterState.LEAVE))); break; case E_HunterState.LEAVE: break; } }
void mentalState() { mental_player_Canvas.SetActive(true); main_Canvas.enabled = false; player_Canvas.enabled = false; if (voltandoDoMiniGame_Mental == false) { player_text_mental.text = array_Dialogo_mental[Dialogo_mental__CURRENT_INDEX]; main_Sprite.sprite = sprites_Dialogo_mental[Dialogo_mental__CURRENT_INDEX]; if (Dialogo_mental__CURRENT_INDEX == array_Dialogo_mental.Length - 1) { if (ativar_minigame_p1) { StartCoroutine(irParaMiniGames_P1()); } else if (ativar_minigame_p2) { StartCoroutine(irParaMiniGames_P2()); } else { state = FSMState.Boiando; desativarTUDO(); } } } else { if (script_pensamentoController.tipo_resposta_Pesamento == "Resposta 1") { player_text_mental.text = array_Dialogo_mental_Minigame_1[Dialogo_mental__CURRENT_INDEX]; main_Sprite.sprite = sprites_Dialogo_mental_Minigame_1[Dialogo_mental__CURRENT_INDEX]; if (Dialogo_mental__CURRENT_INDEX == array_Dialogo_balao_Minigame_1.Length - 1) { state = FSMState.Boiando; desativarTUDO(); } } if (script_pensamentoController.tipo_resposta_Pesamento == "Resposta 2") { player_text_mental.text = array_Dialogo_mental_Minigame_2[Dialogo_mental__CURRENT_INDEX]; main_Sprite.sprite = sprites_Dialogo_mental_Minigame_2[Dialogo_mental__CURRENT_INDEX]; if (Dialogo_mental__CURRENT_INDEX == array_Dialogo_balao_Minigame_2.Length - 1) { state = FSMState.Boiando; desativarTUDO(); } } if (script_pensamentoController.tipo_resposta_Pesamento == "Resposta 3") { player_text_mental.text = array_Dialogo_mental_Minigame_3[Dialogo_mental__CURRENT_INDEX]; main_Sprite.sprite = sprites_Dialogo_mental_Minigame_3[Dialogo_mental__CURRENT_INDEX]; if (Dialogo_mental__CURRENT_INDEX == array_Dialogo_balao_Minigame_3.Length - 1) { state = FSMState.Boiando; desativarTUDO(); } } } }
public override void Enter(FSMState lastState) { }
protected void AddState( FSMState<T> state ) { m_states.Add( state.GetStateID(), state ); }
/// <summary> /// 启动状态机 /// </summary> /// <param name="fsmState"></param> public void StartFSM(FSMState fsmState) { currentState = fsmState; _currentActionID = fsmState.ID; }
public FSM(FSMState state) { current = state; current.Enter(); }
// Push State onto Stack public void Push(FSMState state) { stateStack.Push(state); }
public void AddTransition(FSMTransition transition, FSMState target) { links [transition] = target; }
public JumpAction(FSMState owner) : base(owner) { }
public override void Leave(FSMState nextState) { //base.Leave(nextState); }
public void Awake() { CurrentState = null; PreviousState = null; GlobalState = null; }
public RePlanState(FSMState next, Agent agent, Goal goal) : base(next) { _agent = agent; }
public IEnumerator NotOverrideTest() { FSMRoot <ETestRunenrEnum> fSMRoot = new FSMRoot <ETestRunenrEnum>(); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test1)); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test2)); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test3)); TestRunnerHelper.Reset(); TestRunnerHelper.testBoolean = false; fSMRoot.OnRunAction = () => { TestRunnerHelper.testBoolean = true; }; fSMRoot.OnUpdateAction = () => { TestRunnerHelper.testFloat += 1.0f; }; fSMRoot.OnStopAction = () => { TestRunnerHelper.testBoolean = false; }; FSMState <ETestRunenrEnum> fsmState = fSMRoot.GetState(ETestRunenrEnum.Test1); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 1; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt += 1; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.1f; }; fsmState = fSMRoot.GetState(ETestRunenrEnum.Test2); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 2; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt -= 2; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.2f; }; fsmState = fSMRoot.GetState(ETestRunenrEnum.Test3); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 3; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt += 3; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.3f; }; fSMRoot.Run(ETestRunenrEnum.Test1); Assert.AreEqual(true, TestRunnerHelper.testBoolean); Assert.AreEqual(1, TestRunnerHelper.testInt); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt > 30) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Transition(ETestRunenrEnum.Test2); break; } yield return(null); } Assert.AreEqual(2, TestRunnerHelper.testInt); Assert.AreEqual(0.1f, TestRunnerHelper.testFloat); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt < -60) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Transition(ETestRunenrEnum.Test3); break; } yield return(null); } Assert.AreEqual(3, TestRunnerHelper.testInt); Assert.AreEqual(0.2f, TestRunnerHelper.testFloat); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt > 90) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Stop(); break; } yield return(null); } Assert.AreEqual(0.3f, TestRunnerHelper.testFloat); Assert.AreEqual(false, TestRunnerHelper.testBoolean); yield return(null); }
public void Configure(T newOwner, FSMState <T> initialState, FSMState <T> initialGlobalState = null) { owner = newOwner; ChangeState(initialState); ChangeGlobalState(initialGlobalState); }
public void ChangeGlobalState(FSMState <T> newState) { globalState = newState; globalState?.Enter(owner); }
public void Awake() { currentState = null; globalState = null; }
public void start_conversa_Balao() { ativarBangs(); state = FSMState.Interagindo; }
public void Awake() { currentState = previousState = globalState = null; }
public override void DrawNodeInspectorGUI() { base.DrawNodeInspectorGUI(); this.ApplyFSM = (FSMState)UnityEditor.EditorGUILayout.EnumPopup("ApplyFSM", (System.Enum)ApplyFSM); }
public override void Leave(FSMState nextState) { GameLogicScript.CurrentMemeko.EnableInputLogic = false; //base.Leave(nextState); }