示例#1
0
    public void ApplyHeal(HealData healing, bool applyResistanceData = false, float resistanceDuration = 0)
    {
        healthData.currentHealth = Mathf.Min(healthData.maxHealth, healthData.currentHealth + healing.heath);
        healthData.currentShield = Mathf.Min(healthData.maxShield, healthData.currentShield + healing.shield);
        healthData.currentArmour = Mathf.Min(healthData.maxArmour, healthData.currentArmour + healing.armour);

        if (applyResistanceData)
        {
            timeTillTempResistExpire = resistanceDuration;
            healthData.resistancesData.SetTempResist(healing.resistance);
            //this replaces old buffs with new ones. If we want to keep multiple resistance buffs, then
            //the temp resistances need to be in a list, each with thier own remaining duration timer. this means that the tempRes will need to be in a struct.
        }
    }
示例#2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        foreach (string tag in tagsMakeDamage)
        {
            if (collision.CompareTag(tag))
            {
                DamageData data = collision.GetComponent <DamageData>();
                Damage(data.damageAmount);
                return;
            }
        }

        foreach (string tag in tagsHealing)
        {
            if (collision.CompareTag(tag))
            {
                HealData data = collision.GetComponent <HealData>();
                Heal(data.healingAmount);
                return;
            }
        }
    }