Example #1
0
    public ExecutionResult IfChaseGotKid(BehaviourTreeInstance instance)
    {
        if (instance.HasToStart())
        {
            Debug.Log("running after kid");

            instance.WaitUntil(() =>
            {
                // Here we are using Unity's implementation of asynchronous calls.
                // You will have to use a different one in different contexts.
                StartCoroutine(Chasing(instance));
            });
        }
        else if (instance.HasToComplete())
        {
            bool b = Random.Range(0f, 1f) > 0.49;
            Debug.Log(instance.Actor.Name() + ": " + " got child: " + b);
            return(new ExecutionResult(b));
        }
        else
        {
            Debug.Log("running after kid doing nothing");
        }

        return(new ExecutionResult(true));
    }
Example #2
0
    public ExecutionResult ActionBringChildToStation(BehaviourTreeInstance instance)
    {
        if (instance.HasToStart())
        {
            Debug.Log(instance.Actor.Name() + ": " + "Bring child to station");

            instance.WaitUntil(() =>
            {
                // Here we are using Unity's implementation of asynchronous calls.
                // You will have to use a different one in different contexts.
                StartCoroutine(DoNap(instance, () =>
                {
                    Debug.Log("Completed: child in station");
                    totalKidsWondering--;
                }));
            });
        }
        return(new ExecutionResult(true));
    }
Example #3
0
 public ExecutionResult IfChaseGotKidCases(BehaviourTreeInstance instance)
 {
     if (instance.HasToStart())
     {
         Debug.Log("running after kid");
         instance.WaitUntil(() =>
         {
             StartCoroutine(DoNap(instance));
         });
     }
     else if (instance.HasToComplete())
     {
         var random = Random.Range(0f, 1f);
         var b      = random > 0.6 ? 2 : (random > 0.3 ? 1 : 0);
         Debug.Log(instance.Actor.Name() + ": " + " got child: " + b);
         return(new ExecutionResult(b));
     }
     else
     {
         Debug.Log("running after kid doing nothing");
     }
     return(new ExecutionResult(true));
 }