コード例 #1
0
 void Update()
 {
     if (_rootNode.Evaluate())
     {
         _rootNode.Tick();
     }
 }
コード例 #2
0
ファイル: EnemyAI.cs プロジェクト: PaiLv99/3DPortfolio
 private void Update()
 {
     rootNode.Evaluate();
     if (rootNode.NodeState == NodeState.Failure)
     {
         agent.isStopped = true;
         controller.Idle();
     }
 }
コード例 #3
0
 public override bool OnEvaluate()
 {
     if (_activeBtNode == null)
     {
         _activeBtNode = ChildNode[0];
         index         = 0;
     }
     return(_activeBtNode.Evaluate());
 }
コード例 #4
0
ファイル: BehaviourController.cs プロジェクト: jfez/IAp2
    public void PerformTurn_AI(int actionsPerTurn)
    {
        hasToMoveTroops    = true;
        hasToMoveExplorers = true;
        hasToMoveLabourers = true;

        for (int i = 0; i < actionsPerTurn; i++)
        {
            behaviourTree.Evaluate(this);
        }
    }
コード例 #5
0
 protected override bool OnEvaluate(BTInput _input)
 {
     if (CheckIndex(mCurrentSelectIndex))
     {
         BTNode node = mChildren[mCurrentSelectIndex];
         if (node.Evaluate(_input))
         {
             return(true);
         }
     }
     return(base.OnEvaluate(_input));
 }
コード例 #6
0
 protected override bool OnEvaluate(BTInput _input)
 {
     for (int i = 0; i < childCount; i++)
     {
         BTNode node = mChildren[i];
         if (node.Evaluate(_input))
         {
             mCurrentSelectIndex = i;
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
        protected override bool OnEvaluate(BTInput _input)
        {
            bool checkLoopCount = loopCount == INFINITELOOP || mCurrentCount < loopCount;

            if (!checkLoopCount)
            {
                return(false);
            }
            if (CheckIndex(0))
            {
                BTNode node = mChildren[0];
                if (node.Evaluate(_input))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #8
0
ファイル: BTTree.cs プロジェクト: cyulei/NewbieZone
    void Update()
    {
        if (!isRunning)
        {
            return;
        }

        if (database.GetData <bool>(RESET))
        {
            Reset();
            database.SetData <bool>(RESET, false);
        }

        // 对整个树从根节点开始检查和运行
        if (root.Evaluate())
        {
            root.Tick();
        }
    }
コード例 #9
0
ファイル: BTInverseDecoractor.cs プロジェクト: Akirame/IA-RTS
    public override NodeStates Evaluate()
    {
        switch (childNode.Evaluate())
        {
        case NodeStates.Fail:
            nodeState = NodeStates.Success;
            return(nodeState);

        case NodeStates.Success:
            nodeState = NodeStates.Fail;
            return(nodeState);

        case NodeStates.Running:
            nodeState = NodeStates.Running;
            return(nodeState);
        }
        nodeState = NodeStates.Success;
        return(nodeState);
    }
コード例 #10
0
ファイル: BTTree.cs プロジェクト: yiyuan1130/BT-Framework
    void Update()
    {
        if (!isRunning)
        {
            return;
        }

        if (database.GetData <bool>(RESET))
        {
            Reset();
            database.SetData <bool>(RESET, false);
        }

        // Iterate the BT tree now!
        if (_root.Evaluate())
        {
            _root.Tick();
        }
    }
コード例 #11
0
ファイル: Inverter.cs プロジェクト: cgnerds/UnityAI
    // Reports a success if the child fails and a failure if the child succeeds.
    // Running will report as running.
    public override NodeStates Evaluate()
    {
        switch (m_node.Evaluate())
        {
        case NodeStates.FAILURE:
            m_nodeState = NodeStates.SUCCESS;
            return(m_nodeState);

        case NodeStates.SUCCESS:
            m_nodeState = NodeStates.FAILURE;
            return(m_nodeState);

        case NodeStates.RUNNING:
            m_nodeState = NodeStates.RUNNING;
            return(m_nodeState);
        }

        m_nodeState = NodeStates.SUCCESS;
        return(m_nodeState);
    }
コード例 #12
0
ファイル: BTSequence.cs プロジェクト: cyulei/NewbieZone
 protected override bool DoEvaluate()
 {
     if (activeChild != null)
     {
         bool result = activeChild.Evaluate();
         // 节点之间与关系 一个不能执行则后面不执行
         if (!result)
         {
             activeChild.Clear();
             activeChild = null;
             activeIndex = -1;
         }
         return(result);
     }
     else
     {
         //Debug.Log(children[0]);
         return(children[0].Evaluate());
     }
 }
コード例 #13
0
        protected override bool OnEvaluate(BTInput _input)
        {
            int i;

            if (mCurrentIndex == INVALID_CHILD_NODE_INDEX)
            {
                i = 0;
            }
            else
            {
                i = mCurrentIndex;
            }
            if (CheckIndex(i))
            {
                BTNode node = mChildren[i];
                if (node.Evaluate(_input))
                {
                    return(true);
                }
            }
            return(false);
        }