Пример #1
0
 public bool PlaceShip(int headX, int headY, int tailX, int tailY)
 {
     if (Math.Abs(headX - tailX) == 0)
     {
         for (int i = headY - 1; i <= tailY - 1; i++)
         {
             selfField.markZone(headX - 1, i, Field.ship);
         }
         return(true);
     }
     else if (Math.Abs(headY - tailY) == 0)
     {
         for (int i = headX - 1; i <= tailX - 1; i++)
         {
             selfField.markZone(i, headY - 1, Field.ship);
         }
         return(true);
     }
     return(false);
 }
Пример #2
0
        public bool Shoot(Player enemy, int x, int y)
        {
            x--;
            y--;
            switch (enemy.GetZone(x, y))
            {
            case Field.water:
            case Field.attacked:
            {
                enemy.Miss(x, y);
                enemy.switchTurn();
                switchTurn();
                enemyField.markZone(x, y, Field.attacked);
                //Console.WriteLine("сударь вы KOSOY EBLAN");
                //selfField.PrintGameField(40);
                return(false);
            }

            case Field.ship:
            {
                enemy.Hit(x, y);
                enemyField.markZone(x, y, Field.shotDown);
                Console.WriteLine("сударь вы попали");
                //enemyField.PrintGameField(0);
                //selfField.PrintGameField(40);
                return(true);
            }

            default:
            {
                //enemyField.PrintGameField(0);
                //selfField.PrintGameField(40);
                break;
            }
            }
            return(false);
        }