private void GetShips(Cell[,] cells) { foreach (var cell in cells) if (cell.Ship != null && cell.Ship.Color == Color) _ships.Add(cell.Ship); Count = _ships.Count; }
private void GetStations(Cell[,] cells) { foreach (var cell in cells) { if (cell.Obstacle is Station && (cell.Obstacle as Station).OwnerColor == Color) { _stations.Add(cell.Obstacle as Station); } } Count = _stations.Count; }
public Map() { Random = new Random(); MapCells = new Cell[0, 0]; _abilities = new Dictionary<AbilityName, IAbility> { {AbilityName.Heal, new Heal()}, {AbilityName.Corrosion, new Corrosion()} }; _activeSelectExists = false; IsResponding = true; }
private bool IsNeighbourCellNotControlled(Cell c) { return (!(c.Visited) && (c.Object == null || c.Object.IsPassable) && c.Ship == null && !(c.IsControlled)); }
private bool IsNeighbourCellEmpty(Cell c) { return (!(c.Visited) && (c.Object == null || c.Object.IsPassable) && c.Ship == null); }
public void CreateEmptyMap(int width, int height) { MapCells = new Cell[width, height]; for (var i = 0; i < width; i++) for (var j = 0; j < height; j++) { MapCells[i, j].IsLightened = false; } //CAREFULЪ HARDCODE DETEHTED! MapCells[0, 0].Object = new Dock(); MapCells[0, 1].Object = new Dock(); MapCells[1, 0].Object = new Dock(); MapCells[1, 1].Object = new Dock(); MapCells[2, 0].Object = new Dock(); MapCells[2, 1].Object = new Dock(); MapCells[4, 2].Object = new Station(); MapCells[13, 5].Object = new Station(); MapCells[0, 6].Object = new Station(); MapCells[17, 1].Object = new Station(); MapCells[15, 6].Object = new Dock(); MapCells[15, 7].Object = new Dock(); MapCells[16, 6].Object = new Dock(); MapCells[16, 7].Object = new Dock(); MapCells[17, 6].Object = new Dock(); MapCells[17, 7].Object = new Dock(); }
public ShipIterator(Cell[,] cells, PlayerColor color) { Color = color; _ships = new List<Ship>(); GetShips(cells); }
public StationIterator(Cell[,] cells, PlayerColor color) { Color = color; _stations = new List<Station>(); GetStations(cells); }