예제 #1
0
        /// <summary>
        /// SeaGrid constructor, a seagrid has a number of tiles stored in an array
        /// </summary>
        public SeaGrid(Dictionary<ShipName, Ship> ships)
        {
            _GameTiles = new Tile[Width, Height];
            //fill array with empty Tiles
            int i = 0;
            for (i = 0; i <= Width - 1; i++) {
                for (int j = 0; j <= Height - 1; j++) {
                    _GameTiles[i, j] = new Tile(i, j, null);
                }
            }

            _Ships = ships;
        }
예제 #2
0
 // Constructor
 public Map(int posX, int posY, int width, int height)
 {
     this.posX = posX;
     this.posY = posY;
     this.width = width;
     this.height = height;
     tiles = new Tile[width, height];
     // Set position of all tiles in grid
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             tiles[j, i] = new Tile();
             tiles[j, i].posX = (posX + j);
             tiles[j, i].posY = (posY + i);
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Add tile adds the ship tile
 /// </summary>
 /// <param name="tile">one of the tiles the ship is on</param>
 public void AddTile(Tile tile)
 {
     _tiles.Add(tile);
 }