Пример #1
0
        protected override NodeResult OnUpdate()
        {
            var currentChild       = GetChildNodes()[CurrentChildIndex];
            var currentChildResult = CurrentController.CheckNodeStatus(currentChild);

            if (currentChildResult != NodeResult.Running)
            {
                if (currentChildResult == NodeResult.Failrue)
                {
                    CurrentChildIndex = 0;
                    return(NodeResult.Failrue);
                }
                if (currentChildResult == NodeResult.Suspended)
                {
                    SwitchToNode(ChildNodes[CurrentChildIndex]);
                    return(NodeResult.Running);
                }
                else
                {
                    CurrentChildIndex++;

                    if (CurrentChildIndex == ChildNodes.Count)
                    {
                        CurrentChildIndex = 0;
                        return(NodeResult.Success);
                    }

                    SwitchToNode(ChildNodes[CurrentChildIndex]);
                }
            }

            return(NodeResult.Running);
        }
Пример #2
0
        protected override NodeResult OnUpdate()
        {
            var childResult = CurrentController.CheckNodeStatus(DecoratedNode);

            if (childResult != NodeResult.Running)
            {
                if (childResult == NodeResult.Success)
                {
                    return(NodeResult.Failrue);
                }
                else if (childResult == NodeResult.Failrue)
                {
                    return(NodeResult.Success);
                }
            }

            return(NodeResult.Running);
        }