private void DoActions(FSMController fSMController, Action[] actions) { if (actions != null) { for (int i = 0; i < actions.Length; i++) { actions[i].Act(fSMController); } } }
private void CheckTranstions(FSMController fSMController) { for (int i = 0; i < transtions.Length; i++) { bool decision = transtions[i].decision.Decide(fSMController); if (decision) { fSMController.TransitionToState(transtions[i].trueState); } else { fSMController.TransitionToState(transtions[i].falseState); } } }
public override bool Decide(FSMController fSMController) { hits = Physics2D.CircleCastAll(fSMController.transform.position, fSMController.detectionRadius, Vector2.zero); if (hits != null) { for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.CompareTag("Player")) { fSMController.ChosenTarget = hits[i].transform; Debug.Log("Detected"); return(true); } } } return(false); }
public override void Act(FSMController fSMController) { Debug.Log("Chasing"); }
public void OnEnterState(FSMController fSMController) { DoActions(fSMController, onEnterActions); }
public void OnExitState(FSMController fSMController) { DoActions(fSMController, onExitActions); }
public void UpdateState(FSMController fSMController) { DoActions(fSMController, actions); CheckTranstions(fSMController); }
public override void Act(FSMController fSM) { //fSMController.animator.SetBool("detected", true); fSM.Material.color = Color.red; fSM.Current.stateColor = Color.red; }
public override void Act(FSMController fSMController) { //fSMController.animator.SetBool("detected", false); fSMController.Material.color = Color.green; fSMController.Current.stateColor = Color.green; }
public override bool Decide(FSMController fSM) { return(true); }
public abstract void Act(FSMController fSMController);
public abstract bool Decide(FSMController fSM);