Example #1
0
        protected override bool onEvaluate(/*in*/ TBTWorkingData wData)
        {
            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);

            thisContext.currentSelectedIndex = -1;
            int childCount = GetChildCount();

            for (int i = 0; i < childCount; ++i)
            {
                TBTAction node = GetChild <TBTAction>(i);
                if (node.Evaluate(wData))
                {
                    thisContext.currentSelectedIndex = i;
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        protected override bool onEvaluate(/*in*/ TBTWorkingData wData)
        {
            GuideWorkingData gWData      = wData as GuideWorkingData;
            EStage_State     tmpCurState = EStage_State.ESS_NONE;
            int tmpNoviceID = -1;

            if (gWData != null)
            {
                tmpCurState = gWData.GuideStateBB.GetValue <EStage_State>(EGuideStateBBKey.GameStageState, EStage_State.ESS_NONE);
                tmpNoviceID = gWData.GuideStateBB.GetValue <int>(EGuideStateBBKey.PlayerNoviceGuideType, -1);
            }

            if (m_eOldStage != EStage_State.ESS_NONE && m_eOldStage != tmpCurState)
            {
                GuideManager.Instance.DestroyOldDynamicGuideRoot(wData);
            }
            else if (m_eOldStage != EStage_State.ESS_NONE && m_eOldStage == tmpCurState)
            {
                if (tmpNoviceID != -1 && tmpNoviceID != m_nNoviceID)
                {
                    GuideManager.Instance.DestroyOldDynamicGuideRoot(wData);
                }
            }
            m_eOldStage = tmpCurState;
            m_nNoviceID = tmpNoviceID;


            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);

            thisContext.currentSelectedIndex = -1;
            int childCount = GetChildCount();

            for (int i = 0; i < childCount; ++i)
            {
                TBTAction node = GetChild <TBTAction>(i);
                if (node.Evaluate(wData))
                {
                    thisContext.currentSelectedIndex = i;
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        public int UpdateBehavior(float gameTime, float deltaTime)
        {
            if (_currentRequest == null)
            {
                return(0);
            }
            //update working data
            _behaviorWorkingData.entityAnimator.speed = GameTimer.Instance.timeScale;
            _behaviorWorkingData.gameTime             = gameTime;
            _behaviorWorkingData.deltaTime            = deltaTime;

            //test bb usage
            _blackboard.SetValue(BBKEY_NEXTMOVINGPOSITION, _currentRequest.nextMovingTarget);

            if (_behaviorTree.Evaluate(_behaviorWorkingData))
            {
                _behaviorTree.Update(_behaviorWorkingData);
            }
            else
            {
                _behaviorTree.Transition(_behaviorWorkingData);
            }
            return(0);
        }