public void SetHeartsHealthSystem(HeartsHealthSystem heartsHealthSystem) { this.heartsHealthSystem = heartsHealthSystem; heartsHealthSystemStatic = heartsHealthSystem; List <HeartsHealthSystem.Heart> heartList = heartsHealthSystem.GetHeartList(); int row = 0; int col = 0; int colMax = 5; float rowColSize = 30f; for (int i = 0; i < heartList.Count; i++) { HeartsHealthSystem.Heart heart = heartList[i]; Vector2 heartAnchoredPosition = new Vector2(col * rowColSize, -row * rowColSize); CreateHeartImage(heartAnchoredPosition).SetHeartFraments(heart.GetFragmentAmount()); col++; if (col >= colMax) { row++; col = 0; } } heartsHealthSystem.OnDamaged += HeartsHealthSystem_OnDamaged; heartsHealthSystem.OnHealed += HeartsHealthSystem_OnHealed; heartsHealthSystem.OnDead += HeartsHealthSystem_OnDead; }
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; } }
private void HealingAnimatedPeriodic() { if (isHealing) { bool fullyHealed = true; List <HeartsHealthSystem.Heart> heartList = heartsHealthSystem.GetHeartList(); for (int i = 0; i < heartList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartList[i]; if (heartImage.GetFragmentAmount() != heart.GetFragmentAmount()) { // Visual is different from logic heartImage.AddHeartVisualFragment(); if (heartImage.GetFragmentAmount() == HeartsHealthSystem.MAX_FRAGMENT_AMOUNT) { // This heart was fully healed 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 RefreshAllHearts() { List <HeartsHealthSystem.Heart> heartList = heartsHealthSystem.GetHeartList(); for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartList[i]; heartImage.SetHeartFraments(heart.GetFragmentAmount()); } }
private void refreshAllHearts() { // get a lisst of all hearts List <HeartsHealthSystem.Heart> hearts = heartHealthSystem.getHeartsList(); for (int i = 0; i < heartImageList.Count; i++) { HeartImage img = heartImageList[i]; HeartsHealthSystem.Heart heart = hearts[i]; // update heart img.SetHeartFragments(heart.GetCurrentFragmentAmount()); // reset fragment } }
private void HeartsHealthSystem_OnDamaged(object sender, EventArgs e) { // Hearts health system was damaged //RefreshAllHearts(); List <HeartsHealthSystem.Heart> heartList = heartsHealthSystem.GetHeartList(); for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; HeartsHealthSystem.Heart heart = heartList[i]; heartImage.SetHeartFragments(heart.GetFragmentAmount()); } }
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; }
public void setHeartHealthSystem(HeartsHealthSystem sys) { heartHealthSystem = sys; List <HeartsHealthSystem.Heart> allHearts = sys.getHeartsList(); for (int i = 0; i < allHearts.Count; i++) { HeartsHealthSystem.Heart heart = allHearts[i]; createHeartImage(new Vector2(XPos, 0), fullHeartSprite).SetHeartFragments(heart.GetCurrentFragmentAmount()); XPos += distanceBtwHearts; } //subscribe to an event heartHealthSystem.onDamage += HeartHealthSystem_OnDamaged; heartHealthSystem.onHeal += HeartHealthSystem_OnHealed; heartHealthSystem.onDead += HeartHealthSystem_OnDead; }