예제 #1
0
 protected void buildBT(BehaviorTree btree, SecurityElement btNode)
 {
     UtilXml.getXmlAttrStr(btNode, "name", ref btree.m_name);
 }
예제 #2
0
 public void parseXml(BehaviorTree btree, SecurityElement btNode)
 {
     buildBT(btree, btNode);
     Stack<BehaviorComponent> stack = new Stack<BehaviorComponent>();
     depthTraverse(stack, btree.root, btNode);
 }
예제 #3
0
        override public void dispose()
        {
            if(m_btRes != null)
            {
                Ctx.m_instance.m_aiSystem.behaviorTreeMgr.unload(m_btRes.GetPath(), null);
                m_btRes = null;
            }

            if(m_bt != null)
            {
                m_bt = null;
            }

            Ctx.m_instance.m_aiSystem.aiControllerMgr.removeController(this);
        }
예제 #4
0
        public void syncUpdateBT()
        {
            if (m_bNeedReloadBT)
            {
                m_bt = Ctx.m_instance.m_aiSystem.behaviorTreeMgr.getBT(m_btID);
            }

            m_bNeedReloadBT = false;
        }
예제 #5
0
        public void parseXml(string xmlStr)
        {
            SecurityParser xmlDoc = new SecurityParser();
            xmlDoc.LoadXml(xmlStr);

            SecurityElement rootNode = xmlDoc.ToXml();
            ArrayList behaviorTemplateNode = rootNode.Children;
            ArrayList behaviorTreeXmlList = null;
            SecurityElement xmlElemTpl;
            SecurityElement xmlElemBT;
            BehaviorTree behaviorTree = null;
            string strId = "";
            BTID id = BTID.eNone;

            foreach (SecurityElement node in behaviorTemplateNode)  // 树列表,包括树和其它信息
            {
                xmlElemTpl = node;
                behaviorTreeXmlList = xmlElemTpl.Children;
                behaviorTree = new BehaviorTree(new BTRoot());

                UtilXml.getXmlAttrStr(node, "name", ref strId);
                id = m_btAttrSys.getBTIDByName(strId);
                m_id2BTDic[id] = behaviorTree;

                foreach (SecurityElement nodetree in behaviorTreeXmlList)
                {
                    xmlElemBT = nodetree;
                    m_BTFactory.parseXml(behaviorTree, xmlElemBT);
                }
            }
        }
예제 #6
0
        protected void initAi(BTID id)
        {
            //if (m_behaviorTree == null && m_skinAniModel.rootGo != null)
            {
                // 生成行为树
                BehaviorTree behaviorTree = Ctx.m_instance.m_aiSystem.behaviorTreeMgr.getBT(id) as BehaviorTree;
                m_behaviorTree = behaviorTree;
                // 生成 ai 控制器
                if (m_aiController == null)
                {
                    m_aiController = new AIController();
                    m_aiController.initControl(m_skinAniModel);
                }

                //m_aiController.vehicle.sceneGo = m_skinAniModel.rootGo;
                // 初始化 Steerings 参数信息
                initSteerings();
            }
        }