public ParticleManagement(Game game, GraphicsDevice graphicsDevice) { // Construct our particle system components. explosionParticles = new ParticleSystem(game, PoseidonGame.contentManager, "ExplosionSettings", graphicsDevice); explosionSmallParticles = new ParticleSystem(game, PoseidonGame.contentManager, "ExplosionSettingsSmall", graphicsDevice); explosionLargeParticles = new ParticleSystem(game, PoseidonGame.contentManager, "ExplosionSettingsLarge", graphicsDevice); sandParticles = new ParticleSystem(game, PoseidonGame.contentManager, "SandSettings", graphicsDevice); sandParticlesForFactory = new ParticleSystem(game, PoseidonGame.contentManager, "SandSettingsForFactory", graphicsDevice); projectileTrailParticles = new ParticleSystem(game, PoseidonGame.contentManager, "ProjectileTrailSettings", graphicsDevice); frozenBreathParticles = new ParticleSystem(game, PoseidonGame.contentManager, "FrozenBreathSettings", graphicsDevice); toxicAirParticles = new ParticleSystem(game, PoseidonGame.contentManager, "ToxicAirSettings", graphicsDevice); sandParticles.DrawOrder = 200; sandParticlesForFactory.DrawOrder = 200; explosionParticles.DrawOrder = 400; explosionSmallParticles.DrawOrder = 400; explosionLargeParticles.DrawOrder = 400; projectileTrailParticles.DrawOrder = 300; frozenBreathParticles.DrawOrder = 400; toxicAirParticles.DrawOrder = 200; explosionParticles.Load(); explosionSmallParticles.Load(); explosionLargeParticles.Load(); sandParticles.Load(); sandParticlesForFactory.Load(); projectileTrailParticles.Load(); frozenBreathParticles.Load(); toxicAirParticles.Load(); }
/// <summary> /// Constructs a new particle emitter object. /// </summary> public ParticleEmitter(ParticleSystem particleSystem, float particlesPerSecond, Vector3 initialPosition) { this.particleSystem = particleSystem; timeBetweenParticles = 1.0f / particlesPerSecond; previousPosition = initialPosition; }
/// <summary> /// Constructs a new projectile. /// </summary> public Projectile(ParticleSystem explosionParticles, ParticleSystem explosionSmokeParticles, ParticleSystem projectileTrailParticles) { this.explosionParticles = explosionParticles; this.explosionSmokeParticles = explosionSmokeParticles; // Start at the origin, firing in a random (but roughly upward) direction. position = Vector3.Zero; velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange; velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; // Use the particle emitter helper to output our trail particles. trailEmitter = new ParticleEmitter(projectileTrailParticles, trailParticlesPerSecond, position); }
public static void updateProjectileHitBot(HydroBot hydroBot, List<DamageBullet> enemyBullets, GameMode gameMode, BaseEnemy[] enemies, int enemiesAmount, ParticleSystem explosionParticles, Camera gameCamera, Fish[] fishes, int fishAmount) { for (int i = 0; i < enemyBullets.Count; ) { if (enemyBullets[i].BoundingSphere.Intersects(hydroBot.BoundingSphere)) { if (!HydroBot.invincibleMode) { HydroBot.currentHitPoint -= enemyBullets[i].damage; if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) PlayGameScene.healthLost += enemyBullets[i].damage; PoseidonGame.audio.botYell.Play(); Point point = new Point(); String point_string = "-" + enemyBullets[i].damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, hydroBot.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } //when auto hipnotize mode is on //whoever hits the bot will be hipnotized if (HydroBot.autoHipnotizeMode) { if (enemyBullets[i].shooter != null && !enemyBullets[i].shooter.isHypnotise) CastSkill.useHypnotise(enemyBullets[i].shooter); } if (HydroBot.autoExplodeMode) { PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(12.5f, .2f); CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, true); } // add particle effect when certain kind of bullet hits if (enemyBullets[i] is Torpedo || enemyBullets[i] is ChasingBullet) { if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(enemyBullets[i].Position, Vector3.Zero); } PoseidonGame.audio.explosionSmall.Play(); } enemyBullets.RemoveAt(i); } else { i++; } } }
// End---------------------------------------------------------- /// <summary> /// PROJECTILES FUNCTION /// </summary> /* scene --> 1-playgamescene, 2-shipwreckscene */ /* switch to use GameMode instead, look at the beginning of PoseidonGame for more details */ public static void updateDamageBulletVsBarriersCollision(List<DamageBullet> bullets, SwimmingObject[] barriers, ref int size, BoundingFrustum cameraFrustum, GameMode gameMode, GameTime gameTime, HydroBot hydroBot, BaseEnemy[] enemies, int enemiesAmount, Fish[] fishes, int fishAmount, Camera gameCamera, ParticleSystem explosionParticles) { BoundingSphere sphere; for (int i = 0; i < bullets.Count; i++) { //special handling for the skill combo FlyingHammer if (bullets[i] is FlyingHammer) { if (PoseidonGame.playTime.TotalSeconds - ((FlyingHammer)bullets[i]).timeShot > 1.25) { ((FlyingHammer)bullets[i]).explodeNow = true; PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(25f, .4f); CastSkill.UseThorHammer(bullets[i].Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, false); } } if (bullets[i] is FlyingHammer) { if (((FlyingHammer)bullets[i]).explodeNow) { bullets.RemoveAt(i--); continue; } } for (int j = 0; j < size; j++) { sphere = barriers[j].BoundingSphere; sphere.Radius *= GameConstants.EasyHitScale; //because Mutant Shark's easy hit sphere is too large if (barriers[j] is MutantShark) sphere.Radius *= 0.7f; if (bullets[i].BoundingSphere.Intersects(sphere)) { if (barriers[j] is Fish && barriers[j].BoundingSphere.Intersects(cameraFrustum)) { PoseidonGame.audio.animalYell.Play(); } if (barriers[j] is BaseEnemy) { //if (((BaseEnemy)barriers[j]).isHypnotise) if (bullets[i].shooter == barriers[j]) { continue; } else { if (bullets[i].shooter == null && !((BaseEnemy)barriers[j]).isHypnotise) { ((BaseEnemy)barriers[j]).justBeingShot = true; ((BaseEnemy)barriers[j]).startChasingTime = PoseidonGame.playTime; } } //special handling for the skill combo FlyingHammer if (bullets[i] is FlyingHammer) { PoseidonGame.audio.bodyHit.Play(); Vector3 oldPosition = barriers[j].Position; Vector3 pushVector = barriers[j].Position - bullets[i].Position; pushVector.Normalize(); ((BaseEnemy)barriers[j]).stunned = true; ((BaseEnemy)barriers[j]).stunnedStartTime = PoseidonGame.playTime.TotalSeconds; ((BaseEnemy)barriers[j]).Position += (pushVector * GameConstants.ThorPushFactor); barriers[j].Position.X = MathHelper.Clamp(barriers[j].Position.X, -hydroBot.MaxRangeX, hydroBot.MaxRangeX); barriers[j].Position.Z = MathHelper.Clamp(barriers[j].Position.Z, -hydroBot.MaxRangeZ, hydroBot.MaxRangeZ); barriers[j].BoundingSphere.Center = barriers[j].Position; if (Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, fishes, fishAmount) || Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, enemies, enemiesAmount)) { barriers[j].Position = oldPosition; barriers[j].BoundingSphere.Center = oldPosition; } } } // add particle effect when certain kind of bullet hits if (bullets[i] is Torpedo || bullets[i] is ChasingBullet) { if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(bullets[i].Position, Vector3.Zero); } PoseidonGame.audio.explosionSmall.Play(); } //whether or not to reduce health of the hit object bool reduceHealth = true; if (bullets[i] is HerculesBullet) { if (!((HerculesBullet)bullets[i]).piercingArrow) reduceHealth = true; else { bool enemyHitBefore = false; foreach (BaseEnemy hitEnemy in ((HerculesBullet)bullets[i]).hitEnemies) { if (hitEnemy == (BaseEnemy)barriers[j]) enemyHitBefore = true; } if (!enemyHitBefore) { reduceHealth = true; ((HerculesBullet)bullets[i]).hitEnemies.Add((BaseEnemy)barriers[j]); } else reduceHealth = false; } } else reduceHealth = true; if (reduceHealth) { barriers[j].health -= bullets[i].damage; if (barriers[j].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "-" + bullets[i].damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, barriers[j].Position, Color.DarkRed); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } //remove the bullet that hits something if (bullets[i] is FlyingHammer) { //if (((FlyingHammer)bullets[i]).explodeNow) bullets.RemoveAt(i--); } //special handling for the skill combo Piercing arrow //pierce through enemies else if (bullets[i] is HerculesBullet) { if (!((HerculesBullet)bullets[i]).piercingArrow) bullets.RemoveAt(i--); } else bullets.RemoveAt(i--); break; } } } }
public static void deleteSmallerThanZero(SwimmingObject[] objs, ref int size, BoundingFrustum cameraFrustum, GameMode gameMode, Cursor cursor, ParticleSystem explosionParticles) { for (int i = 0; i < size; i++) { if (objs[i].health <= 0 && objs[i].gaveExp == false) { // Delete code is below this // This snippet does not include deleting if (objs[i] is SeaCow) { HydroBot.hasSeaCow = false; HydroBot.seaCowPower = 0; HydroBot.iconActivated[IngamePresentation.seaCowIcon] = false; } if (objs[i] is SeaTurtle) { HydroBot.hasTurtle = false; HydroBot.turtlePower = 0; HydroBot.iconActivated[IngamePresentation.turtleIcon] = false; } if (objs[i] is SeaDolphin) { HydroBot.hasDolphin = false; HydroBot.dolphinPower = 0; HydroBot.iconActivated[IngamePresentation.dolphinIcon] = false; } if (objs[i].isBigBoss == true) { if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) { PlayGameScene.isBossKilled = true; PlayGameScene.numBossKills += 1; } else if (gameMode == GameMode.SurvivalMode && objs[i] is Fish) SurvivalGameScene.isAncientKilled = true; } else { if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) { PlayGameScene.numNormalKills += 1; } } if (objs[i] is BaseEnemy) { HydroBot.currentExperiencePts += objs[i].basicExperienceReward; objs[i].gaveExp = true; if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.score += objs[i].basicExperienceReward / 2; if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "+" + objs[i].basicExperienceReward.ToString() + "EXP"; point.LoadContent(PoseidonGame.contentManager, point_string, objs[i].Position, Color.LawnGreen); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } if (!objs[i].isBigBoss) { if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { if (objs[i] is GhostPirate) PoseidonGame.audio.skeletonDie.Play(); else PoseidonGame.audio.hunterYell.Play(); } } else { if (objs[i] is MutantShark) PoseidonGame.audio.mutantSharkYell.Play(); else if (objs[i] is Terminator) PoseidonGame.audio.terminatorYell.Play(); else if (objs[i] is Submarine) { PoseidonGame.audio.Explosion.Play(); if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(objs[i].Position, Vector3.Zero); } } } } if (objs[i] is Fish) { int envLoss; envLoss = GameConstants.envLossForFishDeath; HydroBot.currentEnvPoint -= envLoss; if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "-" + envLoss.ToString() + "ENV"; point.LoadContent(PoseidonGame.contentManager, point_string, objs[i].Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } if (objs[i] == cursor.targetToLock) { cursor.targetToLock = null; //objs[i] = null; } //if we are playing the survival mode //revive the dead enemy instead if (gameMode != GameMode.SurvivalMode || objs[i] is Fish || (objs[i].releasedFromSubmarine)) { objs[i] = null; for (int k = i; k < size - 1; k++) { objs[k] = objs[k + 1]; } objs[--size] = null; } } } }