Ejemplo n.º 1
0
        static public TBTAction GetBehaviorTreeAction()
        {
            if (_bevTreeAct != null)
            {
                return(_bevTreeAct);
            }
            _bevTreeAct = new TBTActionPrioritizedSelector();
//			_bevTreeAct.AddChild(new TBTActionSequence()
//                    .SetPrecondition(new TBTPreconditionNOT(new CON_HasReachedTarget()))
//                    .AddChild(new NOD_TurnTo())
//                    .AddChild(new NOD_MoveTo()))
//                .AddChild(new NOD_Attack());

            TBTActionSequence actionSequence = new TBTActionSequence();

            _bevTreeAct.AddChild(actionSequence);

            CON_HasReachedTarget hasReachedTarget = new CON_HasReachedTarget();
            TBTPreconditionNOT   preconditionNOT  = new TBTPreconditionNOT(hasReachedTarget);

            actionSequence.SetPrecondition(preconditionNOT);


            NOD_TurnTo turnTo   = new NOD_TurnTo();
            NOD_MoveTo moveTo   = new NOD_MoveTo();
            NOD_Attack attackTo = new NOD_Attack();

            actionSequence.AddChild(turnTo);
            actionSequence.AddChild(moveTo);
            actionSequence.AddChild(attackTo);



            return(_bevTreeAct);
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            _behaviorWorkingData = new AIEntityWorkingData();
            _behaviorWorkingData.entityAnimator = GetComponent <Animator>();
            _behaviorWorkingData.entityTF       = transform;

            _behaviorTree = new TBTActionPrioritizedSelector();
            _behaviorTree
            .AddChild(new TBTActionSequence()
                      .SetPrecondition(new TBTPreconditionNOT(new HasReachedTarget()))
                      .AddChild(new TurnToAction())
                      .AddChild(new MoveToAction()))
            .AddChild(new TBTActionParallel()
                      .AddChild(new TurnToAction())
                      .AddChild(new AttackAction()));
        }
Ejemplo n.º 3
0
        private void Awake()
        {
            _behaviorWorkingData = new AIEntityWorkingData();
            _behaviorWorkingData.entityAnimation = GetComponent <Animation>();
            _behaviorWorkingData.entityTF        = transform;

            _behaviorTree = new TBTActionPrioritizedSelector();
            _behaviorTree
            .AddChild(new TBTActionSequence()
                      .SetPrecondition(new TBTPreconditionNOT(new HasReachEnemy()))
                      .AddChild(new LookEnemyAction())
                      .AddChild(new IdleAction()))
            .AddChild(new TBTActionParallel()
                      .AddChild(new LookEnemyAction())
                      .AddChild(new AttackAction()));
        }
Ejemplo n.º 4
0
 static public TBTAction GetBehaviorTreeDemo1()
 {
     if (_bevTreeDemo1 != null)
     {
         return(_bevTreeDemo1);
     }
     _bevTreeDemo1 = new TBTActionPrioritizedSelector();
     _bevTreeDemo1
     .AddChild(new TBTActionSequence()
               .SetPrecondition(new TBTPreconditionNOT(new CON_HasReachedTarget()))
               .AddChild(new NOD_TurnTo())
               .AddChild(new NOD_MoveTo()))
     .AddChild(new TBTActionSequence()
               .AddChild(new NOD_TurnTo())
               .AddChild(new NOD_Attack()));
     return(_bevTreeDemo1);
 }
Ejemplo n.º 5
0
        public void CreateNewDynamicGuideRoot(TBTWorkingData wData)
        {
            if (m_GuideDynamicRoot == null)
            {
                GuideWorkingData data = wData as GuideWorkingData;
                if (data != null && data.GuideDynamicBB != null)
                {
                    int GuideStateID = data.GuideStateBB.GetValue <int>(EGuideStateBBKey.GuideStateID, -1);
                    SSchemeGuideStateData stateData = GetGuideStateData(GuideStateID);
                    if (stateData != null)
                    {
                        m_GuideDynamicRoot = CreateDynamicRoot(stateData.GuideRootType);


                        for (int j = 0; j < stateData.GuideNodeIDList.Count; ++j)
                        {
                            EGuideNodeID         guideNodeID   = (EGuideNodeID)stateData.GuideNodeIDList[j];
                            SSchemeGuideNodeData guideNodeData = null;
                            if (dicGuideConfigTable.TryGetValue(guideNodeID, out guideNodeData))
                            {
                                //先根据引导节点需要挂接的父节点类型处理
                                EGuideActionLayerType layerType       = (EGuideActionLayerType)guideNodeData.nGuideActionLayerType;
                                TBTAction             layerTypeAction = null;
                                if (!m_GuideDynamicRoot.TryGetLayerTypeAction(layerType, out layerTypeAction))
                                {
                                    layerTypeAction = CreateLayerTypeAction(layerType);
                                    m_GuideDynamicRoot.AddChild(layerTypeAction);
                                }

                                layerTypeAction.AddChild(getNodeDataInstance(guideNodeID));
                            }
                            else
                            {
                                Trace.LogWarning("没有引导ID为:" + guideNodeID + " 的引导数据,配错了?");
                            }
                        }
                    }
                }
            }
        }