Created
February 6, 2017 05:00
-
-
Save doublespoiler/ec6b255a2d1a864b0a54c0b4ad6f2529 to your computer and use it in GitHub Desktop.
Could not load type RogueSharp.Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using RLNET; | |
using RogueSharpTut.Core; | |
using RogueSharp; | |
namespace RogueSharpTut.Systems | |
{ | |
public class MapGenerator | |
{ | |
private readonly int _width; | |
private readonly int _height; | |
private readonly DungeonMap _map; | |
//Constructing a new MapGenerator requires dimensions of the map it will make | |
public MapGenerator(int width, int height) | |
{ | |
_width = width; | |
_height = height; | |
_map = new DungeonMap(); | |
} | |
//Generate a newmap that is a simple open floor with walls around the outside | |
public DungeonMap CreateMap() | |
{ | |
//Initialize very cell in the map by setting walkable/transparency/explored to true | |
_map.Initialize(_width, _height); | |
foreach (Cell cell in _map.GetAllCells()) | |
{ | |
_map.SetCellProperties(cell.X, cell.Y, true, true, true); | |
} | |
//Set first and last rows to not be transparent or walkable | |
foreach (Cell cell in _map.GetCellsInRows(0, _height -1)) | |
{ | |
_map.SetCellProperties(cell.X, cell.Y, false, false, true); | |
} | |
//Set the first and last columns in map to not be transparent or walkable | |
foreach(Cell cell in _map.GetCellsInColumns(0, _width - 1 )) | |
{ | |
_map.SetCellProperties(cell.X, cell.Y, false, false, true); | |
} | |
return _map; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment