public RoomNode InitMapFrameWork(System.Random seed, MapSetting mapSetting) { GameObject[] temp = Resources.LoadAll <GameObject>("Prefabs/BossTool"); specialPotions = temp.ToList(); tilemap.ClearAllTiles(); map = new Map(mapSetting.width, mapSetting.height); TileManager.Instance.LayTiles(map, tilemap, seed); bsp = new BinarySpacePartitioner(mapSetting.width, mapSetting.height, seed, mapSetting.BSPIterationTimes); rooms = bsp.SliceMap(mapSetting.minRoomWidth, mapSetting.minRoomHeight, mapSetting.passageWidth, mapSetting.corridorWidth); RoomManager.Instance.SetRoomsType(ref rooms, seed); RoomNode startRoom = rooms[seed.Next(0, rooms.Count)]; while (startRoom.type.Equals(RoomType.Boss)) { startRoom = rooms[seed.Next(0, rooms.Count)]; } RoomManager.Instance.SetRoomContent(startRoom.type, startRoom, map, seed, mapSetting); TileManager.Instance.LayTilsInRoom(map, startRoom, tilemap, seed); return(startRoom); }
public Map GenerateBinaryMap(int mapWidth, int mapHeight) { //TileManager.Instance.Test(); #if UNITY_STANDALONE tilemap.ClearAllTiles(); #endif map = new Map(mapWidth, mapHeight); if (useRandomSeed || seed == null) { seed = Time.time.ToString(); } System.Random random = new System.Random(seed.GetHashCode()); BinarySpacePartitioner bsp = new BinarySpacePartitioner(mapWidth, mapHeight, random, mapSetting.BSPIterationTimes); rooms = bsp.SliceMap(mapSetting.minRoomWidth, mapSetting.minRoomHeight, mapSetting.passageWidth, mapSetting.corridorWidth); RoomManager.Instance.SetRoomsType(ref rooms, random, mapSetting.RoomTypePercentage); foreach (RoomNode room in rooms) { //for(int y=room.bottomLeft.y;y<=room.topRight.y;y++) //{ // for(int x=room.bottomLeft.x;x<=room.topRight.x;x++) // { // if (x == 0 || x == mapWidth - 1 || y == 0 || y == mapHeight - 1) // map.mapMatrix[x, y] = (float)TileType.Border; // //else // // map.mapMatrix[x, y] = (float)TileType.Floor_1; // } //} //Debug.Log(rooms.IndexOf(room) + " " + room.type + " " + room.bottomLeft); RoomManager.Instance.SetRoomContent(room.type, room, map, random, mapSetting); } //foreach (Corridor corridor in bsp.corridors) //{ // foreach (Vector2Int pos in corridor.coordinates) // { // map.mapMatrix[pos.x, pos.y] = (float)TileType.Corridor; // } //} TileManager.Instance.LayTiles(map, tilemap, random); return(map); }