public void RenderPrefebBuilding(VABuildingInfo buildinginfo) { int bid = buildinginfo.id; Quaternion rotation = Quaternion.Euler(0, buildinginfo.rotation, 0); if (PeGameMgr.IsSingleAdventure) { if (buildinginfo.buildingId.buildingNo != VArtifactTownConstant.NATIVE_TOWER_BUILDING_ID) { if (!BlockBuilding.s_tblBlockBuildingMap.ContainsKey(bid)) { LogManager.Error("bid = [", bid, "] not exist in database!"); return; } int campId = SceneDoodadDesc.c_neutralCamp; int damageId = SceneDoodadDesc.c_neutralDamage; if (buildinginfo.vau.vat.type == VArtifactType.NpcTown) { if (!buildinginfo.vau.vat.IsPlayerTown) { if (bid == ColonyNoMgrMachine.DOODAD_ID_REPAIR || bid == ColonyNoMgrMachine.DOODAD_ID_SOLARPOWER) { return; } campId = AllyConstants.EnemyNpcCampId; damageId = AllyConstants.EnemyNpcDamageId; } } else { if (buildinginfo.vau.vat.nativeType == NativeType.Puja) { campId = AllyConstants.PujaCampId; damageId = AllyConstants.PujaDamageId; } else { campId = AllyConstants.PajaCampId; damageId = AllyConstants.PajaDamageId; } } int playerId = VATownGenerator.Instance.GetPlayerId(buildinginfo.vau.vat.AllyId); if (!buildinginfo.vau.isDoodadNpcRendered) { VArtifactTownManager.Instance.AddAliveBuilding(buildinginfo.vau.vat.townId, DoodadEntityCreator.CreateRandTerDoodad(BlockBuilding.s_tblBlockBuildingMap[bid].mDoodadProtoId, buildinginfo.root, Vector3.one, rotation, buildinginfo.buildingId.townId, campId, damageId, playerId).Id); } //building npc if (!mCreatedNpcBuildingID.ContainsKey(buildinginfo.buildingId)) { BlockBuilding building = BlockBuilding.s_tblBlockBuildingMap[bid]; List <BuildingNpc> buildingNpcs; building.GetNpcInfo(out buildingNpcs); for (int bni = 0; bni < buildingNpcs.Count; bni++) { BuildingNpc bn = buildingNpcs[bni]; VArtifactUtil.GetPosRotFromPointRot(ref bn.pos, ref bn.rotY, buildinginfo.root, buildinginfo.rotation); } if (buildingNpcs != null && buildingNpcs.Count > 0) { if (buildinginfo.vau.vat.IsPlayerTown) { if (!buildinginfo.vau.isDoodadNpcRendered) { StartCoroutine(CreateBuildingNpcList(buildingNpcs)); mCreatedNpcBuildingID.Add(buildinginfo.buildingId, 0); } } else { GenEnemyNpc(buildingNpcs, buildinginfo.vau.vat.townId, buildinginfo.vau.vat.AllyId); } } } } else if (buildinginfo.buildingId.buildingNo == VArtifactTownConstant.NATIVE_TOWER_BUILDING_ID) { //tower if (!buildinginfo.vau.isDoodadNpcRendered) { int playerId = VATownGenerator.Instance.GetPlayerId(buildinginfo.vau.vat.AllyId); VArtifactTownManager.Instance.AddAliveBuilding(buildinginfo.vau.vat.townId, DoodadEntityCreator.CreateRandTerDoodad(buildinginfo.pathID, buildinginfo.root, Vector3.one, rotation, buildinginfo.vau.vat.townId, buildinginfo.campID, buildinginfo.damageID, playerId).Id ); } } if (missionBuilding.ContainsKey(0)) { if (buildinginfo.buildingId != missionBuilding[0]) { RemoveBuilding(buildinginfo.buildingId); } } else { RemoveBuilding(buildinginfo.buildingId); } } else if (PeGameMgr.IsMulti) { if (buildinginfo.buildingId.buildingNo != VArtifactTownConstant.NATIVE_TOWER_BUILDING_ID) { if (!BlockBuilding.s_tblBlockBuildingMap.ContainsKey(bid)) { LogManager.Error("bid = [", bid, "] not exist in database!"); return; } Debug.Log("RenderPrefebBuilding():" + bid); // int campId = SceneDoodadDesc.c_neutralCamp; int campId = SceneDoodadDesc.c_neutralCamp; int damageId = SceneDoodadDesc.c_neutralDamage; if (buildinginfo.vau.vat.type == VArtifactType.NpcTown) { if (!buildinginfo.vau.vat.IsPlayerTown) { if (bid == ColonyNoMgrMachine.DOODAD_ID_REPAIR || bid == ColonyNoMgrMachine.DOODAD_ID_SOLARPOWER) { return; } campId = AllyConstants.EnemyNpcCampId; damageId = AllyConstants.EnemyNpcDamageId; } } else { if (buildinginfo.vau.vat.nativeType == NativeType.Puja) { campId = AllyConstants.PujaCampId; damageId = AllyConstants.PujaDamageId; } else { campId = AllyConstants.PajaCampId; damageId = AllyConstants.PajaDamageId; } } int playerId = VATownGenerator.Instance.GetPlayerId(buildinginfo.vau.vat.AllyId); if (!buildinginfo.vau.isDoodadNpcRendered) { PlayerNetwork.RequestServer(EPacketType.PT_Common_TownDoodad, buildinginfo.buildingId, BlockBuilding.s_tblBlockBuildingMap[bid].mDoodadProtoId, buildinginfo.root, Vector3.one, rotation, buildinginfo.vau.vat.townId, campId, damageId, playerId); } //building npc if (!mCreatedNpcBuildingID.ContainsKey(buildinginfo.buildingId)) { BlockBuilding building = BlockBuilding.s_tblBlockBuildingMap[bid]; List <BuildingNpc> buildingNpcs; building.GetNpcInfo(out buildingNpcs); for (int bni = 0; bni < buildingNpcs.Count; bni++) { BuildingNpc bn = buildingNpcs[bni]; VArtifactUtil.GetPosRotFromPointRot(ref bn.pos, ref bn.rotY, buildinginfo.root, buildinginfo.rotation); } if (buildingNpcs != null && buildingNpcs.Count > 0) { if (buildingNpcs != null && buildingNpcs.Count > 0) { if (buildinginfo.vau.vat.IsPlayerTown) { if (!buildinginfo.vau.isDoodadNpcRendered) { StartCoroutine(CreateBuildingNpcList(buildingNpcs)); mCreatedNpcBuildingID.Add(buildinginfo.buildingId, 0); } } else { GenEnemyNpc(buildingNpcs, buildinginfo.vau.vat.townId, buildinginfo.vau.vat.AllyId); } } } } } else if (buildinginfo.buildingId.buildingNo == VArtifactTownConstant.NATIVE_TOWER_BUILDING_ID) { if (!buildinginfo.vau.isDoodadNpcRendered) { int playerId = VATownGenerator.Instance.GetPlayerId(buildinginfo.vau.vat.AllyId); PlayerNetwork.RequestServer(EPacketType.PT_Common_NativeTowerCreate, buildinginfo.buildingId, buildinginfo.pathID, buildinginfo.root, Vector3.one, rotation, buildinginfo.vau.vat.townId, buildinginfo.campID, buildinginfo.damageID, playerId); } } RemoveBuilding(buildinginfo.buildingId); } }