// Use this for initialization void Start() { // initialize the agent /*for(int i = 0; i < transform.childCount; i++) { agents.Add(transform.GetChild(i).GetComponent<Member>()); }*/ uniqueAgent = transform.GetChild(0).GetComponent<Member>(); // State machine for member statePatrol = new StateMachine(); Idle monIdle = new Idle(uniqueAgent); Search monWalk = new Search(uniqueAgent); Chase monFire = new Chase(uniqueAgent); //from Idle to... Transition transitionIdle = new Transition(uniqueAgent.changeToWalk, monWalk); Transition transitionWalk = new Transition(uniqueAgent.canShoot, monFire); Transition transitionFire = new Transition(uniqueAgent.changeToIdle, monIdle); monIdle.addTransition(transitionIdle); monWalk.addTransition(transitionWalk); monFire.addTransition(transitionFire); statePatrol.currentState = monIdle; // State machine for team stateTactic = new StateMachine(); Regroup regroup = new Regroup(this); Reform reform = new Reform(this); StateMachineWrapper stateWrapper = new StateMachineWrapper(statePatrol); Transition transitionRegroup = new Transition(checkNeedToReform, reform); Transition transitionReform = new Transition(() => { return doTransitionToPatrol; }, stateWrapper); Transition transitionPatrol = new Transition(() => { return doTransitionToRegroup; }, regroup); regroup.addTransition(transitionRegroup); reform.addTransition(transitionReform); stateWrapper.addTransition(transitionPatrol); stateTactic.currentState = regroup; }
public void addTransition(Transition p_transmission) { transition.Add(p_transmission); }