Пример #1
0
        // VIRTUAL METHODS: -----------------------------------------------------------------------

        public override Node.Return Execute(Node node, GameObject invoker, Behavior behavior)
        {
            int instanceID = node.GetInstanceID();
            int passCount  = behavior.GetPassCount(instanceID);

            if (this.count <= 0 || passCount < this.count)
            {
                Node.Return result = base.Execute(node, invoker, behavior);

                if (result == Node.Return.Success || result == Node.Return.Fail)
                {
                    behavior.SetPassCount(instanceID, passCount + 1);
                    node.ResetOutputStates(invoker, behavior, true);
                }

                return(Node.Return.Running);
            }

            return(Node.Return.Success);
        }
Пример #2
0
        // VIRTUAL METHODS: -----------------------------------------------------------------------

        public override Node.Return Execute(Node node, GameObject invoker, Behavior behavior)
        {
            int instanceID = node.GetInstanceID();

            int passCount = behavior.GetPassCount(instanceID);

            if (passCount > 0)
            {
                return(behavior.GetState(instanceID));
            }

            Node.Return result = base.Execute(node, invoker, behavior);

            switch (result)
            {
            case Node.Return.Fail:
            case Node.Return.Success:
                behavior.SetPassCount(instanceID, passCount + 1);
                return(result);
            }

            return(Node.Return.Running);
        }