void DrawCellBackground(Point position, MapCell.CellType cellType) { for (int i = 0; i < cellHeight; i++) { Console.ForegroundColor = Console.BackgroundColor = cellType.GetConsoleColor(); Console.SetCursorPosition(gridLeftMargin + position.X * cellWidth, gridTopMargin + position.Y * cellHeight + i); Console.WriteLine(string.Concat(Enumerable.Repeat('█', cellWidth))); } }
int GetCountUpNeighbours(int x, int y, MapCell.CellType cellType, bool SetChecked = false) { if (y == StaticData.WorldCellSize) { return(0); } if (Map[y, x] == (int)cellType) { if (SetChecked) { Map[y, x] = (int)MapCell.CellType.Checked; } return(1 + GetCountUpNeighbours(x, y + 1, cellType, SetChecked)); } return(0); }
public static ConsoleColor GetConsoleColor(this MapCell.CellType celltype) { Dictionary <MapCell.CellType, ConsoleColor> cellColors = new Dictionary <MapCell.CellType, ConsoleColor>() { { MapCell.CellType.Ground, ConsoleColor.DarkGreen }, { MapCell.CellType.Water, ConsoleColor.Cyan } }; if (cellColors.ContainsKey(celltype)) { return(cellColors[celltype]); } else { throw new Exception("Для данного типа ячейки не задан фоновый цвет"); } }