private void HealingAnimatedPeriodic() { if (!isHealing) { return; } bool fullyHealed = true; for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartsHealthSystem.GetHeartList()[i]; if (Math.Round(heartImage.GetValue(), 3) != heart.GetValue()) { heartImage.AddHeartVisualValue(); if (Math.Round(heartImage.GetValue(), 2) == HeartsHealthSystem.MAX_HEARTH_VALUE) { heartImage.PlayHeartFullAnimation(); } fullyHealed = false; break; } } if (fullyHealed) { isHealing = false; } }
public void RefreshAllHearts(object sender, EventArgs e) { for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartsHealthSystem.GetHeartList()[i]; heartImage.SetHeartValue(heart.GetValue()); } }
private void RefreshHearts(object sender, System.EventArgs e) { for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartsHealthSystem.GetHeartList()[i]; heartImage.SetValue(heart.GetValue()); } if (heartsHealthSystem.HeartEmpty() == true) { _player.IsDead(); } }
public void SetHeartsHealthSystem(HeartsHealthSystem heartsHealthSystem) { this.heartsHealthSystem = heartsHealthSystem; List <HeartsHealthSystem.Heart> heartList = heartsHealthSystem.GetHeartList(); Vector2 heartAnchorePosition = new Vector2(0, 0); for (int i = 0; i < heartList.Count; i++) { HeartsHealthSystem.Heart heart = heartList[i]; CreateHeartImage(heartAnchorePosition).SetHeartValue(heart.GetValue()); heartAnchorePosition += new Vector2(OFFSET, 0); } heartsHealthSystem.onDamaged += RefreshAllHearts; heartsHealthSystem.onHealed += HeakthSystem_OnHealed; heartsHealthSystem.onDead += DeadMessage; }