示例#1
0
 private void FireThreeShooter()
 {
     if (
         threeShooter == null &&
         hero.HasAmmo(Weapon.WeaponTypes.THREE_SHOOTER)
         )
     {
         threeShooter = new ThreeShooter(this.hero.X, this.hero.Y - 2);
         hero.SubtractAmmo(Weapon.WeaponTypes.THREE_SHOOTER);
     }
 }
示例#2
0
        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();
                    }
                }
            }
        }