Example #1
0
    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
        }
    }
Example #2
0
    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;
    }