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); } } }
// 异步加载 public void loadBT(BTID id) { LoadParam param = Ctx.m_instance.m_poolSys.newObject<LoadParam>(); LocalFileSys.modifyLoadParam(m_btAttrSys.m_id2ItemDic[id].m_path, param); param.m_loadNeedCoroutine = false; param.m_resNeedCoroutine = false; load<BehaviorTreeRes>(param); Ctx.m_instance.m_poolSys.deleteObj(param); }
public BehaviorTree getBT(BTID id) { if (!m_id2BTDic.ContainsKey(id)) { BehaviorTreeRes res = getAndSyncLoadBT(id); this.unload(res.GetPath(), null); } return m_id2BTDic[id]; }
// 异步加载 public void loadBT(BTID id) { LoadParam param = Ctx.m_instance.m_poolSys.newObject <LoadParam>(); LocalFileSys.modifyLoadParam(m_btAttrSys.m_id2ItemDic[id].m_path, param); param.m_loadNeedCoroutine = false; param.m_resNeedCoroutine = false; load <BehaviorTreeRes>(param); Ctx.m_instance.m_poolSys.deleteObj(param); }
public BehaviorTree getBT(BTID id) { if (!m_id2BTDic.ContainsKey(id)) { BehaviorTreeRes res = getAndSyncLoadBT(id); this.unload(res.GetPath(), null); } return(m_id2BTDic[id]); }
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(); } }
public BehaviorTreeRes getAndSyncLoadBT(BTID id) { return getAndSyncLoad<BehaviorTreeRes>(m_btAttrSys.m_id2ItemDic[id].m_path); }
// 同步加载 public void syncLoadBT(BTID id) { syncLoad<BehaviorTreeRes>(m_btAttrSys.m_id2ItemDic[id].m_path); }
// 添加 AI virtual public void addAiByID(BTID id) { m_btID = id; initAi(m_btID); }
public BehaviorTreeRes getAndSyncLoadBT(BTID id) { return(getAndSyncLoad <BehaviorTreeRes>(m_btAttrSys.m_id2ItemDic[id].m_path)); }
// 同步加载 public void syncLoadBT(BTID id) { syncLoad <BehaviorTreeRes>(m_btAttrSys.m_id2ItemDic[id].m_path); }
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(); } }
// 添加 AI virtual public void addAiByID(BTID id) { m_btID = id; initAi(m_btID); }