示例#1
0
        /// <summary>
        /// 加载关卡模式的地图
        /// </summary>
        /// <param name="configStr"></param>
        private void LoadNormalModeMapData(string configStr)
        {
            NormalModeMapData normalModeMapData = JsonConvert.DeserializeObject <NormalModeMapData>(configStr);

            if (normalModeMapData == null)
            {
                throw new Exception("读取配置失败!!! 请检查配置文件是否正确");
            }

            LoadModeMapData(normalModeMapData);

            LoadMapPart(0, normalModeMapData.mapPart);
        }
示例#2
0
        private MapData GenerateMapData()
        {
            MapData mapData = null;

            Transform mapParts = transform.Find(ChapterEditorDef.MapParts);

            if (mapParts == null)
            {
                throw new Exception("MapParts 结点不存在,导出失败!!!");
            }

            if (mapParts.childCount <= 0)
            {
                throw new Exception("MapParts 结点下不存在 MapPart 结点,导出失败!!!");
            }

            switch (Mode)
            {
            case MapMode.NormalMode:
                NormalModeMapData normalModeMapData = new NormalModeMapData();
                normalModeMapData.mapPart = GenerateMapPartDataList(mapParts, true)[0];
                mapData = normalModeMapData;
                break;

            case MapMode.EndlessMode:
                EndlessModeMapData endlessModeMapData = new EndlessModeMapData();
                endlessModeMapData.mapParts = GenerateMapPartDataList(mapParts, false);
                mapData = endlessModeMapData;
                break;
            }

            if (mapData == null)
            {
                throw new Exception("出现了未知的错误,构建数据失败!!!");
            }

            // 章节编号
            mapData.no = GenerateChapterNo();
            // 章节名称
            mapData.name = ChapterName;
            // 背景音乐路径
            mapData.bgmPaths = GenerateBgmPaths();
            // 天空盒路径
            mapData.skyboxPath = GenerateSkyboxPath();
            // 出生点信息
            mapData.birthPoints = GenerateBirthPoints();

            return(mapData);
        }