Advertisement
Guest User

Cave generation problem

a guest
Jan 22nd, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 21.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Collections;
  5. using UnityEngine.Tilemaps;
  6.  
  7. public class GenerateTerrain : MonoBehaviour
  8. {
  9.     public Tilemap tileMap;
  10.     public TileBase baseTile;
  11.  
  12.     public int width;
  13.     public int height;
  14.  
  15.     public int seed;
  16.     public bool useRandomSeed;
  17.     public int caveCount;
  18.  
  19.     public int caveVerticalSize;
  20.     public int caveHorizontalSize;
  21.  
  22.     public int smoothness = 1;
  23.  
  24.     public int[,] terrain;
  25.  
  26.     // Start is called before the first frame update
  27.     void Start()
  28.     {
  29.         //Generate a blank array
  30.         terrain = GenerateArray(width, height);
  31.  
  32.         //Overwrite array with textured terrain depending on if useRandomSeed is true
  33.         if (useRandomSeed)
  34.         {
  35.             terrain = RandomWalkTopSmoothed(terrain, UnityEngine.Random.Range(0, 1000), smoothness);
  36.         }
  37.         else
  38.         {
  39.             terrain = RandomWalkTopSmoothed(terrain, seed, smoothness);
  40.         }
  41.  
  42.         //Used to get GenerateMap() function
  43.         GenerateCaves caveSystem = gameObject.GetComponent<GenerateCaves>();
  44.  
  45.         //Used to set real-world coordinates for placing centers of caves
  46.         int[,] center = new int[1, 2];
  47.         int[,] map;
  48.  
  49.         //USed to determine offset between cave center and rel-world center
  50.         int xShift;
  51.         int yShift;
  52.  
  53.         for (int i = 0; i < caveCount; i++)
  54.         {
  55.             //Randomly select center coordinates
  56.             center[0, 0] = Mathf.RoundToInt(Mathf.PerlinNoise(i + 1, seed) * width);
  57.             center[0, 1] = Mathf.RoundToInt(Mathf.PerlinNoise(i + 2, seed) * height);
  58.  
  59.             //Generate cave coordinates
  60.             map = caveSystem.GenerateMap(""+(seed * i), caveHorizontalSize, caveVerticalSize, UnityEngine.Random.Range(0, 100));
  61.  
  62.             //Determine offset between centers
  63.             xShift = Mathf.Abs((caveHorizontalSize / 2) - center[0, 0]);
  64.             yShift = Mathf.Abs((caveVerticalSize / 2) - center[0, 1]);
  65.  
  66.             //Loop through each column in the map
  67.             for (int x = 0; x < caveHorizontalSize; x++)
  68.             {
  69.                 //Loop through each row in the map
  70.                 for (int y = 0; y < caveVerticalSize; y++)
  71.                 {
  72.                     //Determine if cave (empty block) is in that position
  73.                     if (map[x, y] == 0)
  74.                     {
  75.                         //Apply offset to that position and destroy tile in terrain array
  76.                         terrain[x + xShift, y + yShift] = 0;
  77.                     }
  78.                 }
  79.             }
  80.  
  81.         }
  82.  
  83.         //Set tiles from array onto tilemap
  84.         RenderMap(terrain, tileMap, baseTile);
  85.  
  86.     }
  87.  
  88.     // Update is called once per frame
  89.     void Update()
  90.     {
  91.         //Constantly update the tilemap
  92.         UpdateMap(terrain, tileMap);
  93.     }
  94.  
  95.     //Fucntion used to generate bank arrays
  96.     public static int[,] GenerateArray(int width, int height)
  97.     {
  98.         //Create a multi-dimensional integer array with rows and columns according to the width and height parameters
  99.         int[,] map = new int[width, height];
  100.  
  101.         //Loop through each column in the array
  102.         for (int x = 0; x < map.GetUpperBound(0); x++)
  103.         {
  104.             //Loop through each row in the column
  105.             for (int y = 0; y < map.GetUpperBound(1); y++)
  106.             {
  107.                 //Add a placeholder 1 for each row
  108.                 map[x, y] = 1;
  109.             }
  110.         }
  111.  
  112.         return map;
  113.     }
  114.  
  115.     //Function used to render the array onto the tilemap
  116.     public static void RenderMap(int[,] map, Tilemap tilemap, TileBase tile)
  117.     {
  118.         //Clear the map (ensures we dont overlap)
  119.         tilemap.ClearAllTiles();
  120.  
  121.         //Loop through the width of the map
  122.         for (int x = 0; x < map.GetUpperBound(0); x++)
  123.         {
  124.             //Loop through the height of the map
  125.             for (int y = 0; y < map.GetUpperBound(1); y++)
  126.             {
  127.                 // 1 = tile, 0 = no tile
  128.                 if (map[x, y] == 1)
  129.                 {
  130.                     //Set the tile to baseTile in that Vector if needed
  131.                     tilemap.SetTile(new Vector3Int(x, y, 0), tile);
  132.                 }
  133.             }
  134.         }
  135.     }
  136.  
  137.     //Function which takes in our map and tilemap, setting null tiles where needed
  138.     public static void UpdateMap(int[,] map, Tilemap tilemap)
  139.     {
  140.         //Loop through the width of the map
  141.         for (int x = 0; x < map.GetUpperBound(0); x++)
  142.         {
  143.             //Loop through the height of the map
  144.             for (int y = 0; y < map.GetUpperBound(1); y++)
  145.             {
  146.                 //We are only going to update the map, rather than rendering again
  147.                 //This is because it uses less resources to update tiles to null
  148.                 //As opposed to re-drawing every single tile (and collision data)
  149.                 if (map[x, y] == 0)
  150.                 {
  151.                     //Set the tile to baseTile in that Vector if needed
  152.                     tilemap.SetTile(new Vector3Int(x, y, 0), null);
  153.                 }
  154.             }
  155.         }
  156.     }
  157.  
  158.     //Function used to create the texture which will overlay onto the blank array
  159.     public static int[,] RandomWalkTopSmoothed(int[,] map, float seed, int minSectionWidth)
  160.     {
  161.         //Store the initial texture coords for each column into this list
  162.         List<Tuple<int, int>> getTexture = new List<Tuple<int, int>>();
  163.  
  164.         //Seed our random
  165.         System.Random rand = new System.Random(seed.GetHashCode());
  166.  
  167.         //Determine the start position
  168.         int lastHeight = UnityEngine.Random.Range(0, map.GetUpperBound(1));
  169.  
  170.         //Used to determine which direction to go
  171.         int nextMove = 0;
  172.  
  173.         //Used to keep track of the current sections width
  174.         int sectionWidth = 0;
  175.  
  176.         //Work through the array width
  177.         for (int x = 0; x <= map.GetUpperBound(0); x++)
  178.         {
  179.             //Determine the next move
  180.             nextMove = rand.Next(2);
  181.  
  182.             //Only change the height if we have used the current height more than the minimum required section width
  183.             if (nextMove == 0 && lastHeight > 0 && sectionWidth > minSectionWidth)
  184.             {
  185.                 lastHeight--;
  186.                 sectionWidth = 0;
  187.             }
  188.             else if (nextMove == 1 && lastHeight < map.GetUpperBound(1) && sectionWidth > minSectionWidth)
  189.             {
  190.                 lastHeight++;
  191.                 sectionWidth = 0;
  192.             }
  193.  
  194.             //Increment the section width
  195.             sectionWidth++;
  196.  
  197.             //Add coordinate to texture list
  198.             getTexture.Add(Tuple.Create(x, lastHeight));
  199.         }
  200.  
  201.         //Create the variable to eventually hold the biggest y variable of the coords-
  202.         //In texture list to act as the height limit when overlaying onto the array
  203.         int biggestY = 0;
  204.  
  205.         //Sort through each coordinate pair in the textures
  206.         foreach (Tuple<int, int> coord in getTexture)
  207.         {
  208.             //Add new y value if it is bigger than currently stored y value
  209.             if (coord.Item2 > biggestY)
  210.             {
  211.                 //Overwrite y vaue
  212.                 biggestY = coord.Item2;
  213.             }
  214.         }
  215.  
  216.         //Determine the coordinate shift between the biggest y value and the height limit
  217.         int yShift = map.GetUpperBound(1) - biggestY;
  218.  
  219.         //Sort through each coordinate pair in the textures
  220.         foreach (Tuple<int, int> coord in getTexture)
  221.         {
  222.             //Start removing extra tiles above the texture by translating the getTexture's coords to the map's coords
  223.             for (int i = coord.Item2 + yShift; i < map.GetUpperBound(1); i++)
  224.             {
  225.                 //Set every tile above the texture to 0, as it is not needed
  226.                 map[coord.Item1, i] = 0;
  227.             }
  228.         }
  229.  
  230.         //Return the modified map
  231.         return map;
  232.     }
  233.  
  234. }
  235.  
  236.  
  237. ```
  238. New script
  239. ```
  240.  
  241. using UnityEngine;
  242. using System.Collections.Generic;
  243. using System;
  244.  
  245. public class GenerateCaves : MonoBehaviour
  246. {
  247.     int[,] map;
  248.  
  249.     public int[,] GenerateMap(string seed, int width, int height, int randomFillPercent, int smoothness = 5)
  250.     {
  251.         if(randomFillPercent > 100 || randomFillPercent < 0)
  252.         {
  253.             Debug.LogError("Random Fill Percent must be inbetween 0 and 100");
  254.         }
  255.         map = new int[width, height];
  256.         RandomFillMap(seed, width, height, randomFillPercent);
  257.  
  258.         for (int i = 0; i < smoothness; i++)
  259.         {
  260.             SmoothMap(width, height);
  261.         }
  262.  
  263.         ProcessMap(width, height);
  264.  
  265.         int borderSize = 1;
  266.         int[,] borderedMap = new int[width + borderSize * 2, height + borderSize * 2];
  267.  
  268.         for (int x = 0; x < borderedMap.GetLength(0); x++)
  269.         {
  270.             for (int y = 0; y < borderedMap.GetLength(1); y++)
  271.             {
  272.                 if (x >= borderSize && x < width + borderSize && y >= borderSize && y < height + borderSize)
  273.                 {
  274.                     borderedMap[x, y] = map[x - borderSize, y - borderSize];
  275.                 }
  276.                 else
  277.                 {
  278.                     borderedMap[x, y] = 1;
  279.                 }
  280.             }
  281.         }
  282.         return borderedMap;
  283.     }
  284.  
  285.     void ProcessMap(int width, int height)
  286.     {
  287.         List<List<Coord>> wallRegions = GetRegions(1, width, height);
  288.         int wallThresholdSize = 50;
  289.  
  290.         foreach (List<Coord> wallRegion in wallRegions)
  291.         {
  292.             if (wallRegion.Count < wallThresholdSize)
  293.             {
  294.                 foreach (Coord tile in wallRegion)
  295.                 {
  296.                     map[tile.tileX, tile.tileY] = 0;
  297.                 }
  298.             }
  299.         }
  300.  
  301.         List<List<Coord>> roomRegions = GetRegions(0, width, height);
  302.         int roomThresholdSize = 50;
  303.         List<Room> survivingRooms = new List<Room>();
  304.  
  305.         foreach (List<Coord> roomRegion in roomRegions)
  306.         {
  307.             if (roomRegion.Count < roomThresholdSize)
  308.             {
  309.                 foreach (Coord tile in roomRegion)
  310.                 {
  311.                     map[tile.tileX, tile.tileY] = 1;
  312.                 }
  313.             }
  314.             else
  315.             {
  316.                 survivingRooms.Add(new Room(roomRegion, map));
  317.             }
  318.         }
  319.         survivingRooms.Sort();
  320.         survivingRooms[0].isMainRoom = true;
  321.         survivingRooms[0].isAccessibleFromMainRoom = true;
  322.  
  323.         ConnectClosestRooms(survivingRooms, width, height);
  324.     }
  325.  
  326.     void ConnectClosestRooms(List<Room> allRooms, int width, int height, bool forceAccessibilityFromMainRoom = false)
  327.     {
  328.  
  329.         List<Room> roomListA = new List<Room>();
  330.         List<Room> roomListB = new List<Room>();
  331.  
  332.         if (forceAccessibilityFromMainRoom)
  333.         {
  334.             foreach (Room room in allRooms)
  335.             {
  336.                 if (room.isAccessibleFromMainRoom)
  337.                 {
  338.                     roomListB.Add(room);
  339.                 }
  340.                 else
  341.                 {
  342.                     roomListA.Add(room);
  343.                 }
  344.             }
  345.         }
  346.         else
  347.         {
  348.             roomListA = allRooms;
  349.             roomListB = allRooms;
  350.         }
  351.  
  352.         int bestDistance = 0;
  353.         Coord bestTileA = new Coord();
  354.         Coord bestTileB = new Coord();
  355.         Room bestRoomA = new Room();
  356.         Room bestRoomB = new Room();
  357.         bool possibleConnectionFound = false;
  358.  
  359.         foreach (Room roomA in roomListA)
  360.         {
  361.             if (!forceAccessibilityFromMainRoom)
  362.             {
  363.                 possibleConnectionFound = false;
  364.                 if (roomA.connectedRooms.Count > 0)
  365.                 {
  366.                     continue;
  367.                 }
  368.             }
  369.  
  370.             foreach (Room roomB in roomListB)
  371.             {
  372.                 if (roomA == roomB || roomA.IsConnected(roomB))
  373.                 {
  374.                     continue;
  375.                 }
  376.  
  377.                 for (int tileIndexA = 0; tileIndexA < roomA.edgeTiles.Count; tileIndexA++)
  378.                 {
  379.                     for (int tileIndexB = 0; tileIndexB < roomB.edgeTiles.Count; tileIndexB++)
  380.                     {
  381.                         Coord tileA = roomA.edgeTiles[tileIndexA];
  382.                         Coord tileB = roomB.edgeTiles[tileIndexB];
  383.                         int distanceBetweenRooms = (int)(Mathf.Pow(tileA.tileX - tileB.tileX, 2) + Mathf.Pow(tileA.tileY - tileB.tileY, 2));
  384.  
  385.                         if (distanceBetweenRooms < bestDistance || !possibleConnectionFound)
  386.                         {
  387.                             bestDistance = distanceBetweenRooms;
  388.                             possibleConnectionFound = true;
  389.                             bestTileA = tileA;
  390.                             bestTileB = tileB;
  391.                             bestRoomA = roomA;
  392.                             bestRoomB = roomB;
  393.                         }
  394.                     }
  395.                 }
  396.             }
  397.             if (possibleConnectionFound && !forceAccessibilityFromMainRoom)
  398.             {
  399.                 CreatePassage(bestRoomA, bestRoomB, bestTileA, bestTileB, width, height);
  400.             }
  401.         }
  402.  
  403.         if (possibleConnectionFound && forceAccessibilityFromMainRoom)
  404.         {
  405.             CreatePassage(bestRoomA, bestRoomB, bestTileA, bestTileB, width, height);
  406.             ConnectClosestRooms(allRooms, width, height, true);
  407.         }
  408.  
  409.         if (!forceAccessibilityFromMainRoom)
  410.         {
  411.             ConnectClosestRooms(allRooms, width, height, true);
  412.         }
  413.     }
  414.  
  415.     void CreatePassage(Room roomA, Room roomB, Coord tileA, Coord tileB, int width, int height)
  416.     {
  417.         Room.ConnectRooms(roomA, roomB);
  418.         //Debug.DrawLine (CoordToWorldPoint (tileA), CoordToWorldPoint (tileB), Color.green, 100);
  419.  
  420.         List<Coord> line = GetLine(tileA, tileB);
  421.         foreach (Coord c in line)
  422.         {
  423.             DrawCircle(c, 5, width, height);
  424.         }
  425.     }
  426.  
  427.     void DrawCircle(Coord c, int r, int width, int height)
  428.     {
  429.         for (int x = -r; x <= r; x++)
  430.         {
  431.             for (int y = -r; y <= r; y++)
  432.             {
  433.                 if (x * x + y * y <= r * r)
  434.                 {
  435.                     int drawX = c.tileX + x;
  436.                     int drawY = c.tileY + y;
  437.                     if (IsInMapRange(drawX, drawY, width, height))
  438.                     {
  439.                         map[drawX, drawY] = 0;
  440.                     }
  441.                 }
  442.             }
  443.         }
  444.     }
  445.  
  446.     List<Coord> GetLine(Coord from, Coord to)
  447.     {
  448.         List<Coord> line = new List<Coord>();
  449.  
  450.         int x = from.tileX;
  451.         int y = from.tileY;
  452.  
  453.         int dx = to.tileX - from.tileX;
  454.         int dy = to.tileY - from.tileY;
  455.  
  456.         bool inverted = false;
  457.         int step = Math.Sign(dx);
  458.         int gradientStep = Math.Sign(dy);
  459.  
  460.         int longest = Mathf.Abs(dx);
  461.         int shortest = Mathf.Abs(dy);
  462.  
  463.         if (longest < shortest)
  464.         {
  465.             inverted = true;
  466.             longest = Mathf.Abs(dy);
  467.             shortest = Mathf.Abs(dx);
  468.  
  469.             step = Math.Sign(dy);
  470.             gradientStep = Math.Sign(dx);
  471.         }
  472.  
  473.         int gradientAccumulation = longest / 2;
  474.         for (int i = 0; i < longest; i++)
  475.         {
  476.             line.Add(new Coord(x, y));
  477.  
  478.             if (inverted)
  479.             {
  480.                 y += step;
  481.             }
  482.             else
  483.             {
  484.                 x += step;
  485.             }
  486.  
  487.             gradientAccumulation += shortest;
  488.             if (gradientAccumulation >= longest)
  489.             {
  490.                 if (inverted)
  491.                 {
  492.                     x += gradientStep;
  493.                 }
  494.                 else
  495.                 {
  496.                     y += gradientStep;
  497.                 }
  498.                 gradientAccumulation -= longest;
  499.             }
  500.         }
  501.  
  502.         return line;
  503.     }
  504.  
  505.     List<List<Coord>> GetRegions(int tileType, int width, int height)
  506.     {
  507.         List<List<Coord>> regions = new List<List<Coord>>();
  508.         int[,] mapFlags = new int[width, height];
  509.  
  510.         for (int x = 0; x < width; x++)
  511.         {
  512.             for (int y = 0; y < height; y++)
  513.             {
  514.                 if (mapFlags[x, y] == 0 && map[x, y] == tileType)
  515.                 {
  516.                     List<Coord> newRegion = GetRegionTiles(x, y, width, height);
  517.                     regions.Add(newRegion);
  518.  
  519.                     foreach (Coord tile in newRegion)
  520.                     {
  521.                         mapFlags[tile.tileX, tile.tileY] = 1;
  522.                     }
  523.                 }
  524.             }
  525.         }
  526.  
  527.         return regions;
  528.     }
  529.  
  530.     List<Coord> GetRegionTiles(int startX, int startY, int width, int height)
  531.     {
  532.         List<Coord> tiles = new List<Coord>();
  533.         int[,] mapFlags = new int[width, height];
  534.         int tileType = map[startX, startY];
  535.  
  536.         Queue<Coord> queue = new Queue<Coord>();
  537.         queue.Enqueue(new Coord(startX, startY));
  538.         mapFlags[startX, startY] = 1;
  539.  
  540.         while (queue.Count > 0)
  541.         {
  542.             Coord tile = queue.Dequeue();
  543.             tiles.Add(tile);
  544.  
  545.             for (int x = tile.tileX - 1; x <= tile.tileX + 1; x++)
  546.             {
  547.                 for (int y = tile.tileY - 1; y <= tile.tileY + 1; y++)
  548.                 {
  549.                     if (IsInMapRange(x, y, width, height) && (y == tile.tileY || x == tile.tileX))
  550.                     {
  551.                         if (mapFlags[x, y] == 0 && map[x, y] == tileType)
  552.                         {
  553.                             mapFlags[x, y] = 1;
  554.                             queue.Enqueue(new Coord(x, y));
  555.                         }
  556.                     }
  557.                 }
  558.             }
  559.         }
  560.         return tiles;
  561.     }
  562.  
  563.     bool IsInMapRange(int x, int y, int width, int height)
  564.     {
  565.         return x >= 0 && x < width && y >= 0 && y < height;
  566.     }
  567.  
  568.  
  569.     void RandomFillMap(string seed, int width, int height, int randomFillPercent)
  570.     {
  571.  
  572.         System.Random pseudoRandom = new System.Random(seed.GetHashCode());
  573.  
  574.         for (int x = 0; x < width; x++)
  575.         {
  576.             for (int y = 0; y < height; y++)
  577.             {
  578.                 if (x == 0 || x == width - 1 || y == 0 || y == height - 1)
  579.                 {
  580.                     map[x, y] = 1;
  581.                 }
  582.                 else
  583.                 {
  584.                     map[x, y] = (pseudoRandom.Next(0, 100) < randomFillPercent) ? 1 : 0;
  585.                 }
  586.             }
  587.         }
  588.     }
  589.  
  590.     void SmoothMap(int width, int height)
  591.     {
  592.         for (int x = 0; x < width; x++)
  593.         {
  594.             for (int y = 0; y < height; y++)
  595.             {
  596.                 int neighbourWallTiles = GetSurroundingWallCount(x, y, width, height);
  597.  
  598.                 if (neighbourWallTiles > 4)
  599.                     map[x, y] = 1;
  600.                 else if (neighbourWallTiles < 4)
  601.                     map[x, y] = 0;
  602.  
  603.             }
  604.         }
  605.     }
  606.  
  607.     int GetSurroundingWallCount(int gridX, int gridY, int width, int height)
  608.     {
  609.         int wallCount = 0;
  610.         for (int neighbourX = gridX - 1; neighbourX <= gridX + 1; neighbourX++)
  611.         {
  612.             for (int neighbourY = gridY - 1; neighbourY <= gridY + 1; neighbourY++)
  613.             {
  614.                 if (IsInMapRange(neighbourX, neighbourY, width, height))
  615.                 {
  616.                     if (neighbourX != gridX || neighbourY != gridY)
  617.                     {
  618.                         wallCount += map[neighbourX, neighbourY];
  619.                     }
  620.                 }
  621.                 else
  622.                 {
  623.                     wallCount++;
  624.                 }
  625.             }
  626.         }
  627.  
  628.         return wallCount;
  629.     }
  630.  
  631.     struct Coord
  632.     {
  633.         public int tileX;
  634.         public int tileY;
  635.  
  636.         public Coord(int x, int y)
  637.         {
  638.             tileX = x;
  639.             tileY = y;
  640.         }
  641.     }
  642.  
  643.  
  644.     class Room : IComparable<Room>
  645.     {
  646.         public List<Coord> tiles;
  647.         public List<Coord> edgeTiles;
  648.         public List<Room> connectedRooms;
  649.         public int roomSize;
  650.         public bool isAccessibleFromMainRoom;
  651.         public bool isMainRoom;
  652.  
  653.         public Room()
  654.         {
  655.         }
  656.  
  657.         public Room(List<Coord> roomTiles, int[,] map)
  658.         {
  659.             tiles = roomTiles;
  660.             roomSize = tiles.Count;
  661.             connectedRooms = new List<Room>();
  662.  
  663.             edgeTiles = new List<Coord>();
  664.             foreach (Coord tile in tiles)
  665.             {
  666.                 for (int x = tile.tileX - 1; x <= tile.tileX + 1; x++)
  667.                 {
  668.                     for (int y = tile.tileY - 1; y <= tile.tileY + 1; y++)
  669.                     {
  670.                         if (x == tile.tileX || y == tile.tileY)
  671.                         {
  672.                             if (map[x, y] == 1)
  673.                             {
  674.                                 edgeTiles.Add(tile);
  675.                             }
  676.                         }
  677.                     }
  678.                 }
  679.             }
  680.         }
  681.  
  682.         public void SetAccessibleFromMainRoom()
  683.         {
  684.             if (!isAccessibleFromMainRoom)
  685.             {
  686.                 isAccessibleFromMainRoom = true;
  687.                 foreach (Room connectedRoom in connectedRooms)
  688.                 {
  689.                     connectedRoom.SetAccessibleFromMainRoom();
  690.                 }
  691.             }
  692.         }
  693.  
  694.         public static void ConnectRooms(Room roomA, Room roomB)
  695.         {
  696.             if (roomA.isAccessibleFromMainRoom)
  697.             {
  698.                 roomB.SetAccessibleFromMainRoom();
  699.             }
  700.             else if (roomB.isAccessibleFromMainRoom)
  701.             {
  702.                 roomA.SetAccessibleFromMainRoom();
  703.             }
  704.             roomA.connectedRooms.Add(roomB);
  705.             roomB.connectedRooms.Add(roomA);
  706.         }
  707.  
  708.         public bool IsConnected(Room otherRoom)
  709.         {
  710.             return connectedRooms.Contains(otherRoom);
  711.         }
  712.  
  713.         public int CompareTo(Room otherRoom)
  714.         {
  715.             return otherRoom.roomSize.CompareTo(roomSize);
  716.         }
  717.     }
  718.  
  719. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement