/// <summary> /// Factory method for spawning a projectile /// </summary> /// <param name="projectileType">The type of projectile to create</param> /// <param name="position">The position of the projectile in the game world</param> /// <returns>The game object id of the projectile</returns> public Projectile CreateProjectile(ProjectileType projectileType, Vector2 position, Vector2 velocity) { Projectile projectile = null; uint id = NextID(); switch (projectileType) { case ProjectileType.Bullet: projectile = new Bullet(id, content, position); break; case ProjectileType.Fireball: projectile = new Fireball(id, content, position); break; case ProjectileType.BubbleBullet: projectile = new BubbleBullet(id, content, position); break; case ProjectileType.Bomb: projectile = new Bomb(id, content, position, true); break; case ProjectileType.Blades: projectile = new Blades(id, content); break; case ProjectileType.DroneLaser: projectile = new DroneLaser(id, content, position); break; case ProjectileType.ToPlayerBullet: projectile = new ToPlayerBullet(id, content, position); break; case ProjectileType.ArrowProjectile: projectile = new ArrowProjectile(id, content, position); break; case ProjectileType.BirdCrap: projectile = new BirdCrap(id, content, position); break; case ProjectileType.EBullet: projectile = new EBullet(id, content, position); break; case ProjectileType.Frostball: projectile = new Frostball(id, content, position); break; case ProjectileType.BlueBeam: projectile = new blueBeam(id, content, position); break; //This method doesn't fit the trishield very well, so this code is a bit poor in quality. case ProjectileType.TrishieldBall: for (int i = 0; i < 2; i++) { projectile = new TriShieldBall(id, content, 2 * MathHelper.Pi / 3 * i); QueueGameObjectForCreation(projectile); id = NextID(); } projectile = new TriShieldBall(id, content, 4 * MathHelper.Pi / 3); break; case ProjectileType.GenericEnemyBullet: projectile = new GenericEnemyBullet(id, content, position); break; case ProjectileType.DroneWave: // waveIndex helps draw the wave to the left and right of the ship, while waveSpacing holds the vector difference of space between each drone. // Drone count is managed by 2*i. Vector2 waveIndex = new Vector2(-1, 1); Vector2 waveSpacing = new Vector2(40,30); for (int i = 0; i < 5; i++) { projectile = new DroneWave(id, content, position + waveSpacing * waveIndex * i); QueueGameObjectForCreation(projectile); id = NextID(); projectile = new DroneWave(id, content, position + waveSpacing * i); QueueGameObjectForCreation(projectile); id = NextID(); } break; case ProjectileType.TurretFireball: projectile = new TurretFireball(id, content, position); break; case ProjectileType.JetMinionBullet: projectile = new JetMinionBullet(id, content, position); break; case ProjectileType.EnergyBlast: projectile = new EnergyBlast(id, content, position, ScrollingShooterGame.Game.Player.energyBlastLevel); break; case ProjectileType.EnemyBullet: // Bullet velocity float bulletVel = 200f; //ScrollingShooterGame.Game.projectiles.Add(new EnemyBullet(ScrollingShooterGame.Game.Content, this.position + offset, bulletVel * toPlayer)); Vector2 toPlayer = (new Vector2(ScrollingShooterGame.Game.Player.Bounds.Center.X, ScrollingShooterGame.Game.Player.Bounds.Center.Y) - position); toPlayer.Normalize(); projectile = new EnemyBullet(id, content, position, bulletVel * toPlayer); break; case ProjectileType.EnemyBomb: projectile = new Bomb(id, content, position, false); break; case ProjectileType.ShotgunBullet: projectile = new ShotgunBullet(id, content, position, BulletDirection.Straight); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Left)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Right)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardLeft)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardRight)); break; case ProjectileType.BlimpShotgun: projectile = new BlimpShotgun(id, content, position, BulletDirection.Straight); QueueGameObjectForCreation(new BlimpShotgun(NextID(), content, position, BulletDirection.Left)); QueueGameObjectForCreation(new BlimpShotgun(NextID(), content, position, BulletDirection.Right)); QueueGameObjectForCreation(new BlimpShotgun(NextID(), content, position, BulletDirection.HardLeft)); QueueGameObjectForCreation(new BlimpShotgun(NextID(), content, position, BulletDirection.HardRight)); break; case ProjectileType.Meteor: projectile = new Meteor(id, content, position); break; case ProjectileType.BigMeteor: projectile = new BigMeteor(id, content, position); break; case ProjectileType.EnemyFlameball: projectile = new EnemyFlameball(id, content, position); break; case ProjectileType.RGSabot: projectile = new RGSabot(id, content, position); break; case ProjectileType.BlimpBullet: projectile = new BlimpBullet(id, content, position); break; case ProjectileType.BirdWrath: projectile = new BirdWrath(id, content, position); break; case ProjectileType.FreezewaveProjectile: projectile = new FreezewaveProjectile(id, content, position); break; case ProjectileType.Photon: projectile = new Photon(id, content, position); break; case ProjectileType.Pincher: projectile = new Pincher(id, content, position); break; case ProjectileType.GreenOrb: projectile = new GreenOrb(id, content, position); break; case ProjectileType.AlienTurretOrb: projectile = new AlienTurretOrb(id, content, position); break; case ProjectileType.TwinJetMissile: projectile = new Boss_TwinJetMissile(id, content, position); break; case ProjectileType.TwinJetBullet: projectile = new Boss_TwinJetBullet(id, content, position); break; case ProjectileType.HomingMissile: projectile = new HomingMissileProjectile(content, position, 1, id); break; case ProjectileType.EnemyPsyBall: projectile = new EnemyPsiBall(id, content, position); break; case ProjectileType.EnemyLightningZap: projectile = new EnemyLightningZap(id, content, position); break; default: throw new NotImplementedException("The projectile type " + Enum.GetName(typeof(ProjectileType), projectileType) + " is not supported"); } if ((int)projectileType < 100) projectile.ObjectType = ObjectType.PlayerProjectile; else projectile.ObjectType = ObjectType.EnemyProjectile; QueueGameObjectForCreation(projectile); return projectile; }
/// <summary> /// Factory method for spawning a projectile /// </summary> /// <param name="projectileType">The type of projectile to create</param> /// <param name="position">The position of the projectile in the game world</param> /// <returns>The game object id of the projectile</returns> public Projectile CreateProjectile(ProjectileType projectileType, Vector2 position) { Projectile projectile; uint id = NextID(); switch (projectileType) { case ProjectileType.Bullet: projectile = new Bullet(id, content, position); break; case ProjectileType.Fireball: projectile = new Fireball(id, content, position); break; case ProjectileType.BubbleBullet: projectile = new BubbleBullet(id, content, position); break; case ProjectileType.Bomb: projectile = new Bomb(id, content, position, true); break; case ProjectileType.Blades: projectile = new Blades(id, content); break; case ProjectileType.DroneLaser: projectile = new DroneLaser(id, content, position); break; case ProjectileType.ToPlayerBullet: projectile = new ToPlayerBullet(id, content, position); break; case ProjectileType.ArrowProjectile: projectile = new ArrowProjectile(id, content, position); break; case ProjectileType.BirdCrap: projectile = new BirdCrap(id, content, position); break; case ProjectileType.EBullet: projectile = new EBullet(id, content, position); break; case ProjectileType.Frostball: projectile = new Frostball(id, content, position); break; case ProjectileType.BlueBeam: projectile = new blueBeam(id, content, position); break; //This method doesn't fit the trishield very well, so this code is a bit poor in quality. case ProjectileType.TrishieldBall: for (int i = 0; i < 2; i++) { projectile = new TriShieldBall(id, content, 2 * MathHelper.Pi / 3 * i); QueueGameObjectForCreation(projectile); id = NextID(); } projectile = new TriShieldBall(id, content, 4 * MathHelper.Pi / 3); break; case ProjectileType.GenericEnemyBullet: projectile = new GenericEnemyBullet(id, content, position); break; case ProjectileType.DroneWave: // waveIndex helps draw the wave to the left and right of the ship, while waveSpacing holds the vector difference of space between each drone. // Drone count is managed by 2*i. Vector2 waveIndex = new Vector2(-1, 1); Vector2 waveSpacing = new Vector2(40, 30); for (int i = 0; i < 5; i++) { projectile = new DroneWave(id, content, position + waveSpacing * waveIndex * i); QueueGameObjectForCreation(projectile); id = NextID(); projectile = new DroneWave(id, content, position + waveSpacing * i); QueueGameObjectForCreation(projectile); id = NextID(); } projectile = new DroneWave(id, content, position + waveSpacing * waveIndex * 6); QueueGameObjectForCreation(projectile); id = NextID(); projectile = new DroneWave(id, content, position + waveSpacing * 6); break; case ProjectileType.TurretFireball: projectile = new TurretFireball(id, content, position); break; case ProjectileType.JetMinionBullet: projectile = new JetMinionBullet(id, content, position); break; case ProjectileType.EnergyBlast: projectile = new EnergyBlast(id, content, position, ScrollingShooterGame.Game.Player.energyBlastLevel); break; case ProjectileType.EnemyBullet: // Bullet velocity float bulletVel = 200f; //ScrollingShooterGame.Game.projectiles.Add(new EnemyBullet(ScrollingShooterGame.Game.Content, this.position + offset, bulletVel * toPlayer)); Vector2 toPlayer = (new Vector2(ScrollingShooterGame.Game.Player.Bounds.Center.X, ScrollingShooterGame.Game.Player.Bounds.Center.Y) - position); toPlayer.Normalize(); projectile = new EnemyBullet(id, content, position, bulletVel * toPlayer); break; case ProjectileType.EnemyBomb: projectile = new Bomb(id, content, position, false); break; case ProjectileType.ShotgunBullet: projectile = new ShotgunBullet(id, content, position, BulletDirection.Straight); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Left)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Right)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardLeft)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardRight)); break; case ProjectileType.Meteor: projectile = new Meteor(id, content, position); break; case ProjectileType.BigMeteor: projectile = new BigMeteor(id, content, position); break; case ProjectileType.EnemyFlameball: projectile = new EnemyFlameball(id, content, position); break; case ProjectileType.RGSabot: projectile = new RGSabot(id, content, position); break; case ProjectileType.Photon: projectile = new Photon(id, content, position); break; default: throw new NotImplementedException("The projectile type " + Enum.GetName(typeof(ProjectileType), projectileType) + " is not supported"); } QueueGameObjectForCreation(projectile); return(projectile); }
/// <summary> /// Factory method for spawning a projectile /// </summary> /// <param name="projectileType">The type of projectile to create</param> /// <param name="position">The position of the projectile in the game world</param> /// <returns>The game object id of the projectile</returns> public Projectile CreateProjectile(ProjectileType projectileType, Vector2 position) { Projectile projectile; uint id = NextID(); switch (projectileType) { case ProjectileType.Bullet: projectile = new Bullet(id, content, position); break; case ProjectileType.Fireball: projectile = new Fireball(id, content, position); break; default: throw new NotImplementedException("The projectile type " + Enum.GetName(typeof(ProjectileType), projectileType) + " is not supported"); } QueueGameObjectForCreation(projectile); return projectile; }
/// <summary> /// Factory method for spawning a projectile /// </summary> /// <param name="projectileType">The type of projectile to create</param> /// <param name="position">The position of the projectile in the game world</param> /// <returns>The game object id of the projectile</returns> public Projectile CreateProjectile(ProjectileType projectileType, Vector2 position, Vector2 velocity) { Projectile projectile; uint id = NextID(); switch (projectileType) { case ProjectileType.Bullet: projectile = new Bullet(id, content, position); break; case ProjectileType.Fireball: projectile = new Fireball(id, content, position); break; case ProjectileType.BubbleBullet: projectile = new BubbleBullet(id, content, position); break; case ProjectileType.Bomb: projectile = new Bomb(id, content, position, true); break; case ProjectileType.Blades: projectile = new Blades(id, content); break; case ProjectileType.DroneLaser: projectile = new DroneLaser(id, content, position); break; case ProjectileType.ToPlayerBullet: projectile = new ToPlayerBullet(id, content, position); break; case ProjectileType.ArrowProjectile: projectile = new ArrowProjectile(id, content, position); break; case ProjectileType.BirdCrap: projectile = new BirdCrap(id, content, position); break; case ProjectileType.EBullet: projectile = new EBullet(id, content, position); break; case ProjectileType.Frostball: projectile = new Frostball(id, content, position); break; case ProjectileType.BlueBeam: projectile = new blueBeam(id, content, position); break; //This method doesn't fit the trishield very well, so this code is a bit poor in quality. case ProjectileType.TrishieldBall: for (int i = 0; i < 2; i++) { projectile = new TriShieldBall(id, content, 2 * MathHelper.Pi / 3 * i); QueueGameObjectForCreation(projectile); id = NextID(); } projectile = new TriShieldBall(id, content, 4 * MathHelper.Pi / 3); break; case ProjectileType.GenericEnemyBullet: projectile = new GenericEnemyBullet(id, content, position); break; case ProjectileType.DroneWave: // waveIndex helps draw the wave to the left and right of the ship, while waveSpacing holds the vector difference of space between each drone. // Drone count is managed by 2*i. Vector2 waveIndex = new Vector2(-1, 1); Vector2 waveSpacing = new Vector2(40, 30); for (int i = 0; i < 5; i++) { projectile = new DroneWave(id, content, position + waveSpacing * waveIndex * i); QueueGameObjectForCreation(projectile); id = NextID(); projectile = new DroneWave(id, content, position + waveSpacing * i); QueueGameObjectForCreation(projectile); id = NextID(); } projectile = new DroneWave(id, content, position + waveSpacing * waveIndex * 6); QueueGameObjectForCreation(projectile); id = NextID(); projectile = new DroneWave(id, content, position + waveSpacing * 6); break; case ProjectileType.TurretFireball: projectile = new TurretFireball(id, content, position); break; case ProjectileType.JetMinionBullet: projectile = new JetMinionBullet(id, content, position); break; case ProjectileType.EnergyBlast: projectile = new EnergyBlast(id, content, position, (int)velocity.X); break; case ProjectileType.EnemyBullet: projectile = new EnemyBullet(id, content, position, velocity); break; case ProjectileType.EnemyTurretTowerBullet: projectile = new EnemyTurretTowerBullet(id, content, position, velocity); break; case ProjectileType.EnemyBomb: projectile = new Bomb(id, content, position, false); break; case ProjectileType.ShotgunBullet: projectile = new ShotgunBullet(id, content, position, BulletDirection.Straight); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Left)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.Right)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardLeft)); QueueGameObjectForCreation(new ShotgunBullet(NextID(), content, position, BulletDirection.HardRight)); break; case ProjectileType.Meteor: projectile = new Meteor(id, content, position); break; case ProjectileType.BigMeteor: projectile = new BigMeteor(id, content, position); break; case ProjectileType.EnemyFlameball: projectile = new EnemyFlameball(id, content, position); break; case ProjectileType.RGSabot: projectile = new RGSabot(id, content, position); break; default: throw new NotImplementedException("The projectile type " + Enum.GetName(typeof(ProjectileType), projectileType) + " is not supported"); } // Set the objectType to player or enemy projectile depending on enum value int type = (int)projectileType; if (type < 100) projectile.objectType = ObjectType.playerProjectile; else projectile.objectType = ObjectType.enemyProjectile; QueueGameObjectForCreation(projectile); return projectile; }