Exemple #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);
        }
    // 更新行为树
    public int UpdateBehavior(float gameTime, float deltaTime)
    {
        if (m_BehaviorTree == null)
        {
            return(1);
        }

        AIBehaviorRequest currentRequest = m_BehaviorWorkData.request;

        if (currentRequest == null)
        {
            return(1);
        }

        //if(currentRequest.isRequestCompleted)
        //    return 1;

        m_BehaviorWorkData.gameTime  = gameTime;
        m_BehaviorWorkData.deltaTime = deltaTime;

        if (m_BehaviorTree.Evaluate(m_BehaviorWorkData))
        {
            m_BehaviorTree.Update(m_BehaviorWorkData);
        }

        return(0);
    }
Exemple #3
0
        public int UpdateBehavior(float gameTime, float deltaTime)
        {
            if (_currentRequest == null)
            {
                return(0);
            }

            if (_targetDummyObject == null)
            {
                return(0);
            }

            //update working data
            if (null != _behaviorWorkingData.entityAnimator)
            {
                _behaviorWorkingData.entityAnimator.speed = AITimer.instance.timeScale;
            }

            _behaviorWorkingData.gameTime  = gameTime;
            _behaviorWorkingData.deltaTime = deltaTime;

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

            if (_behaviorTree.Evaluate(_behaviorWorkingData))
            {
                _behaviorTree.Update(_behaviorWorkingData);
            }
            else
            {
                _behaviorTree.Transition(_behaviorWorkingData);
            }
            return(0);
        }
Exemple #4
0
 private void Update()
 {
     if (_behaviorTree.Evaluate(_behaviorWorkingData))
     {
         _behaviorTree.Update(_behaviorWorkingData);
     }
     else
     {
         _behaviorTree.Transition(_behaviorWorkingData);
     }
 }
    // 更新决策树
    public int UpdateDecision(float gameTime, float deltaTime)
    {
        if (m_DecisionTree == null)
        {
            return(1);
        }

        if (m_DecisionTree.Evaluate(m_DecisionWorkData))
        {
            m_DecisionTree.Update(m_DecisionWorkData);
        }

        return(0);
    }
Exemple #6
0
    //public override void AddBody(bool isStrong = false)
    //{

    //}

    public int UpdateBehavior(float gameTime, float deltaTime)
    {
        _BevWorkingData._GameTime  = gameTime;
        _BevWorkingData._DeltaTime = deltaTime;
        if (_BevTree.Evaluate(_BevWorkingData))
        {
            _BevTree.Update(_BevWorkingData);
        }
        else
        {
            _BevTree.Transition(_BevWorkingData);
        }
        return(0);
    }
Exemple #7
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);
        }