Esempio n. 1
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            TBTActionSequenceContext thisContext = getContext <TBTActionSequenceContext>(wData);
            int runningStatus = TBTRunningStatus.FINISHED;

            if (IsIndexValid(thisContext.currentSelectedIndex))
            {
                TBTAction node = GetChild <TBTAction>(thisContext.currentSelectedIndex);
                runningStatus = node.Update(wData);
                if (_continueIfErrorOccurs == false && TBTRunningStatus.IsError(runningStatus))
                {
                    thisContext.currentSelectedIndex = -1;
                    return(runningStatus);
                }
            }
            if (TBTRunningStatus.IsFinished(runningStatus))
            {
                thisContext.currentSelectedIndex++;
                if (IsIndexValid(thisContext.currentSelectedIndex))
                {
                    runningStatus = TBTRunningStatus.EXECUTING;
                }
                else
                {
                    thisContext.currentSelectedIndex = -1;
                }
            }
            return(runningStatus);
        }
        protected override int onUpdate(TBTWorkingData wData)
        {
            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);
            int runningStatus = TBTRunningStatus.FINISHED;

            if (thisContext.lastSelectedIndex != thisContext.currentSelectedIndex)
            {
                if (IsIndexValid(thisContext.lastSelectedIndex))
                {
                    TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex);
                    node.Transition(wData);
                }
                thisContext.lastSelectedIndex = thisContext.currentSelectedIndex;
            }
            if (IsIndexValid(thisContext.currentSelectedIndex))
            {
                TBTAction node = GetChild <TBTAction>(thisContext.currentSelectedIndex);
                runningStatus = node.Update(wData);
                if (TBTRunningStatus.IsFinished(runningStatus))
                {
                    thisContext.lastSelectedIndex = -1;
                }
            }
            return(runningStatus);
        }
Esempio n. 3
0
        protected override void onTransition(TBTWorkingData wData)
        {
            TBTActionSequenceContext thisContext = getContext <TBTActionSequenceContext>(wData);
            TBTAction node = GetChild <TBTAction>(thisContext.currentSelectedIndex);

            if (node != null)
            {
                node.Transition(wData);
            }
        }
Esempio n. 4
0
        protected override void onTransition(TBTWorkingData wData)
        {
            TBTActionParellelContext thisContext = getContext <TBTActionParellelContext>(wData);

            for (int i = 0; i < GetChildCount(); i++)
            {
                TBTAction node = GetChild <TBTAction>(i);
                node.Transition(wData);
            }
            initListTo <int>(thisContext.runningStatus, TBTRunningStatus.EXECUTING);
        }
        protected override void onTransition(TBTWorkingData wData)
        {
            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);
            TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex);

            if (node != null)
            {
                node.Transition(wData);
            }
            thisContext.lastSelectedIndex = -1;
        }
Esempio n. 6
0
        protected override void onTransition(TBTWorkingData wData)
        {
            TBTActionLoopContext thisContext = getContext <TBTActionLoopContext>(wData);

            if (IsIndexValid(0))
            {
                TBTAction node = GetChild <TBTAction>(0);
                node.Transition(wData);
            }
            thisContext.currentCount = 0;
        }
Esempio n. 7
0
        protected override bool onEvaluate(TBTWorkingData wData)
        {
            TBTActionSequenceContext thisContext = getContext <TBTActionSequenceContext>(wData);
            int checkNodeIndex = IsIndexValid(thisContext.currentSelectedIndex) ? thisContext.currentSelectedIndex : 0;

            if (IsIndexValid(checkNodeIndex))
            {
                TBTAction node = GetChild <TBTAction>(checkNodeIndex);
                if (node.Evaluate(wData))
                {
                    thisContext.currentSelectedIndex = checkNodeIndex;
                    return(true);
                }
            }
            return(false);
        }
        protected override bool onEvaluate(TBTWorkingData wData)
        {
            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);

            thisContext.currentSelectedIndex = -1;
            for (int i = 0; i < GetChildCount(); i++)
            {
                TBTAction node = GetChild <TBTAction>(i);
                if (node.Evaluate(wData))
                {
                    thisContext.currentSelectedIndex = i;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 9
0
        protected override bool onEvaluate(TBTWorkingData wData)
        {
            TBTActionLoopContext thisContext = getContext <TBTActionLoopContext>(wData);
            bool checkLoopCount = loopCount == INIFITY || thisContext.currentCount < loopCount;

            if (!checkLoopCount)
            {
                return(false);
            }
            if (IsIndexValid(0))
            {
                TBTAction node = GetChild <TBTAction>(0);
                return(node.Evaluate(wData));
            }
            return(false);
        }
Esempio n. 10
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            TBTActionParellelContext thisContext = getContext <TBTActionParellelContext>(wData);

            if (thisContext.runningStatus.Count != GetChildCount())
            {
                initListTo <int>(thisContext.runningStatus, TBTRunningStatus.EXECUTING);
            }
            bool hasFinished  = false;
            bool hasExecuting = false;

            for (int i = 0; i < GetChildCount(); i++)
            {
                if (thisContext.evaluationStatus[i] == false)
                {
                    continue;
                }
                if (TBTRunningStatus.IsFinished(thisContext.runningStatus[i]))
                {
                    hasFinished = true;
                    continue;
                }

                TBTAction node          = GetChild <TBTAction>(i);
                int       runningStatus = node.Update(wData);
                if (TBTRunningStatus.IsFinished(runningStatus))
                {
                    hasFinished = true;
                }
                else
                {
                    hasExecuting = true;
                }
                thisContext.runningStatus[i] = runningStatus;
            }
            if (_runningStatusRelationShip == ECHILDREN_RELATIONSHIP.OR && hasFinished || _runningStatusRelationShip == ECHILDREN_RELATIONSHIP.AND && hasExecuting == false)
            {
                initListTo <int>(thisContext.runningStatus, TBTRunningStatus.EXECUTING);
                return(TBTRunningStatus.FINISHED);
            }
            return(TBTRunningStatus.EXECUTING);
        }
Esempio n. 11
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            TBTActionLoopContext thisContext = getContext <TBTActionLoopContext>(wData);
            int runningStatus = TBTRunningStatus.FINISHED;

            if (IsIndexValid(0))
            {
                TBTAction node = GetChild <TBTAction>(0);
                runningStatus = node.Update(wData);
                if (TBTRunningStatus.IsFinished(runningStatus))
                {
                    thisContext.currentCount++;
                    if (loopCount == INIFITY || thisContext.currentCount < loopCount)
                    {
                        runningStatus = TBTRunningStatus.EXECUTING;
                    }
                }
            }
            return(runningStatus);
        }
Esempio n. 12
0
        protected override bool onEvaluate(TBTWorkingData wData)
        {
            TBTActionParellelContext thisContext = getContext <TBTActionParellelContext>(wData);

            initListTo <bool>(thisContext.evaluationStatus, false);
            bool finalResult = false;

            for (int i = 0; i < GetChildCount(); i++)
            {
                TBTAction node = GetChild <TBTAction>(i);
                bool      ret  = node.Evaluate(wData);
                if (_evaluationRelationShip == ECHILDREN_RELATIONSHIP.AND && ret == false)
                {
                    finalResult = false;
                    break;
                }
                if (ret)
                {
                    finalResult = true;
                }
                thisContext.evaluationStatus[i] = ret;
            }
            return(finalResult);
        }