Beispiel #1
0
    void Start()
    {
        root = new BehaviorTree();

        sequence_1 = new Sequence();
        sequence_2 = new Sequence();
        selecter_1 = new Selecter();

        condition_Dead        = new Condition_Dead();
        condition_Fine        = new Condition_Find();
        condition_AttackRange = new Condition_AttackRange();
        condition_Arrive      = new Condition_Arrive();

        timeOut_RoamingDelay = new TimeDelay();

        roaming = new Action_Roaming();
        trace   = new Action_Trace();
        attack  = new Action_Attack();
        dead    = new Action_Dead();

        colliders = new Collider[5];

        //========== 공격 ===================
        condition_AttackRange.SetTask(attack);
        selecter_1.AddTask(condition_AttackRange);
        //===================================

        //========== 추적 ===================
        condition_Fine.SetTask(trace);
        selecter_1.AddTask(condition_Fine);
        //===================================

        //========== 로밍 ===================
        timeOut_RoamingDelay.SetTime(3.0f);
        sequence_2.AddTask(timeOut_RoamingDelay);
        sequence_2.AddTask(roaming);
        condition_Arrive.SetTask(sequence_2);
        selecter_1.AddTask(condition_Arrive);
        //==================================

        sequence_1.AddTask(selecter_1);
        condition_Dead.SetTask(dead);
        sequence_1.AddTask(condition_Dead);

        root.Init(sequence_1);

        enemyCharacter     = GetComponentInChildren <Animator>().gameObject;
        animatorController = GetComponentInChildren <Animator>();
        StartCoroutine(Update_Coroution());
    }