public virtual void Update(GameTime gameTime, Rectangle levelBounds) { switch (_lifeState) { case LifeState.Living: case LifeState.Ghost: { if (Panicked) { _panicTimer -= gameTime.ElapsedGameTime; if (_panicTimer <= TimeSpan.Zero) { _panicTimer = TimeSpan.FromSeconds(PANIC_DIRECTION_CHANGE_FREQUENCY); XnaHelper.RandomizeVector(ref _moveDirection, -1, 1, -1, 1); _lookDirection = _moveDirection; } } lookThisWay(LookDirection); if (MoveDirection.Length() > 0) { moveThisWay(MoveDirection, gameTime); } //handle burning ApplyDamage(_statusEffects.Fire * (float)gameTime.ElapsedGameTime.TotalSeconds * FIRE_DPS); break; } case LifeState.Disabled: case LifeState.Frozen: { if (_statusEffects.Cryo <= 0) { _lifeState = LifeState.Living; //still cold after defrosting _statusEffects.Cryo = MAX_STAT_EFFECT / 2; } break; } case LifeState.Shattered: { for (int y = 0; y < ICE_DIVISIONS; y++) { for (int x = 0; x < ICE_DIVISIONS; x++) { _fragments[x, y].Angle += _fragments[x, y].AngularVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; _fragments[x, y].Position += _fragments[x, y].Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; _fragments[x, y].Velocity += _fragments[x, y].Acceleration * (float)gameTime.ElapsedGameTime.TotalSeconds; _fragments[x, y].Acceleration = Vector2.Zero; _fragments[x, y].Health -= FRAGMENT_MELT_RATE * (float)gameTime.ElapsedGameTime.TotalSeconds; _fragments[x, y].ScaleFactor = _fragments[x, y].Health / FRAGMENT_HEALTH * FRAGMENT_SCALE_FACTOR; XnaHelper.ClampVector(ref _fragments[x, y].Velocity, FRAGMENT_MAX_VELOCITY, out _fragments[x, y].Velocity); if (_fragments[x, y].BeingEaten) { _fragments[x, y].Health -= FRAGMENT_EAT_RATE * (float)gameTime.ElapsedGameTime.TotalSeconds; } } } return; } case LifeState.BeingEaten: { _sprite.ScaleFactor -= BLACK_HOLE_EAT_SCALE_FACTOR * (float)gameTime.ElapsedGameTime.TotalSeconds; if (_sprite.ScaleFactor <= 0) { _lifeState = LifeState.Destroyed; } break; } case LifeState.Destroyed: default: { return; //don't update anything } } stayInBounds(levelBounds.Width, levelBounds.Height); _velocity += _acceleration * (float)gameTime.ElapsedGameTime.TotalSeconds; Position += _velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; controlVelocity(_maxSpeed, gameTime.ElapsedGameTime); _sprite.Angle += _angularVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; LookDirection = Vector2.Zero; MoveDirection = Vector2.Zero; _acceleration = Vector2.Zero; if (_movementParticleEffect != null) { _movementParticleEffect.Update(gameTime); } //burning visual effect _burningParticleEffect.Spawn(Position, 0.0f, gameTime.ElapsedGameTime, _velocity); _burningParticleEffect.IntensityFactor = _statusEffects.Fire / MAX_STAT_EFFECT; _burningParticleEffect.Update(gameTime); //cryo visual effect if (_statusEffects.Cryo > 0 && _lifeState != LifeState.Disabled) { _sprite.Shade = Color.Lerp(Color.White, Color.Blue, _statusEffects.Cryo / MAX_STAT_EFFECT); } _hitRect.X = (int)Position.X - _hitRect.Width / 2; _hitRect.Y = (int)Position.Y - _hitRect.Height / 2; //manage stat effects if (_statusEffects.Cryo >= MAX_STAT_EFFECT && _lifeState != LifeState.Frozen) { _lifeState = LifeState.Frozen; _iceIntegrity = maxHealth * ICE_INTEGRITY_FACTOR; _statusEffects.Fire = 0; //stop burning if frozen } //decrement every stat effect based on status resist _statusEffects -= _statusResist * (float)gameTime.ElapsedGameTime.TotalSeconds; _statusEffects.Clamp(0, MAX_STAT_EFFECT); _sprite.Update(gameTime); }