public void Draw(float currentHealth, IMeterRenderer meterRenderer, SpriteBatch spritebatch, bool flip = false) { if (!IsVisible) { return; } CurrentHP = currentHealth; meterRenderer.DrawBorder(this, spritebatch, Position, Vector2.One, Vector2.Zero, Color.White, flip); if (HealTimer.HasTimeRemaining) { //If the character is being healed, draw in heal mode //how much health bar to draw? var healingHealthBar = PreHealAmount + ((CurrentHP - PreHealAmount) * (1f - HealTimer.Lerp)); var healingAlpha = ConvertToAlpha(0, MaxHP, healingHealthBar); //how much pulsate to add to hp bar? var pulsate = PulsateScale(HealTimer.CurrentTime * HealPulsateSpeed, HealScaleAmount, Position); //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip); //draw the healing part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, healingAlpha, currentAlpha, Vector2.One, Vector2.Zero, GetHealingColor(), flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, healingAlpha, Vector2.One, Vector2.Zero, GetHealColor(), flip); meterRenderer.DrawMeter(this, spritebatch, Position, 0f, healingAlpha, pulsate, Vector2.Zero, GetHealColor(), flip); } else if (HitTimer.HasTimeRemaining) { //else if the character is being hit, draw in hit mode //how much pulsate to add to hp bar? var healthPulsate = PulsateScale(HitTimer.CurrentTime * HitShakeSpeed, HitHealthScaleAmount, Position); //how much offset to add to health bar? var healthOffset = OffsetVector(HitTimer.CurrentTime * HitShakeSpeed, HitHealthOffsetAmount); //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP); //what is the alpha of the current HP? var damageAlpha = ConvertToAlpha(0, MaxHP, PreDamageAmount); //how much pulsate to add to damage bar? var damagePulsate = PulsateScale(HitTimer.CurrentTime * HitShakeSpeed, HitDepletedHealthScaleAmount, Position); //how much offset to add to health bar? var damageOffset = OffsetVector(HitTimer.CurrentTime * HitShakeSpeed, HitDepletedHealthOffsetAmount); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, healthOffset, DepletedHealthColor, flip); //draw the damage bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, damageAlpha, damagePulsate, damageOffset, GetHitDepletedHealthColor(), flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, healthPulsate, healthOffset, GetHitHealthColor(), flip); } else if (!NearDeathClock.Paused) { //else if the character is near-death, draw in near-death mode //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetNearDeathColor(), flip); } else { //otherwise draw the health bar normal //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxHP, CurrentHP); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, DepletedHealthColor, flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetHealthColor(), flip); } }
public void Draw(float currentHealth, IMeterRenderer meterRenderer, SpriteBatch spritebatch, bool flip = false) { if (!IsVisible) { return; } CurrentMP = currentHealth; meterRenderer.DrawBorder(this, spritebatch, Position, Vector2.One, Vector2.Zero, Color.White, flip); if (UseManaTimer.HasTimeRemaining) { //else if the character is being hit, draw in hit mode //how much pulsate to add to hp bar? var healthPulsate = PulsateScale(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseManaScaleAmount, Position); //how much offset to add to health bar? var healthOffset = OffsetVector(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseManaOffsetAmount); //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxMP, CurrentMP); //what is the alpha of the current HP? var damageAlpha = ConvertToAlpha(0, MaxMP, PreUseManaAmount); //how much pulsate to add to damage bar? var damagePulsate = PulsateScale(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseDepletedManaScaleAmount, Position); //how much offset to add to health bar? var damageOffset = OffsetVector(UseManaTimer.CurrentTime * InUseShakeSpeed, InUseDepletedManaOffsetAmount); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, healthOffset, EmptyManaColor, flip); //draw the damage bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, damageAlpha, damagePulsate, damageOffset, GetInUseManaDepletedColor(), flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, healthPulsate, healthOffset, GetInUseManaColor(), flip); } else if (!ManaFullClock.Paused) { //else if the energy is full, draw in FullEnergy mode //how much pulsate to add to hp bar? var pulsate = PulsateScale(ManaFullClock.CurrentTime * ManaFullPulsateSpeed, ManaFullScaleAmount, Position); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, 1f, pulsate, Vector2.Zero, GetManaFullColor(), flip); } else { //otherwise draw the health bar normal //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxMP, CurrentMP); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, Position, currentAlpha, 1f, Vector2.One, Vector2.Zero, EmptyManaColor, flip); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, Position, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetManaColor(), flip); } }
public void Draw(float currentTime, IMeterRenderer meterRenderer, SpriteBatch spritebatch) { if (!IsVisible) { return; } CurrentTime = currentTime; var correctedPosition = GetShakyRectangle(); if (IsNearEndMode) { //else if the character is near-death, draw in near-death mode //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime); //how much pulsate to add to hp bar? var pulsate = PulsateScale(TimeClock.CurrentTime * NearEndPulsateSpeed, NearEndPulsateAmount, correctedPosition); //draw the border meterRenderer.DrawBorder(this, spritebatch, correctedPosition, pulsate, Vector2.Zero, Color.White); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, pulsate, Vector2.Zero, DepletedTimeColor); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, pulsate, Vector2.Zero, GetNearEndTimeColor()); } else if (CurrentTime <= 0f) { //otherwise draw the health bar normal //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime); //how much pulsate to add to hp bar? var pulsate = PulsateScale(TimeClock.CurrentTime * NearEndPulsateSpeed, NearEndPulsateAmount * 0.5f, correctedPosition); //draw the border meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, Vector2.Zero, Color.White); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, pulsate, Vector2.Zero, GetTimeOutColor()); } else { //otherwise draw the health bar normal //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxTime, CurrentTime); //draw the border meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, Vector2.Zero, Color.White); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, Vector2.One, Vector2.Zero, DepletedTimeColor); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, Vector2.One, Vector2.Zero, GetTimeColor()); } }
public void Draw(float currentEnergy, IMeterRenderer meterRenderer, SpriteBatch spritebatch) { if (!IsVisible) { return; } CurrentEnergy = currentEnergy; var correctedPosition = GetNopedRectangle(); //how much offset to add to energy bar? Vector2 offset = Vector2.Zero; if (UseEnergyTimer.HasTimeRemaining) { offset = OffsetVector(UseEnergyTimer.CurrentTime * UseEnergyShakeSpeed, UseEnergyShakeAmount); } meterRenderer.DrawBorder(this, spritebatch, correctedPosition, Vector2.One, offset, Color.White); if (UseEnergyTimer.HasTimeRemaining) { var spentEnergy = MaxEnergy * UseEnergyTimer.Lerp; var spentEnergyAlpha = ConvertToAlpha(0, MaxEnergy, spentEnergy); //draw the depleted bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, spentEnergyAlpha, 1f, Vector2.One, offset, GetUseEnergyDepletedColor()); //draw the energy bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, spentEnergyAlpha, Vector2.One, offset, GetUseEnergyColor()); } else if (AddEnergyTimer.HasTimeRemaining) { //how much health bar to draw? var healingHealthBar = PreAddAmount + ((CurrentEnergy - PreAddAmount) * (1f - AddEnergyTimer.Lerp)); var healingAlpha = ConvertToAlpha(0, MaxEnergy, healingHealthBar); //how much pulsate to add to hp bar? var pulsate = PulsateScale(AddEnergyTimer.CurrentTime * AddEnergyPulsateSpeed, AddEnergyScaleAmount, correctedPosition); //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxEnergy, CurrentEnergy); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, Vector2.One, Vector2.Zero, EmptyEnergyColor); //draw the healing part of the bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, healingAlpha, currentAlpha, Vector2.One, Vector2.Zero, GetAddingEnergyColor()); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, healingAlpha, Vector2.One, Vector2.Zero, GetAddEnergyColor()); meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, healingAlpha, pulsate, Vector2.Zero, GetAddEnergyColor()); } else if (!EnergyFullClock.Paused) { //else if the energy is full, draw in FullEnergy mode //how much pulsate to add to hp bar? var pulsate = PulsateScale(EnergyFullClock.CurrentTime * EnergyFullPulsateSpeed, EnergyFullScaleAmount, correctedPosition); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, pulsate, Vector2.Zero, GetEnergyFullColor()); } else { //otherwise draw the health bar normal //what is the alpha of the current HP? var currentAlpha = ConvertToAlpha(0, MaxEnergy, CurrentEnergy); //draw the empty part of the bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, currentAlpha, 1f, Vector2.One, Vector2.Zero, EmptyEnergyColor); //draw the health bar meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, currentAlpha, Vector2.One, Vector2.Zero, GetEnergyColor()); } //draw the shadow if time is left if (UseEnergyShadowTimer.HasTimeRemaining) { var scale = LerpScale(UseEnergyShadowTimer, UseEnergyShadowTargetScale, correctedPosition); var color = GetUseEnergyShadowColor(); meterRenderer.DrawMeter(this, spritebatch, correctedPosition, 0f, 1f, scale, Vector2.Zero, color); } }