public Grid(int width, int height, float cellSize, string tilePallet, int roomId) { this.width = width; this.height = height; this.cellSize = cellSize; this.tilePallet = tilePallet; room = new GameObject(); room.name = "Room_" + roomId; sprites = Resources.LoadAll <Sprite>(tilePallet); cells = new Room.Cell[width, height]; // Init the array; debugTextArray = new TextMesh[width, height]; // DEBUG CODE // Add the cell objects to the grid and set its type from the array created above. for (int x = 0; x < cells.GetLength(0); x++) { for (int y = 0; y < cells.GetLength(1); y++) { cells[x, y] = new Room.Cell(x + "_" + y, cellSize); // Add cell object to array cells[x, y].getGameObject().transform.parent = room.gameObject.transform; } } }
/** Return if a cell with ground is at coords **/ public bool hasGround(int x, int y) { Room.Cell cell = getCellAtCoord(x, y); return(cell.getHasGroundTile()); }
/** Return if a cell of a type is at a coords **/ public bool hasCellOfType(int x, int y, CellType type) { Room.Cell cell = getCellAtCoord(x, y); return(cell.getCellType() == type); }