コード例 #1
0
ファイル: Program.cs プロジェクト: DavidParkerDr/TTGNov19
 private static void CheckLaserCollisions()
 {
     for (int laserIndex = Lasers.Count - 1; laserIndex >= 0; laserIndex--)
     {
         for (int fallerIndex = Falling.Count - 1; fallerIndex >= 0; fallerIndex--)
         {
             if (Lasers[laserIndex].Bolt[0].Col == Falling[fallerIndex].Col &&
                 Lasers[laserIndex].Bolt[0].Row == Falling[fallerIndex].Row)
             {
                 score++;
                 if (score % 2 == 0)
                 {
                     if (rng.Next(2) == 1)
                     {
                         spawnTimer.ModifyPeriod(-1);
                     }
                     else
                     {
                         dropTimer.ModifyPeriod(-1);
                     }
                 }
                 for (int i = 0; i < Lasers[laserIndex].Bolt.Length; i++)
                 {
                     Laser l = Lasers[laserIndex];
                     if (l.Bolt[i].Row < board.GetLength(0) && l.Bolt[i].Row >= 0)
                     {
                         board[l.Bolt[i].Row, l.Bolt[i].Col] = background[l.Bolt[i].Row, l.Bolt[i].Col];
                     }
                 }
                 Lasers.RemoveAt(laserIndex);
                 Falling.RemoveAt(fallerIndex);
                 break;
             }
         }
     }
 }