Example #1
0
        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;
        }
Example #2
0
 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;
 }
Example #3
0
        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;
        }
Example #4
0
 private bool IsNeighbourCellNotControlled(Cell c)
 {
     return (!(c.Visited) && (c.Object == null || c.Object.IsPassable) && c.Ship == null && !(c.IsControlled));
 }
Example #5
0
 private bool IsNeighbourCellEmpty(Cell c)
 {
     return (!(c.Visited) && (c.Object == null || c.Object.IsPassable) && c.Ship == null);
 }
Example #6
0
        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();
        }
Example #7
0
 public ShipIterator(Cell[,] cells, PlayerColor color)
 {
     Color = color;
     _ships = new List<Ship>();
     GetShips(cells);
 }
Example #8
0
 public StationIterator(Cell[,] cells, PlayerColor color)
 {
     Color = color;
     _stations = new List<Station>();
     GetStations(cells);
 }