Example #1
0
        public Stun Clone()
        {
            Stun stun = new Stun();

            stun.chance   = chance;
            stun.duration = duration;
            return(stun);
        }
Example #2
0
        public static Stun GetTowerStunMultiplier(int prefabID)
        {
            if (instance == null)
            {
                return(new Stun(0, 0));
            }
            Stun stunG = instance.globalTowerModifier.stats.stun;
            Stun stunT = GetTowerModifier(prefabID).stats.stun;

            return(new Stun(stunG.chance + stunT.chance, stunG.duration + stunT.duration));
        }
Example #3
0
 public UnitStat()
 {
     stun        = new Stun();
     crit        = new Critical();
     slow        = new Slow();
     dot         = new Dot();
     instantKill = new InstantKill();
     buff        = new Buff();
     //if(shootObjects == null)
     //{
     //    shootObjects = new List<ShootObject>();
     //    shootObjects.Add(null);
     //}
 }
Example #4
0
        //shared among tower, ability & fpsWeapon. 0-tower, 1-fpsWeapon, 2-ability
        public static Stun ModifyStunWithPerkBonus(Stun stun, int prefabID, int type = 0)
        {
            Stun stunMod = new Stun();

            if (type == 0)
            {
                stunMod = GetTowerStunMultiplier(prefabID);
            }
            else if (type == 1)
            {
                stunMod = GetFPSWeaponStunMultiplier(prefabID);
            }
            stun.chance   *= (1 + stunMod.chance);
            stun.duration *= (1 + stunMod.duration);
            return(stun);
        }
Example #5
0
        //stats processing for attack from fps-weapon
        public void Process_SrcWeapon()
        {
            if (srcWeapon.GetInstantKill().IsApplicable(tgtUnit.HP, tgtUnit.fullHP))
            {
                damage      = tgtUnit.HP;
                damageHP    = tgtUnit.HP;
                instantKill = true;
                destroy     = true;
                return;
            }

            damage  = Random.Range(srcWeapon.GetDamageMin(), srcWeapon.GetDamageMax());
            damage /= (float)srcWeapon.GetShootPointCount();    //divide the damage by number of shootPoint

            float critChance = srcWeapon.GetCritChance();

            if (tgtUnit.immuneToCrit)
            {
                critChance = -1f;
            }
            if (Random.Range(0f, 1f) < critChance)
            {
                critical = true;
                damage  *= srcWeapon.GetCritMultiplier();
                //new TextOverlay(impactPoint, "Critical", new Color(1f, .6f, 0f, 1f));
            }

            float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcWeapon.damageType);

            damage *= dmgModifier;

            if (damage >= tgtUnit.shield)
            {
                damageShield = tgtUnit.shield;
                damageHP     = damage - tgtUnit.shield;
            }
            else
            {
                damageShield = damage;
                damageHP     = 0;
            }


            if (Random.Range(0f, 1f) < srcWeapon.GetShieldPierce() && damageShield > 0)
            {
                damageHP    += damageShield;
                damageShield = 0;
                pierceShield = true;
                //new TextOverlay(impactPoint,"Shield Pierced", new Color(0f, 1f, 1f, 1f));
            }
            if (srcWeapon.DamageShieldOnly())
            {
                damageHP = 0;
            }

            if (damageHP >= tgtUnit.HP)
            {
                destroy = true;
                return;
            }

            if (Random.Range(0f, 1f) < srcWeapon.GetShieldBreak() && tgtUnit.fullShield > 0)
            {
                breakShield = true;
            }

            stunned = srcWeapon.GetStun().IsApplicable();
            if (tgtUnit.immuneToStun)
            {
                stunned = false;
            }

            slowed = srcWeapon.GetSlow().IsValid();
            if (tgtUnit.immuneToSlow)
            {
                slowed = false;
            }

            if (srcWeapon.GetDot().GetTotalDamage() > 0)
            {
                dotted = true;
            }


            if (stunned)
            {
                stun = srcWeapon.GetStun().Clone();
            }
            if (slowed)
            {
                slow = srcWeapon.GetSlow().Clone();
            }
            if (dotted)
            {
                dot = srcWeapon.GetDot().Clone();
            }
        }
Example #6
0
        //stats processing for attack from unit (tower/creep)
        public void Process_SrcUnit()
        {
            if (srcUnit.GetHit() <= 0)
            {
                Debug.LogWarning("Attacking unit (" + srcUnit.unitName + ") has default hitChance of 0%, is this intended?", srcUnit);
            }

            float hitChance = Mathf.Clamp(srcUnit.GetHit() - tgtUnit.GetDodge(), 0, 1);

            if (Random.Range(0f, 1f) > hitChance)
            {
                missed = true;
                return;
            }

            if (srcUnit.GetInstantKill().IsApplicable(tgtUnit.HP, tgtUnit.fullHP))
            {
                damage      = tgtUnit.HP;
                damageHP    = tgtUnit.HP;
                instantKill = true;
                destroy     = true;
                return;
            }


            damage  = Random.Range(srcUnit.GetDamageMin(), srcUnit.GetDamageMax());
            damage /= (float)srcUnit.GetShootPointCount();  //divide the damage by number of shootPoint


            float critChance = srcUnit.GetCritChance();

            if (tgtUnit.immuneToCrit)
            {
                critChance = -1f;
            }
            if (Random.Range(0f, 1f) < critChance)
            {
                critical = true;
                damage  *= srcUnit.GetCritMultiplier();
                new TextOverlay(impactPoint, "Critical", new Color(1f, .6f, 0f, 1f));
            }

            float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcUnit.damageType);

            damage *= dmgModifier;

            if (damage >= tgtUnit.shield)
            {
                damageShield = tgtUnit.shield;
                damageHP     = damage - tgtUnit.shield;
            }
            else
            {
                damageShield = damage;
                damageHP     = 0;
            }


            if (Random.Range(0f, 1f) < srcUnit.GetShieldPierce() && damageShield > 0)
            {
                damageHP    += damageShield;
                damageShield = 0;
                pierceShield = true;
                new TextOverlay(impactPoint, "Shield Pierced", new Color(0f, 1f, 1f, 1f));
            }
            if (srcUnit.DamageShieldOnly())
            {
                damageHP = 0;
            }

            if (damageHP >= tgtUnit.HP)
            {
                destroy = true;
                return;
            }

            if (Random.Range(0f, 1f) < srcUnit.GetShieldBreak() && tgtUnit.fullShield > 0)
            {
                breakShield = true;
            }

            stunned = srcUnit.GetStun().IsApplicable();
            if (tgtUnit.immuneToStun)
            {
                stunned = false;
            }

            slowed = srcUnit.GetSlow().IsValid();
            if (tgtUnit.immuneToSlow)
            {
                slowed = false;
            }

            if (srcUnit.GetDot().GetTotalDamage() > 0)
            {
                dotted = true;
            }

            if (stunned)
            {
                stun = srcUnit.GetStun().Clone();
            }
            if (slowed)
            {
                slow = srcUnit.GetSlow().Clone();
            }
            if (dotted)
            {
                dot = srcUnit.GetDot().Clone();
            }
        }