Ejemplo n.º 1
0
    public void ApplyEffectDirectly(DamageEffectData damage, GameObject obj)
    {
        if (!blackListObjects.Contains(obj))
        {
            damage.ApplyResistances(healthData.resistancesData.TotalResistance());
            damage.RollForEffectChance();
            damage.SetInitalScores();

            freezeChanged = persistantDamages.freeze.GetScore() > 0;
            persistantDamages.CheckEffectScores(damage);
            originalPersistantDamages.CheckEffectScores(damage);
            if (damage.fire.GetScore() > 0 || damage.acid.GetScore() > 0)
            {
                blackListObjects.Add(obj);
            }
        }
    }
Ejemplo n.º 2
0
    public void ApplyDamage(DamageData damageData)// need to have a apply peristant effect damage
    {
        if (!healthData.isDamageable || healthData.isDead)
        {
            return;
        }

        float[] damageTaken = new float[5] {
            0, 0, 0, 0, 0
        };
        DamageEffectData originalPersistantDamagesCopy = damageData.damageEffectData;

        float armourValue  = (healthData.currentArmour - damageData.armourPierce > 0) ? healthData.currentArmour - damageData.armourPierce : 0;
        float ignoreShield = damageData.damage * damageData.shieldPierce;

        damageData.damage -= ignoreShield;
        damageData.damageEffectData.ApplyResistances(healthData.resistancesData.TotalResistance());

        float[] damageArray = damageData.damageEffectData.ImpactDamageAsArray();
        damageArray = new float[5] {
            damageData.damage, damageArray[0], damageArray[1], damageArray[2], damageArray[3],
        };
        float[] damageModArray = damageData.damageEffectData.ShieldModAsArray();
        damageModArray = new float[] { damageData.shieldDamageMod, damageModArray[0], damageModArray[1], damageModArray[2], damageModArray[3] };


        int length = damageArray.Length;

        for (int i = 0; i < length; ++i)
        {
            if (healthData.currentShield > 0)//apply shield Damage
            {
                healthData.currentShield -= damageArray[i] * damageModArray[i];

                damageTaken[i] += damageArray[i] * damageModArray[i];
                if (damageArray[i] * damageArray[i] > 0)
                {
                    healthData.regenData.timeTillShieldRegenStart = healthData.regenData.shieldRegenDelay;
                }
                if (!tookDamage)
                {
                    tookDamage = (damageTaken[i] > 0) ? true : false;
                }
                if (healthData.currentShield <= 0)
                {
                    damageArray[i]           = healthData.currentShield / damageModArray[i];
                    damageTaken[i]          -= healthData.currentShield / damageModArray[i];
                    healthData.currentShield = 0;
                    break;
                }
                damageArray[i] = 0;
            }
        }
        damageModArray = damageData.damageEffectData.HealthModAsArray();
        damageModArray = new float[] { damageData.healthDamageMod, damageModArray[0], damageModArray[1], damageModArray[2], damageModArray[3] };

        damageArray[0] *= (1 - armourValue);
        for (int i = 0; i < length; ++i)
        {
            if (healthData.currentHealth > 0)// apply health Damage
            {
                healthData.currentHealth -= damageArray[i] * damageModArray[i];
                damageTaken[i]           += damageArray[i] * damageModArray[i];
                if (damageArray[i] * damageArray[i] > 0)
                {
                    healthData.regenData.timeTillShieldRegenStart = healthData.regenData.shieldRegenDelay;
                    healthData.regenData.timeTillHealthRegenStart = healthData.regenData.healthRegenDelay;
                }
                if (!tookDamage)
                {
                    tookDamage = (damageTaken[i] > 0) ? true : false;
                }
                if (healthData.currentHealth <= 0)
                {
                    damageArray[i]           = healthData.currentHealth / damageModArray[i];
                    damageTaken[i]          -= healthData.currentHealth / damageModArray[i];
                    healthData.currentHealth = 0;
                    healthData.isDead        = true;
                    break;
                }
                damageArray[i] = 0;
            }
        }

        if (!damageData.damageEffectData.isEmpty())//apply new persistent effects, if there are any to apply
        {
            damageData.damageEffectData.RollForEffectChance();
            if (damageData.damageEffectData.fire.GetScore() == 0)
            {
                originalPersistantDamagesCopy.fire.Clear();
            }
            if (damageData.damageEffectData.freeze.GetScore() == 0)
            {
                originalPersistantDamagesCopy.freeze.Clear();
            }
            if (damageData.damageEffectData.shock.GetScore() == 0)
            {
                originalPersistantDamagesCopy.shock.Clear();
            }
            if (damageData.damageEffectData.acid.GetScore() == 0)
            {
                originalPersistantDamagesCopy.acid.Clear();
            }

            damageData.damageEffectData.SetInitalScores();
            originalPersistantDamagesCopy.SetInitalScores();
            freezeChanged      = false;
            freezeAddIntensity = 0;
            freezeChanged      = damageData.damageEffectData.freeze.GetScore() > 0;
            freezeAddIntensity = damageData.damageEffectData.freeze.intensity;
            persistantDamages.CheckEffectScores(damageData.damageEffectData);
            originalPersistantDamages.CheckEffectScores(originalPersistantDamagesCopy);
        }

        healthData.recentDamage.SetAllDamage(damageTaken);

        // Debug.Log("Health: " + healthData.currentHealth + ". Shield: " + healthData.currentShield);
    }