Beispiel #1
0
 private static void FindDangerousPoints(Bullet bullet)
 {
     double deltaX = (bullet.To.X - bullet.From.X) / 10;
     double deltaY = (bullet.To.Y - bullet.From.Y) / 10;
     double oldDistance = FindDistance(bullet.From, MyFrog.Position);
     Point point = new Point() { X = bullet.From.X + deltaX, Y = bullet.From.Y + deltaY };
     double currentDistance = FindDistance(point, MyFrog.Position);
     if (oldDistance > currentDistance && currentDistance < 30)
     {
         bool dangerousAdded = false;
         while (oldDistance > currentDistance)
         {
             var oldPoint = new Point() { X = point.X, Y = point.Y };
             if (currentDistance < 4.5)
             {
                 Dangerous.Add(oldPoint);
                 dangerousAdded = true;
             }
             oldDistance = currentDistance;
             point.X += deltaX;
             point.Y += deltaY;
             currentDistance = FindDistance(point, MyFrog.Position);
         }
         if (dangerousAdded)
         {
             Dangerous.Add(point);
         }
     }
 }
Beispiel #2
0
 private static void ReadInput()
 {
     Radius = int.Parse(Console.ReadLine());
     string[] lineMyFrog = Console.ReadLine().Split(' ');
     MyFrog = new Frog()
     {
         Position = new Point() { X = double.Parse(lineMyFrog[0]), Y = double.Parse(lineMyFrog[1]) },
         CanShootAfter = int.Parse(lineMyFrog[2])
     };
     string[] lineEnemyFrog = Console.ReadLine().Split(' ');
     EnemyFrog = new Frog()
     {
         Position = new Point() { X = double.Parse(lineEnemyFrog[0]), Y = double.Parse(lineEnemyFrog[1]) },
         CanShootAfter = int.Parse(lineEnemyFrog[2])
     };
     BulletsCount = int.Parse(Console.ReadLine());
     if (BulletsCount > 0)
     {
         Bullets = new Bullet[BulletsCount];
         for (int i = 0; i < BulletsCount; i++)
         {
             string[] line = Console.ReadLine().Split(' ');
             Bullets[i] = new Bullet()
             {
                 From = new Point() { X = double.Parse(line[0]), Y = double.Parse(line[1]) },
                 To = new Point() { X = double.Parse(line[2]), Y = double.Parse(line[3]) }
             };
             FindDangerousPoints(Bullets[i]);
         }
     }
 }