示例#1
0
    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;
        }
    }
示例#2
0
 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());
     }
 }
示例#3
0
    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();
        }
    }
示例#4
0
    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;
    }