Beispiel #1
0
        public static ChunkInfo[, ] BuildChunkMap(AbstractLevelDescription _levelDescription)
        {
            // 初始化
            LevelDescription = _levelDescription;

            // 构造空图
            ChunkMap = new ChunkInfo[LevelDescription.MaxChunkX, LevelDescription.MaxChunkY];
            for (int i = 0; i < LevelDescription.MaxChunkX; i++)
            {
                for (int j = 0; j < LevelDescription.MaxChunkY; j++)
                {
                    ChunkMap[i, j] = new ChunkInfo(i, j);
                    if ((i < Constant.OverBorderChunkSize || i >= LevelDescription.MaxChunkX - Constant.OverBorderChunkSize) ||
                        (j < Constant.OverBorderChunkSize || j >= LevelDescription.MaxChunkY - Constant.OverBorderChunkSize))
                    {
                        ChunkMap[i, j].ChunkType = "OverNone";
                    }
                }
            }

            // 生成房间
            BuildInitRoom();
            // 生成路口
            BuildInitCross();
            // 连接路口
            ConnectCross();

            // 生成完毕,刷新道路毗邻数据
            RefreshCross();

            // 打印测试
            PrintChunkMap();

            return(ChunkMap);
        }
Beispiel #2
0
        public static void BuildLevel(AbstractLevelDescription _levelDescription)
        {
            LevelDescription = _levelDescription;

            // 生成区块地图
            ChunkMap = ChunkMapGenerator.BuildChunkMap(LevelDescription);
            // 生成方块地图
            BlockMap = BlockMapGenerator.BuildBlockMap(LevelDescription, ChunkMap);
            // 实例化地图
            RealMapGenerator.PrintMap(BlockMap);
        }
Beispiel #3
0
        public static BlockInfo[,] BuildBlockMap(AbstractLevelDescription _levelDescription, ChunkInfo[,] _chunkMap)
        {
            // 初始化数据,存入类中缓存
            LevelDescription = _levelDescription;
            ChunkMap         = _chunkMap;

            // 初始化方块地图
            BlockMap = new BlockInfo[LevelDescription.MaxChunkX * Constant.ChunkSize, LevelDescription.MaxChunkY *Constant.ChunkSize];
            for (int i = 0; i < BlockMap.GetLength(0); i++)
            {
                for (int j = 0; j < BlockMap.GetLength(1); j++)
                {
                    BlockMap[i, j]         = new BlockInfo(i, j);
                    BlockMap[i, j].CanPass = false;
                }
            }

            // 使用房间构造器生成房间方块地图
            BuildbyRoomGenerator();
            // 使用模板生成器填充通常区块
            BuildbyTemplateChunk();

            return(BlockMap);
        }