public PowerUp(IPlayerShip ship) { name = ScreenView.objectName.EPowerUp; size = 0.0125 * 3; double tempPosX = ScreenView.rnd.NextDouble(); if (tempPosX < 0.1) { tempPosX += 0.1; } else if (tempPosX > 0.9) { tempPosX -= 0.1; } position.X = tempPosX; position.Y = 0 - size; previousPosition.X = position.X; previousPosition.Y = position.Y; velocity.X = 0; velocity.Y = 0.002; maxVelocity = 0.01; double value = ScreenView.rnd.NextDouble(); if (value < 0.2) { shape = 'S'; } else if (value < 0.5) { if (ship.getMultipleBullets() < 5) { shape = 'M'; } else { shape = 'P'; } } else if (value < 0.8) { shape = 'F'; } else if (value <= 1) { shape = 'P'; } }
public static void playerShot(IPlayerShip ship) { Vector bulletPosition = new Vector(ship.getPosition(), 0, 0 - (ship.getSize() + 0.0125) / 2); int bulletCount = ship.getMultipleBullets(); Console.Out.WriteLine("Bullet count = " + bulletCount); Console.Out.WriteLine("Firerate = " + ship.getFirerate()); Console.Out.WriteLine("Power = " + ship.getPower()); Console.Out.WriteLine("Velocity = " + ship.getVelocity().X + ", " + ship.getVelocity().Y); if (bulletCount >= 1) { PlayerBullet b = new PlayerBullet(bulletPosition, new Vector(0, -0.01), ship.getPower(), '1'); b.setStrategy(ScreenView.MSStraight); playerBulletList.Add(b); } if (bulletCount >= 2) { PlayerBullet b = new PlayerBullet(bulletPosition, new Vector(-0.007, -0.007), ship.getPower(), '2'); b.setStrategy(ScreenView.MSStraight); playerBulletList.Add(b); } if (bulletCount >= 3) { PlayerBullet b = new PlayerBullet(bulletPosition, new Vector(0.007, -0.007), ship.getPower(), '3'); b.setStrategy(ScreenView.MSStraight); playerBulletList.Add(b); } if (bulletCount >= 4) { PlayerBullet b = new PlayerBullet(bulletPosition, new Vector(0.01, 0), ship.getPower(), '4'); b.setStrategy(ScreenView.MSStraight); playerBulletList.Add(b); } if (bulletCount >= 5) { PlayerBullet b = new PlayerBullet(bulletPosition, new Vector(-0.01, 0), ship.getPower(), '5'); b.setStrategy(ScreenView.MSStraight); playerBulletList.Add(b); } }