Example #1
0
 IEnumerator RunBehaviour()
 {
     BTNode.Result res = Root.Execute();
     while (true) // res == BTNode.Result.Running
     {
         res = Root.Execute();
         yield return(null);
     }
 }
 private void Update()
 {
     if (GetComponent <EnemyController>().CurrentHealth > 0)
     {
         _rootNode.Execute();
     }
 }
Example #3
0
 public override BTNodeStatus Execute()
 {
     if (currentNode == null)
     {
         currentNode = children[0];
         index       = 0;
     }
     if (currentNode.Execute() == BTNodeStatus.Suceesss)
     {
         index++;
         if (index >= children.Count)
         {
             return(BTNodeStatus.Suceesss);
         }
         else
         {
             currentNode = children[index];
             return(BTNodeStatus.Running);
         }
     }
     else
     {
         return(BTNodeStatus.Fail);
     }
 }
Example #4
0
    void Update()
    {
        root.Execute(this);

        if (Input.GetKeyDown(KeyCode.Z))
        {
            enemyHealth--;
        }
    }
Example #5
0
 public override BTStatus Execute() => root.Execute();
Example #6
0
 public void ExecuteBT()
 {
     BTRootNode.Execute();
 }
Example #7
0
 public void Run()
 {
     root.Execute();
 }