public override void Update(GameTime gameTime, Map gameMap) { Speed.Y += GRAVITY; Speed.X = FaceDir; _idleAnim.Update(gameTime); _runAnim.Update(gameTime); Life--; if (Life <= 0) { Active = false; } CheckMapCollisions(gameMap); _tint = Color.White; base.Update(gameTime, gameMap); }
public override void Update(GameTime gameTime, Map gameMap) { if (_hitAlpha > 0f) { _hitAlpha -= 0.1f; } _idleAnim.Update(gameTime); _hitAnim.Update(gameTime); if (!(this is Gorger) && !(this is Lunger) && !(this is Flyer) && !(this is Boss)) { if (Speed.X <= 0f) { _faceDir = -1; } else { _faceDir = 1; } } if (!(this is Boss)) { CheckMapCollisions(gameMap); } if (Life <= 0f) { Die(); } if (Position.Y > (gameMap.Height * gameMap.TileHeight)) { Die(); } if (_underWater) { if (Position.Y < 260) { AudioController.PlaySFX("water_leave", 1f, -0.1f, 0.1f, Camera.Instance, Position); _underWater = false; for (int i = 0; i < 30; i++) { Vector2 pos = new Vector2(Helper.RandomFloat(-5f, 5f), 0f); Color col = Color.Lerp(new Color(0, 81, 147), new Color(211, 234, 254), Helper.RandomFloat(0f, 1f)); ParticleController.Instance.Add(Position + pos, (pos * 0.1f) + new Vector2(Speed.X, Speed.Y * Helper.RandomFloat(0.25f, 2f)), 0, 2000, 500, true, true, new Rectangle(0, 0, 3, 3), col, particle => { ParticleFunctions.FadeInOut(particle); if (particle.Position.Y > 260) { particle.State = ParticleState.Done; } }, 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 1, ParticleBlend.Alpha); } } } else if (Position.Y > 260) { _underWater = true; AudioController.PlaySFX("water_enter", 1f, -0.1f, 0.1f, Camera.Instance, Position); } base.Update(gameTime, gameMap); }
public override void Update(GameTime gameTime, Map gameMap) { if (!Active) { Speed = Vector2.Zero; return; } //Vector2 screenPos = Vector2.Transform(Position, Camera.Instance.CameraMatrix); //engineLoop.Pan = (screenPos.X - (Camera.Instance.Width / 2f)) / (Camera.Instance.Width / 2f); //gunLoop.Pan = (screenPos.X - (Camera.Instance.Width / 2f)) / (Camera.Instance.Width / 2f); projectileTime1 -= gameTime.ElapsedGameTime.TotalMilliseconds; projectileTime2 -= gameTime.ElapsedGameTime.TotalMilliseconds; projectileTime3 -= gameTime.ElapsedGameTime.TotalMilliseconds; Position.Y = MathHelper.Clamp(Position.Y, 16, (gameMap.Height * gameMap.TileHeight) - 16); _idleAnim.Update(gameTime); _upAnim.Update(gameTime); _downAnim.Update(gameTime); _idleHitAnim.Update(gameTime); _upHitAnim.Update(gameTime); _downHitAnim.Update(gameTime); CheckMapCollisions(gameMap); Speed.X = MathHelper.Clamp(Speed.X, -5f, 5f); Speed.Y = MathHelper.Clamp(Speed.Y, -1.5f, 1.5f); if (_hitAlpha > 0f) { _hitAlpha -= 0.02f; } if (Life <= 0f) { Die(); } if (_powerUpText > 0f) { _powerUpText -= 0.01f; } if (PowerUpMeter >= 20 && PowerUpLevel < 4) { AudioController.PlaySFX("powerup", 1f, 0f, 0f); _powerUpText = 1f; PowerUpLevel++; if (PowerUpLevel < 4) { PowerUpMeter = PowerUpMeter - 20; } } Life = MathHelper.Clamp(Life, 0f, 100f); MultiplierTime -= gameTime.ElapsedGameTime.TotalMilliseconds; if (MultiplierTime <= 0f && Multiplier > 1) { MultiplierTime = 1000; Multiplier--; AudioController.PlaySFX("combo_down", 0.5f, -0.8f + (0.2f * (Multiplier - 1f)), -0.8f + (0.2f * (Multiplier - 1f))); } base.Update(gameTime, gameMap); }