コード例 #1
0
ファイル: GuideStructure.cs プロジェクト: zwong91/Titan
        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);
        }
コード例 #2
0
    // 更新行为树
    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);
    }
コード例 #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);
        }
コード例 #4
0
 private void Update()
 {
     if (_behaviorTree.Evaluate(_behaviorWorkingData))
     {
         _behaviorTree.Update(_behaviorWorkingData);
     }
     else
     {
         _behaviorTree.Transition(_behaviorWorkingData);
     }
 }
コード例 #5
0
    // 更新决策树
    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);
    }
コード例 #6
0
ファイル: Enemy.cs プロジェクト: mengtest/Snake-3
    //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);
    }
コード例 #7
0
ファイル: GuideStructure.cs プロジェクト: zwong91/Titan
        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);
        }