public static BaseGrid Create(int width, int height) { // Build a custom cell grid var cells = new EmberCell[width * height]; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { var cell = new EmberCell { Background = Color.Black, Foreground = Color.Gray, Glyph = ' ', Position = new Point(x, y) }; cell.CellProperties = new EmberCell.EmberCellProperties { Name = null, Walkable = true, BlocksFov = false, NormalForeground = cell.Foreground, NormalBackground = cell.Background, ForegroundFov = cell.Foreground == Color.Transparent ? Color.Transparent : Color.Lerp(cell.Foreground, Color.Black, .5f), BackgroundFov = cell.Background == Color.Transparent ? Color.Transparent : Color.Lerp(cell.Foreground, Color.Black, .5f) }; cells[y * width + x] = cell; } } return(new BaseGrid(width, height, cells)); }
public static EmberGrid BuildCustomGrid(int width, int height) { // Build a custom cell grid var cells = new EmberCell[width * height]; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { cells[y * width + x] = new EmberCell { Background = Color.Black, Foreground = Color.Gray, Glyph = '.', CellProperties = new EmberCell.EmberCellProperties { Name = "floor", Walkable = true }, Position = new Point(x, y), }; } } return(new EmberGrid(width, height, cells)); }
private static void SetMapArea(int gridSizeX, int gridSizeY) { var cells = new EmberCell[gridSizeX * gridSizeY]; for (int x = 0; x < gridSizeX; x++) { for (int y = 0; y < gridSizeY; y++) { cells[y * gridSizeX + x] = new EmberCell(new Point(x, y), '.', Color.Green); } } Grid = new EmberGrid(gridSizeX, gridSizeY, cells); Grid.RenderObject(Map); }
private void GetRadiusNeighbors(EmberCell cell, int radius, List <EmberCell> cells) { if (radius == 0) { return; } var neighbors = _grid.GetNeighbors(cell); foreach (var neighbor in neighbors) { if (!cells.Contains(neighbor)) { cells.Add(neighbor); } GetRadiusNeighbors(neighbor, radius - 1, cells); } }
private void HandleDoorInteraction(EmberCell cell) { if (cell.CellProperties.Walkable) { interactionWindow.PrintMessage(Constants.CloseDoor); cell.CellProperties.Walkable = false; cell.Glyph = '+'; } else { interactionWindow.PrintMessage(Constants.OpenDoor); cell.CellProperties.Walkable = true; cell.Glyph = '='; } GridManager.Grid.SetCell(cell); player.MapWindow.Update(); _fovObjectsWindow.Update(player); }
private void HandleDoorInteraction(EmberCell cell) { if (cell.CellProperties.Walkable) { interactionWindow.PrintMessage(Constants.CloseDoor); cell.CellProperties.Walkable = false; cell.Glyph = '+'; cell.CellProperties.BlocksFov = true; } else { interactionWindow.PrintMessage(Constants.OpenDoor); cell.CellProperties.Walkable = true; cell.Glyph = '='; cell.CellProperties.BlocksFov = false; } GridManager.Grid.SetCell(cell); // Incase some effects need to be updated/shown after an interaction UpdateMapAfterInteraction(); }
private void HandleDefaultInteraction(EmberCell cell) { interactionWindow.PrintMessage("Interacting with " + cell.CellProperties.Name); }