Beispiel #1
0
    public void HealingAnimatedPeriodic()
    {
        if (isHealing)
        {
            bool fullyHealed = true;

            List <HealthHeartsSystem.Heart> heartList = healthHeartsSystem.GetHeartList();
            for (int i = 0; i < heartList.Count; i++)
            {
                HeartImage heartImage          = heartImageList[i];
                HealthHeartsSystem.Heart heart = heartList[i];

                if (heartImage.GetFragmentAmount() != heart.GetFragmentAmount())
                {
                    //Comprobar si el resultado visual es diferente de la lógica
                    heartImage.AddHeartVisualFragment();
                    if (heartImage.GetFragmentAmount() == HealthHeartsSystem.MAX_FRAGMENT_AMOUNT)
                    {
                        //Este corazón estaba completamente curado
                        heartImage.PlayHeartFullAnimation();
                    }
                    fullyHealed = false;
                    break;
                }
            }

            if (fullyHealed)
            {
                isHealing = false;
            }
        }
    }
Beispiel #2
0
    /// //Prueba///////////////////

    /*private void Update()
     * {
     *  if(Input.GetKeyDown(KeyCode.K))
     *  {
     *      healthHeartsSystem.Damage(1);
     *  }
     *  if (Input.GetKeyDown(KeyCode.L))
     *  {
     *      healthHeartsSystem.Damage(2);
     *  }
     *  if (Input.GetKeyDown(KeyCode.I))
     *  {
     *      healthHeartsSystem.Heal(1);
     *  }
     *  if (Input.GetKeyDown(KeyCode.O))
     *  {
     *      healthHeartsSystem.Heal(3);
     *  }
     * }*/

    /// //Prueba///////////////////

    public void SetHealthHeartsSystem(HealthHeartsSystem healthHeartsSystem)
    {
        this.healthHeartsSystem  = healthHeartsSystem;
        healthHeartsSystemStatic = healthHeartsSystem;

        List <HealthHeartsSystem.Heart> heartList = healthHeartsSystem.GetHeartList();
        int   row        = 0;
        int   col        = 0;
        int   colMax     = numberOfHeartsPerRow;
        float rowColSize = distanceBetweenHeartsXY;

        for (int i = 0; i < heartList.Count; i++)
        {
            HealthHeartsSystem.Heart heart = heartList[i];
            Vector2 heartAnchoredPosition  = new Vector2(col * rowColSize, -row * rowColSize);
            CreateHeartImage(heartAnchoredPosition).SetHeartFragment(heart.GetFragmentAmount());

            col++;
            if (col >= colMax)
            {
                row++;
                col = 0;
            }
        }

        healthHeartsSystem.OnDamaged += HealthHeartsSystem_OnDamaged;
        healthHeartsSystem.OnHealed  += HealthHeartsSystem_OnHealed;
        healthHeartsSystem.OnDead    += HealthHeartsSystem_OnDead;
    }
Beispiel #3
0
    private void RefreshAllHearts()
    {
        List <HealthHeartsSystem.Heart> heartList = healthHeartsSystem.GetHeartList();

        for (int i = 0; i < heartImageList.Count; i++)
        {
            HeartImage heartImage          = heartImageList[i];
            HealthHeartsSystem.Heart heart = heartList[i];
            heartImage.SetHeartFragment(heart.GetFragmentAmount());
        }
    }