public PowerUp(char[] image, PlayerShip ship) { double tempPosX = Program.rnd.NextDouble(); if (tempPosX < 0.1) { tempPosX += 0.1; } else if (tempPosX > 0.9) { tempPosX -= 0.1; } position.X = tempPosX; position.Y = 0; previousPosition.X = tempPosX - 1; previousPosition.Y = 0; velocity.X = 0; velocity.Y = 0.002; maxVelocity = 0.01; size = 0.0125 * 3; this.image = image; double value = Program.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'; } }
static public List <Bullet> Fire(MovingObject ship) { List <Bullet> backFire = new List <Bullet>(); if (ship.GetType() == typeof(PlayerShip)) { PlayerShip pShip = (PlayerShip)ship; Position bulletPosition = new Position(ship.getPosition(), 0, 0 - (ship.getSize() + 0.0125) / 2); int bulletCount = pShip.getMultipleBullets(); if (bulletCount >= 1) { backFire.Add(new Bullet(bulletPosition, new Velocity(0, -0.01), pShip.getPower(), '|')); } if (bulletCount >= 2) { backFire.Add(new Bullet(bulletPosition, new Velocity(-0.007, -0.007), pShip.getPower(), '\\')); } if (bulletCount >= 3) { backFire.Add(new Bullet(bulletPosition, new Velocity(0.007, -0.007), pShip.getPower(), '/')); } if (bulletCount >= 4) { backFire.Add(new Bullet(bulletPosition, new Velocity(0.01, 0), pShip.getPower(), '¯')); } if (bulletCount >= 5) { backFire.Add(new Bullet(bulletPosition, new Velocity(-0.01, 0), pShip.getPower(), '¯')); } } else { EnemyShip pShip = (EnemyShip)ship; Position bulletPosition = new Position(ship.getPosition(), 0, (ship.getSize() + 0.0125) / 2); backFire.Add(new Bullet(bulletPosition, new Velocity(0, 0.01), 1, '|')); } return(backFire); }