public void Draw(Renderer renderer, float deltaSeconds) { CrossAnimation.Update(deltaSeconds); foreach (SpriteAnimationInstance anim in DigitAnimations) { anim.Update(deltaSeconds); } foreach (SpriteAnimationInstance anim in KeyAnimations) { anim.Update(deltaSeconds); } if (HealthIconAnimation != null) { HealthIconAnimation.Update(deltaSeconds); int hp = Owliver.Health.MaxHealth; SpatialData spatial = HealthIconAnchor.GetWorldSpatialData(); const float spacing = 3; for (int healthIndex = 0; healthIndex < hp; healthIndex++) { Color tint = healthIndex < Owliver.Health.CurrentHealth ? FullHealthTint : NoHealthTint; HealthIconAnimation.Draw(renderer, spatial.GetWorldSpatialData(), tint: tint); spatial.Position.X += HealthIconAnimation.ScaledDim.X + spacing; } } if (Owliver.MoneyBag != null) { MoneyBagIconAnimation.Update(deltaSeconds); SpatialData spatial = MoneyBagIconAnchor.GetWorldSpatialData(); MoneyBagIconAnimation.Draw(renderer, MoneyBagIconAnchor); const float spacing = 3; float previousAnimWidth = MoneyBagIconAnimation.ScaledDim.X; spatial.Position.X -= 0.5f * CrossAnimation.ScaledDim.X + 0.5f * previousAnimWidth + spacing; CrossAnimation.Draw(renderer, spatial); previousAnimWidth = CrossAnimation.ScaledDim.X; int value = Owliver.MoneyBag.CurrentAmount; while (true) { int digit = value % 10; SpriteAnimationInstance digitAnim = DigitAnimations[digit]; spatial.Position.X -= 0.5f * previousAnimWidth + 0.5f * digitAnim.ScaledDim.X + spacing; digitAnim.Draw(renderer, spatial); value /= 10; if (value == 0) { break; } previousAnimWidth = digitAnim.ScaledDim.X; } } if (Owliver.KeyRing != null) { SpatialData anchor = KeyRingAnchor.GetWorldSpatialData(); for (int keyTypeIndex = 0; keyTypeIndex < (int)KeyType.COUNT; keyTypeIndex++) { KeyType keyType = (KeyType)keyTypeIndex; int keyAmount = Owliver.KeyRing[keyType]; SpriteAnimationInstance keyAnim = KeyAnimations[keyTypeIndex]; SpatialData spatial = anchor.GetWorldSpatialData(); for (int keyIndex = 0; keyIndex < keyAmount; keyIndex++) { keyAnim.Draw(renderer, spatial); spatial.Position.X += 0.6f * keyAnim.ScaledDim.X; } anchor.Position.Y += 0.8f * keyAnim.ScaledDim.Y; } } }
public override void Update(float deltaSeconds) { base.Update(deltaSeconds); HealthIcon.Update(deltaSeconds); }