Beispiel #1
0
 public override void InnerSetup()
 {
     if (children[0] is BoolNode)
     {
         convertedBoolNode = children[0] as BoolNode;
     }
 }
Beispiel #2
0
        public override void InnerSetup()
        {
            if (children.Length != 3)
            {
                Debug.LogError("IfElseNode in " + Brain.name + " does not have exaclty 3 children!");
                return;
            }

            if (children[0] is BoolNode boolNode)
            {
                firstChild = boolNode;
            }
            else
            {
                Debug.LogError("First child in IfElseNode in " + Brain.name + " is not a BoolNode!");
                return;
            }
        }
Beispiel #3
0
        public override void InnerBeginn()
        {
            if (children.Length == 2)
            {
                if (displayedWarning == false && child1OnFailure == OnFailure.Restart && child2OnFailure == OnFailure.Restart)
                {
                    Debug.LogWarning("The node " + name + " on " + tree.AttachedBrain.name + " is configured to be in an endless loop");
                    displayedWarning = true;
                }

                if (children[0] is BoolNode)
                {
                    boolNode = children[0] as BoolNode;
                }

                children[1].Beginn(tree);
            }
        }
Beispiel #4
0
        public override void Update()
        {
            if (children.Length != 2)
            {
                Debug.LogError("Children length of Guard node does not equal 2. This node will always return failure");
                CurrentStatus = Status.Failure;
                return;
            }

            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                if (children[0] is BoolNode)
                {
                    BoolNode boolNode = children[0] as BoolNode;
                    boolNode.Restart();
                    boolNode.Beginn(tree);
                    if (boolNode.IsFulfilled() == false)
                    {
                        CurrentStatus = Status.Failure;
                        return;
                    }
                    else
                    {
                        timer = checkEverySeconds;
                    }
                }
                else // children[0] is not a boolNode
                {
                    switch (children[0].CurrentStatus)
                    {
                    case Status.Running:
                        children[0].Update();
                        break;

                    case Status.Success:
                        timer = checkEverySeconds;
                        children[0].Restart();
                        children[0].Beginn(tree);
                        break;

                    case Status.Failure:
                        CurrentStatus = Status.Failure;
                        return;
                    }
                }
            }

            switch (children[1].CurrentStatus)
            {
            case Status.Running:
                children[1].Update();
                break;

            case Status.Success:
                CurrentStatus = Status.Success;
                break;

            case Status.Failure:
                CurrentStatus = Status.Failure;
                break;
            }
        }