Esempio n. 1
0
 /// <summary>
 /// Ставит на поле выбранный корабль
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void seaPlayer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (_stateGame == StateGame.PreparationGame)
     {
         if (sender != null)
         {
             var element = (UIElement)e.Source;
             int row     = Grid.GetRow(element);
             int column  = Grid.GetColumn(element);
             if (_shipToggles.CountsOfShips[GetDeckCount()] > 0)
             {
                 if (_seaPlayer.CanShipStayThere(GetDeckCount(), row, column, GetOrientation()))
                 {
                     _seaPlayer.CreateShip(column - 1, row - 1, GetDeckCount(), GetOrientation());
                     _shipToggles.dicShipCount(GetDeckCount());
                     messageTextBlock.Text = "";
                 }
                 else
                 {
                     if (row > 0 && column > 0)
                     {
                         messageTextBlock.Text = "В это место корабль поставить нельзя!";
                     }
                 }
             }
             else
             {
                 messageTextBlock.Text = "Превышено количество кораблей";
             }
         }
     }
 }