Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }