コード例 #1
0
 private void place()
 {
     if (deleteShip == null)
     {
         return;
     }
     place_sound.Play();
     foreach (int coor in deleteShip.Coordinates)
     {
         ImageBrush img;
         if (deleteShip.IsHorizontal)
         {
             img = ship_hori;
         }
         else
         {
             img = ship_verti;
         }
         Fields[coor / 10, coor % 10].Fill = img;
     }
     allreadySetShips.Add(deleteShip);
     deleteShip = null;
     lengthOfShips.RemoveAt(0);
     LblPlaceShips.Content = "PLACE " + lengthOfShips.Count.ToString() + " SHIPS";
     if (lengthOfShips.Count <= 0)
     {
         this.Visibility = Visibility.Collapsed;
         // Player
         Board playerBoard = new Board();
         playerBoard.Ships = allreadySetShips.ToArray();
         playerBoard.SSOOG();
         // Computer
         Board computerBoard = new Board();
         computerBoard.Ships = Board.GenerateShips();
         computerBoard.SSOOG();
         // Window Configuration
         computer       = new GameWindow(playerBoard, computerBoard, "computer");
         player         = new GameWindow(computerBoard, playerBoard, "player");
         computer.Title = "BATTLESHIP | Computer";
         player.Title   = "BATTLESHIP | Player";
         computer.Enemy = player;
         player.Enemy   = computer;
         computer.Show();
         player.Show();
     }
 }