public void PlayStart() { Int32 state = 0; if (PlayerManager.Instance.LocalAccount.ObType == ObPlayerOrPlayer.PlayerObType) { state = 1; } GameMapObjs GameBuilding = GameObject.FindObjectOfType(typeof(GameMapObjs)) as GameMapObjs; EntityManager.ClearHomeBase(); if (GameBuilding != null) { for (int id = 0; id < GameBuilding.transform.childCount; id++) { Transform child = GameBuilding.transform.GetChild(id); int objId = 0; try { objId = Convert.ToInt32(child.name); } catch (Exception e) { Debug.LogError(e.ToString()); continue; } int infoId = GetMapObjIndex(objId); if (ConfigReader.MapObjXmlInfoDict.ContainsKey(infoId)) { MapObjConfigInfo configInfp = ConfigReader.MapObjXmlInfoDict[infoId]; int type = configInfp.eObjectTypeID; int index = configInfp.un32ObjIdx; int camp = configInfp.n32Camp; UInt64 sGUID = (UInt64)index; EntityManager.HandleDelectEntity(sGUID); Ientity item = NpcManager.Instance.HandleCreateEntity(sGUID, (EntityCampType)camp); item.MapObgId = objId; item.realObject = child.gameObject; item.objTransform = child.gameObject.transform; item.GameObjGUID = sGUID; item.NpcGUIDType = type; item.ObjTypeID = (uint)type; item.entityType = (EntityType)ConfigReader.GetNpcInfo(type).NpcType; item.SetHp(1); item.SetHpMax(1); EntityManager.Instance.SetCommonProperty(item, type); item.RealEntity = EntityManager.AddBuildEntityComponent(item); NpcManager.Instance.AddEntity(sGUID, item); EntityManager.AddHomeBase(item); GuideBuildingTips.Instance.AddBuildingTips(item); } } } LoadBaseDate.Instance().LoadBase(); }
//游戏开始 游戏Bulidings创建 public void PlayStart() { //if (PlayerManager.Instance.LocalAccount.ObjType == ObPlayerOrPlayer.PlayerObType) //{ // state = 1; //} //场景中的对象 箭塔 防御塔, 售货员 产生小兵的基地 GameMapObjs GameBuilding = FindObjectOfType(typeof(GameMapObjs)) as GameMapObjs; //根据场景不同,个数不同 //清除基地 EntityManager.ClearHomeBase(); if (GameBuilding != null) { //获取配置文件并生成初始化 for (int id = 0; id < GameBuilding.transform.childCount; id++) { Transform child = GameBuilding.transform.GetChild(id); int objId = 0; try { objId = Convert.ToInt32(child.name);//将对象名称转化为整型 } catch (Exception e) { Debug.LogError(e.ToString()); continue; } int infoId = GetMapObjIndex(objId); //获取地图对象索引 if (ConfigReader.MapObjXmlInfoDict.ContainsKey(infoId)) //获取对象配置文件并生成对象 { //获取配置文件 MapObjConfigInfo configInfp = ConfigReader.MapObjXmlInfoDict[infoId]; int type = configInfp.eObjectTypeID; int index = configInfp.un32ObjIdx; int camp = configInfp.n32Camp; UInt64 sGUID = (UInt64)index; //生成并初始化 EntityManager.HandleDelectEntity(sGUID); IEntity item = NpcManager.Instance.HandleCreateEntity(sGUID, (EntityCampTypeEnum)camp); item.MapObgId = objId; item.realObject = child.gameObject; item.objTransform = child.gameObject.transform; item.GameObjGUID = sGUID; item.NpcGUIDType = type; item.ObjTypeID = (uint)type; item.entityType = (EntityTypeEnum)ConfigReader.GetNpcInfo(type).NpcType; item.SetHp(1); item.SetHpMax(1); EntityManager.Instance.SetCommonProperty(item, type); item.RealEntity = EntityManager.AddBuildEntityComponent(item); NpcManager.Instance.AddEntity(sGUID, item); EntityManager.AddHomeBase(item); GuideBuildingTips.Instance.AddBuildingTips(item); } } } //加载基地销毁特效,并设置为禁用 LoadBaseDate.Instance().LoadBase(); }