Ejemplo n.º 1
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            TBTActionPrioritizedSelectorContext thisContext = getContext <TBTActionPrioritizedSelectorContext>(wData);
            int runningState = TBTRunningStatus.FINISHED;

            if (thisContext.currentSelectedIndex != thisContext.lastSelectedIndex)
            {
                if (IsIndexValid(thisContext.lastSelectedIndex))
                {
                    TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex);
                    node.Transition(wData);
                }
                thisContext.lastSelectedIndex = thisContext.currentSelectedIndex;
            }
            if (IsIndexValid(thisContext.lastSelectedIndex))
            {
                TBTAction node = GetChild <TBTAction>(thisContext.lastSelectedIndex);
                runningState = node.Update(wData);
                if (TBTRunningStatus.IsFinished(runningState))
                {
                    node.Transition(wData);
                    thisContext.lastSelectedIndex = -1;
                }
            }
            return(runningState);
        }
Ejemplo n.º 2
0
        protected sealed override int onUpdate(TBTWorkingData wData)
        {
            int runningState = TBTRunningStatus.FINISHED;
            TBTActionLeafContext thisContext = getContext <TBTActionLeafContext>(wData);

            if (thisContext.status == ACTION_READY)
            {
                onEnter(wData);
                thisContext.needExit = true;//默认有onExit
                thisContext.status   = ACTION_RUNNING;
            }
            // 从onExecute返回是否结束
            if (thisContext.status == ACTION_RUNNING)
            {
                runningState = onExecute(wData);
                // 如果结束了,切换状态到结束状态
                if (TBTRunningStatus.IsFinished(runningState))
                {
                    thisContext.status = ACTION_FINISHED;
                }
            }

            if (thisContext.status == ACTION_FINISHED)
            {
                if (thisContext.needExit)
                {
                    onExit(wData, runningState);
                }
                thisContext.status   = ACTION_READY;
                thisContext.needExit = false;
            }
            return(runningState);
        }
Ejemplo n.º 3
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            var thisContext  = getContext <TBTActionPrioritizedSelectorContext>(wData);
            int runningState = TBTRunningStatus.FINISHED;

            //action没执行完毕,前提就变了,所以这边需要进行节点的转换来清除上个节点的状态
            if (thisContext.currentSelectedIndex != thisContext.lastSelectedIndex)
            {
                if (IsIndexValid(thisContext.lastSelectedIndex))
                {
                    var node = GetChild <TBTAction>(thisContext.lastSelectedIndex);
                    node.Transition(wData);
                }
                thisContext.lastSelectedIndex = thisContext.currentSelectedIndex;
            }
            // Update
            if (IsIndexValid(thisContext.lastSelectedIndex))
            {
                var node = GetChild <TBTAction>(thisContext.lastSelectedIndex);
                runningState = node.Update(wData);
                //action执行完毕,那么下一次tick不需要进行节点转换
                if (TBTRunningStatus.IsFinished(runningState))
                {
                    thisContext.lastSelectedIndex = -1;
                }
            }
            return(runningState);
        }
Ejemplo n.º 4
0
 public override bool IsTrue(TBTWorkingData wData)
 {
     if (CustomPrecondition(wData) && TBTRunningStatus.IsExecuting(m_nRunningState))
     {
         m_nRunningState = TBTRunningStatus.FINISHED;
     }
     return(TBTRunningStatus.IsFinished(m_nRunningState));
 }
Ejemplo n.º 5
0
        protected override int onUpdate(TBTWorkingData wData)
        {
            GuideRoot_01Context thisContext = getContext <GuideRoot_01Context>(wData);
            int       runningStatus         = TBTRunningStatus.FINISHED;
            TBTAction node = GetChild <TBTAction>(thisContext.currentSelectedIndex);

            runningStatus = node.Update(wData);
            if (_continueIfErrorOccors == false && TBTRunningStatus.IsError(runningStatus))
            {
                thisContext.currentSelectedIndex = -1;
                return(runningStatus);
            }

            return(runningStatus);
        }
Ejemplo n.º 6
0
        protected override bool CustomPrecondition(TBTWorkingData wData)
        {
            bool result = false;

            if (EntityFactory.MainHeroView != null && EntityFactory.MainHeroView.Property != null && EntityFactory.MainHeroView.Property)
            {
                result = EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_TALENT_POINT) >= m_nValueStandard;
            }
            //
            if (result && TBTRunningStatus.IsFinished(m_nRunningState))
            {
                TimerManager.SetTimer(this, 0, 60, 1);
            }
            TLogger.PROFILE("判断玩家战场内金钱数量是否达到" + m_nValueStandard + ":" + result);

            return(result);
        }
Ejemplo n.º 7
0
        protected override int onExecute(TBTWorkingData wData)
        {
            GuideWorkingData gData = wData as GuideWorkingData;

            int result = base.onExecute(wData);

            result = ShowWidget(gData);

            if (TBTRunningStatus.IsFinished(result))
            {
                result = m_bClickWidgetFinished ? TBTRunningStatus.USER_EXECUTING : result;
                UGuideWidget widget = GuideManager.Instance.GetGuideWidget(gData.GuideCurrentNode, m_nStepID);
                if (widget != null && widget.IsWidgetClick())
                {
                    result = TBTRunningStatus.FINISHED;
                }
            }

            return(result);
        }