private void UpdateTorpedo() { if (torpedo != null) { torpedo.Y = torpedo.Y - torpedo.speed; if (torpedo.Y < 1) { torpedo = null; return; } BoxEnemy collidedWith = SpaceHasEnemy(torpedo.X, torpedo.Y); if (collidedWith != null) { torpedo = null; enemies.Remove(collidedWith); score += collidedWith.Value; sound.PlayEnemyDeathSound(); if (rand.Next(1, 21) == rand.Next(1, 21)) { SpawnLoot(collidedWith.X, collidedWith.Y); } } } }
private void UpdateThreeShooter() { if (threeShooter != null) { // if a threeshooter hits someone, // contemplate if it's smarter to replace the value // in the list with a null value for (int i = 0; i < threeShooter.Torpedos.Count; i++) { if (threeShooter.Torpedos[i] == null) { continue; } threeShooter.Torpedos[i].Y -= threeShooter.Torpedos[i].speed; if (i == 0) { threeShooter.Torpedos[i].X += threeShooter.Torpedos[i].speed; } else if (i == (threeShooter.Torpedos.Count - 1)) { Console.WriteLine(threeShooter.Torpedos.Count.ToString()); threeShooter.Torpedos[i].X -= threeShooter.Torpedos[i].speed; } if (threeShooter.Torpedos[i].Y < 1) { threeShooter = null; return; } BoxEnemy collidedWith = SpaceHasEnemy(threeShooter.Torpedos[i].X, threeShooter.Torpedos[i].Y); if (collidedWith != null) { threeShooter.Torpedos.Insert(i, null); enemies.Remove(collidedWith); score += collidedWith.Value; sound.PlayEnemyDeathSound(); } } } }