public void CreateNpc() { Utils.Assert(curChapConfig == null, "Chapter Configdata is null."); if (reader.loadSceneConfig(curChapConfig.scene_config)) { NPCInSceneData[] npcInScene = reader.GetSceneEditorElementData <NPCInSceneData>(); if (npcInScene != null && npcInScene.Length > 0) { int len = npcInScene.Length; CrtHero[] toClient = new CrtHero[len]; for (int i = 0; i < len; i++) { NPCInSceneData sceneD = npcInScene [i]; ServerNPC npc = virNpcLoader.Load(sceneD.npcID, sceneD.camp, WarPoint); if (npc == null) { ConsoleEx.DebugWarning("Create npc fail!!!!!!!!! id:: " + sceneD.npcID); continue; } npc.transform.localPosition = new Vector3(sceneD.pos [0], sceneD.pos [1], sceneD.pos [2]); npc.transform.localScale = new Vector3(sceneD.scale [0], sceneD.scale [1], sceneD.scale [2]); npc.transform.localEulerAngles = new Vector3(sceneD.rotation [0], sceneD.rotation [1], sceneD.rotation [2]); npc.spawnPos = npc.transform.position; npc.spawnRot = npc.transform.rotation; npc.dataInScene = sceneD; npc.data.btData.way = sceneD.way; //初始化buff InitBuff(npc); //初始化AI InitAi(npc); toClient[i] = new CrtHero() { npcID = sceneD.npcID, uniqueId = npc.UniqueID, pos = VectorWrap.ToVector(npc.transform.position), rotation = VectorWrap.ToVector(npc.transform.eulerAngles), camp = (int)npc.Camp, }; } //send creating npc message to client IpcCreateNpcMsg msg = new IpcCreateNpcMsg() { npclist = toClient, }; WarSMgr.realServer.proxyCli.CtorNpc(msg); } } else { ConsoleEx.DebugWarning(curChapConfig.scene_config + " scene config is not find."); } }
public void CreateMap(MapInfo map) { //设置当前配置信息 if (map.type == ConfigType.PVEChapter) { ChapterModel chatperModel = Core.Data.getIModelConfig <ChapterModel>(); curChapConfig = chatperModel.get(map.ID); } else { PVPBattleModel pvpModel = Core.Data.getIModelConfig <PVPBattleModel>(); curChapConfig = pvpModel.get(map.ID); } //加载配表 reader.loadSceneConfig(map.ID); //TODO : According to the type of map, we should make up the right path StringBuilder strBld = new StringBuilder("Scenes/Stage_"); strBld.Append(map.ID.ToString()); GameObject go = Maploader.loadFromUnPack(strBld.ToString(), false); UnityUtils.AddChild_Reverse(go, ScenePoint); MapInSceneData[] mapdata = reader.GetSceneEditorElementData <MapInSceneData>(); if (mapdata != null && mapdata.Length > 0) { go.transform.localPosition = new Vector3(mapdata [0].pos [0], mapdata [0].pos [1], mapdata [0].pos [2]); go.transform.localScale = new Vector3(mapdata [0].scale [0], mapdata [0].scale [1], mapdata [0].scale [2]); go.transform.localEulerAngles = new Vector3(mapdata [0].rotation [0], mapdata [0].rotation [1], mapdata [0].rotation [2]); } strBld.Append("Graph"); string strPath = System.IO.Path.Combine(ResourceSetting.UNPACKROOT, strBld.ToString()); TextAsset mapTxt = UnityEngine.Resources.Load(strPath) as TextAsset; if (mapTxt == null) { Debug.LogError("scene textAsseet data is null :: " + strPath); } AstarPath.active.astarData.DeserializeGraphs(mapTxt.bytes); CreateUnVision(); GameObject helper = new GameObject("helper"); helper.AddComponent <TileHandlerHelper>(); }