public void ChangeState(WorkerStateTrigger trigger) { TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState); currentState = transition.Destination; Output(transition.Output); }
public TransitionBundle ChangeState(WorkerStateTrigger trigger, WorkerState currentState) { foreach (TransitionBundle bundle in workerTransitionsDic[trigger]) { if (bundle.Source == currentState) { return(bundle); } } return(new TransitionBundle(currentState, currentState)); }
private void OnTriggerEnter(Collider other) { WorkerStateTrigger trigger = workerStateScripts[currentState].Collide(other, ref health); if (trigger != WorkerStateTrigger.Null) { TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState); currentState = transition.Destination; Output(transition.Output, other); } }
void LoseHealth() { DestructableObstacleCollision other = Instantiate(testSample); WorkerStateTrigger trigger = workerStateScripts[currentState].Collide(other.GetComponent <Collider>(), ref health); if (trigger != WorkerStateTrigger.Null) { TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState); currentState = transition.Destination; Output(transition.Output); } }
/// <summary> /// Gets the output of the state, from states that can transfer to another /// without external input to the FSM /// </summary> /// <returns></returns> public WorkerStateTrigger InputTrigger() { foreach (IWChangeState stateScript in changeStateScripts) { WorkerStateTrigger inputTrigger = stateScript.InputTrigger(); if (inputTrigger != WorkerStateTrigger.Null) { return(inputTrigger); } } return(WorkerStateTrigger.Null); }
private void Update() { //healthText.text = health.ToString(); // Check if there is an output trigger from current state WorkerStateTrigger trigger = workerStateScripts[currentState].InputTrigger(); if (trigger != WorkerStateTrigger.Null) { TransitionBundle transition = workerStateTransition.ChangeState(trigger, currentState); currentState = transition.Destination; Output(transition.Output); } }