Esempio n. 1
0
    public static FloatPositionVo GetVORotation(int model)
    {
        FloatPositionVo pos      = new FloatPositionVo();
        SceneConfigVo   sceneCfg = MapEditorFunctionSelector.sceneConfigVo;

        if (sceneCfg == null)
        {
            return(null);
        }
        List <SceneElementInfo> list = sceneCfg.transfer;

        if (list == null)
        {
            return(null);
        }
        ClientElementInfo info = null;

        for (int i = 0; i < list.Count; i++)
        {
            info = list[i];
            if (info.model == model)
            {
                return(info.rotation);
            }
        }
        return(null);
    }
Esempio n. 2
0
    public static PositionVo GetVOPosition(int model)
    {
        PositionVo    pos      = new PositionVo();
        SceneConfigVo sceneCfg = MapEditorFunctionSelector.sceneConfigVo;

        if (sceneCfg == null)
        {
            return(pos);
        }
        List <SceneElementInfo> list = sceneCfg.transfer;

        if (list == null)
        {
            return(pos);
        }
        ClientElementInfo info = null;

        for (int i = 0; i < list.Count; i++)
        {
            info = list[i];
            if (info.model == model)
            {
                pos.x = info.location.x;
                pos.y = info.location.y;
                pos.z = info.location.z;
                return(pos);
            }
        }
        return(pos);
    }
Esempio n. 3
0
    public static SceneConfigVo importScene(int sceneId)
    {
        string filepath = Application.dataPath + string.Format(ExportScene.CLIENT_CONFIG_PATH, sceneId);
        string results  = FileTool.LoadFileContent(filepath);

        if (results == null)
        {
            return(null);
        }
        SceneConfigVo cfgVo = (SceneConfigVo)JsonParser.parser(results, typeof(SceneConfigVo));

        return(cfgVo);
    }
Esempio n. 4
0
    private void InitMapInfos(int mapId)
    {
        MapInfos info = new MapInfos();

        info.allmonster   = serverModel.monsterList.data;
        info.npcs         = GetSceneObjOnListByMapId(serverModel.npcList.data, mapId);
        info.transfers    = GetSceneElementOnListByMapId(serverModel.doorList.data, mapId);
        info.playerSpawn  = GetSceneObjOnListByMapId(serverModel.playerSpawn.data, mapId);
        info.monsterSpawn = GetSceneObjOnListByMapId(serverModel.monsterSpawn.data, mapId);

        serverModel.mapInfos = info;

        string sid = serverModel.mapVo.mapresid.ToString();

        EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();       //询问有修改的场景时的 保存当前修改场景
        EditorSceneManager.OpenScene(string.Format(sceneAssetsRoot, sid)); // 打开场景
        EditorMapView.mapName = serverModel.mapVo.map_name;

        sceneConfigVo = EditorSceneConfigLoader.importScene(mapId);// 导入场景数据
        if (sceneConfigVo != null)
        {
            sceneConfigVo.resId = sid;
            for (int i = 0; i < sceneConfigVo.monster.Count; i++)
            {
                ClientElementInfo monInfo = sceneConfigVo.monster[i];
                for (int j = 0; j < serverModel.monsterList.data.Count; j++)
                {
                    SceneObjVo monVo = serverModel.monsterList.data[j];
                }
            }

            info.monsters = sceneConfigVo.monster;
        }

        //加载服务器传来的怪物数据
        EditorNpcLoader.load();          //载入NPC
        EditorElementLoader.load();      // 载入传送门
        EditorMonsterLoader.load();      // 载入Monster
        EditorPlayerSpawnLoader.load();  // 载入玩家出生点
        EditorMonsterSpawnLoader.load(); // 载入刷怪区

        Rect      wr     = new Rect(0, 0, 310, 260);
        MapEditor window = (MapEditor)GetWindowWithRect(typeof(MapEditor), wr, true, "地图编辑器");

        window.editSceneVo.isImportMap = true;
        window.editSceneVo.sceneId     = mapId;
        window.Show();

        this.Close();
    }
Esempio n. 5
0
    /// <summary>
    /// 导出服务端需要的场景数据
    /// </summary>
    /// <param name="listCellVos">List cell vos.</param>
    /// <param name="editSceneVo">Edit scene vo.</param>
    private static void exportConfig(List <GameObjectCellVo> listCellVos, EditSceneVo editSceneVo, string outPath)
    {
        SceneConfigVo sceneConfig = new SceneConfigVo();

        sceneConfig.sceneId   = editSceneVo.sceneId;
        sceneConfig.sceneName = editSceneVo.mapName;
        sceneConfig.resId     = editSceneVo.resId;
        GameObjectCellVo curGOVo;

        for (int index = 0; index < listCellVos.Count; index++)
        {
            curGOVo = listCellVos[index];
            if (curGOVo == null || string.IsNullOrEmpty(curGOVo.cellVo.sourceType) == true)
            {
                continue;
            }
            ClientElementInfo cellVo = curGOVo.cellVo;
            cellVo.location = new PositionVo();

            if (curGOVo.currentGameObject != null)
            {
                Vector3 pos = curGOVo.currentGameObject.transform.position;
                cellVo.location.x = Mathf.Round(pos.x * 10000) / 10000;
                cellVo.location.y = Mathf.Round(pos.y * 10000) / 10000;
                cellVo.location.z = Mathf.Round(pos.z * 10000) / 10000;
                cellVo.rotation   = FloatPositionVo.toPosition(curGOVo.currentGameObject.transform.rotation.eulerAngles);
            }
            //npc
            if (cellVo.sourceType.Contains(ElementVo.ELEMENT_TYPE_NPC) == true)
            {
                sceneConfig.npcs.Add(cellVo);
                continue;
            }
            //door
            if (cellVo.sourceType.Contains(ElementVo.ELEMENT_TYPE_DOOR) == true)
            {
                sceneConfig.transfer.Add((SceneElementInfo)cellVo);
                continue;
            }
            //刷怪区
            if (cellVo.sourceType.Contains(ElementVo.ELEMENT_TYPE_MONSTERSPAWN) == true)
            {
                sceneConfig.monsterSpawn.Add(cellVo);
                continue;
            }
            //monster
            if (cellVo.sourceType.Contains(ElementVo.ELEMENT_TYPE_MONSTER) == true)
            {
                sceneConfig.monster.Add(cellVo);
                continue;
            }
            //玩家出生点
            if (cellVo.sourceType.Contains(ElementVo.ELEMENT_TYPE_PLAYERSPAWN) == true)
            {
                sceneConfig.playerSpawn.Add(cellVo);
                continue;
            }
        }
        string   filepath = Application.dataPath + string.Format(outPath, editSceneVo.sceneId);
        FileInfo t        = new FileInfo(filepath);

        if (!File.Exists(filepath))
        {
            File.Delete(filepath);
        }
        StreamWriter sw = t.CreateText();

        sw.WriteLine(JsonMapper.ToJson(sceneConfig));
        sw.Close();
        sw.Dispose();
        Debug.Log(sceneConfig.sceneName + " 导出完成!!!!!!!!!!");
    }