public void Update(GameTime gameTime) { for (int x = Shots.Count - 1; x >= 0; x--) { Shots[x].Update(gameTime); EffectManager.Effect("NewPulseTracker").Trigger(Shots[x].Center); if (!screenBounds.Intersects(Shots[x].Destination)) { Shots.RemoveAt(x); } } }
public void Update(GameTime gameTime) { for (int x = Shots.Count - 1; x >= 0; x--) { if (enemy) { EffectManager.Effect("Enemy Cannon Fire").Trigger(Shots[x].Center); } else { EffectManager.Effect("Ship Cannon Fire").Trigger(Shots[x].Center); } Shots[x].Update(gameTime); if (!screenBounds.Intersects(Shots[x].Destination)) { Shots.RemoveAt(x); } } }
public void AddExplosion(Vector2 location, Vector2 momentum) { Vector2 pieceLocation = location - new Vector2(pieceRectangles[0].Width / 2, pieceRectangles[0].Height / 2); EffectManager.Effect("BasicExplosionWithTrails2").Trigger(location); int pieces = rand.Next(minPieceCount, maxPieceCount + 1); for (int x = 0; x < pieces; x++) { ExplosionParticles.Add(new Particle( pieceLocation, texture, pieceRectangles[rand.Next(0, pieceRectangles.Count)], randomDirection(pieceSpeedScale) + momentum, Vector2.Zero, explosionMaxSpeed, durationCount, initialColor, finalColor)); } int points = rand.Next(minPointCount, maxPointCount + 1); for (int x = 0; x < points; x++) { ExplosionParticles.Add(new Particle( location, texture, pointRectangle, randomDirection((float)rand.Next( pointSpeedMin, pointSpeedMax)) + momentum, Vector2.Zero, explosionMaxSpeed, durationCount, initialColor, finalColor)); } SoundManager.PlayExplosion(); }
public void Draw(SpriteBatch spriteBatch) { PlayerShotManager.Draw(spriteBatch); if (SheildVisible) { Sheild.Draw(spriteBatch); Sheildbar.Draw(spriteBatch); if (rand.Next(0, 50) == 1) { EffectManager.Effect("ShieldBounce").Trigger(playerSprite.Center); } EffectManager.Effect("ShieldsUp").Trigger(playerSprite.Center); } SheildPowerUP.Draw(spriteBatch); if (!Destroyed) { playerSprite.Draw(spriteBatch); } }
private void checkShotToAsteroidCollisions() { foreach (Sprite shot in playerManager.PlayerShotManager.Shots) { foreach (Sprite asteroid in asteroidManager.Asteroids) { if (shot.IsCircleColliding( asteroid.Center, asteroid.CollisionRadius)) { if (shot.isRocket) { EffectManager.Effect("MeteroidExplode").Trigger(asteroid.Location); asteroid.Location = offScreen; SoundManager.PlayExplosion(); } shot.Location = offScreen; asteroid.Velocity += shotToAsteroidImpact; } } } }
private void checkShotToEnemyCollisions() { foreach (Sprite shot in playerManager.PlayerShotManager.Shots) { foreach (Enemy enemy in enemyManager.Enemies) { if (shot.IsCircleColliding( enemy.EnemySprite.Center, enemy.EnemySprite.CollisionRadius)) { shot.Location = offScreen; enemy.Destroyed = true; playerManager.PlayerScore += enemyPointValue; EffectManager.Effect("BasicExplosion").Trigger(enemy.EnemySprite.Center); /* * explosionManager.AddExplosion( * enemy.EnemySprite.Center, * enemy.EnemySprite.Velocity / 10);*/ } } } }
public void Update(GameTime gameTime) { for (int x = Shots.Count - 1; x >= 0; x--) { Shots[x].Update(gameTime); if (Shots[x].isRocket) { EffectManager.Effect("MeteroidCollision").Trigger(new Vector2(Shots[x].Center.X, Shots[x].Center.Y)); if (Shots[x].tracking > -1) { Vector2 Location = Shots[x].Location; Vector2 target = Enemy.previousLocation; Vector2 vel = target - Location; vel.Normalize(); float dif = Vector2.Distance(target, Shots[x].Location) / 2; float modifier = 100 - dif; vel *= 100 + dif; Vector2 Velocity = vel; Shots[x].Velocity = Velocity; Shots[x].Rotation = (float)Math.Atan2(vel.Y, vel.X); Shots[x].Update(gameTime); } } else { EffectManager.Effect("Enemy Cannon Fire").Trigger(Shots[x].Location); } if (!screenBounds.Intersects(Shots[x].Destination)) { Shots.RemoveAt(x); } } }
public void Update(GameTime gameTime) { PlayerShotManager.Update(gameTime); for (int i = 0; i < 17; i++) { if (PlayerScore > i * 400) { SoundManager.Music[i].Volume = 1f; } } SheildPowerUP.Update(gameTime); SheildRemaining--; String temp = SheildRemaining.ToString(); if (SheildRemaining > 10) { SheildVisible = true; int temp2 = Convert.ToInt32(temp.Substring(0, temp.Length - 1)); Sheildbar.frames[0] = new Rectangle(45, 400, 2, temp2); if (SheildRemaining > 230) { Sheildbar.TintColor = Color.Green; } else { Sheildbar.TintColor = Color.Red; } } else { SheildVisible = false; } if (rand.Next(0, 1000) == 1 && !SheildPowerUP.isVisible && !SheildVisible) { SheildPowerUP.isVisible = true; SheildPowerUP.Location = new Vector2(rand.Next(0, 800), -50); SheildPowerUP.Velocity = new Vector2(0, 100); } if (SheildPowerUP.Location.Y > 700) { SheildPowerUP.Location = new Vector2(0, 0); SheildPowerUP.isVisible = false; } if (SheildPowerUP.IsCircleColliding(playerSprite.Center, playerSprite.CollisionRadius)) { SheildRemaining = 460; SheildPowerUP.Location = new Vector2(0, 0); SheildPowerUP.isVisible = false; } if (!Destroyed) { playerSprite.Velocity = Vector2.Zero; shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; HandleKeyboardInput(Keyboard.GetState()); HandleGamepadInput(GamePad.GetState(PlayerIndex.One)); playerSprite.Velocity.Normalize(); playerSprite.Velocity *= playerSpeed; EffectManager.Effect("ShipSmokeTrail").Trigger(new Vector2(playerSprite.Center.X, playerSprite.Center.Y + 10)); playerSprite.Update(gameTime); imposeMovementLimits(); } }