// Use this for initialization void Start() { BaseStart(); km = GetComponent <KnightMotor>(); // last behaviour currentBehaviour = new WaitBehaviour(km); nextActionBehaviour = null; SelectTarget(); }
private void ComputeNextActionAndTransitionBehaviours() { // If current behaviour is a transition behaviour, start action behaviour if (currentBehaviour != nextActionBehaviour && nextActionBehaviour != null) { SetBehaviour(nextActionBehaviour); } // Else compute the next action behaviour else { // Change mode if needed ChangeMode(); // Find target SelectTarget(); // if no target, do nothing (TODO: improve it and make it passive after several tries) if (target == null) { nextActionBehaviour = new WaitBehaviour(km); SetBehaviour(new WaitBehaviour(km)); } else { // Create the list of possible behaviours, depending on the situation Dictionary <EnemyBehaviour, float> dic = ActionBehaviourList(); // Determine next action behaviour from list nextActionBehaviour = SelectBehaviourFromDictionary(dic); // Create the list of possible behaviours, depending on the situation dic = TransistionBehaviourList(); // Determine next transition behaviour from list and start it EnemyBehaviour transitionBehaviour = SelectBehaviourFromDictionary(dic); SetBehaviour(transitionBehaviour); } } }