public AbilityEffect GetActiveEffect()
        {
            AbilityEffect eff = new AbilityEffect();

            eff.duration   = effect.duration * (1 + PerkManager.GetAbilityDuration(ID));
            eff.damageMin  = effect.damageMin * (1 + PerkManager.GetAbilityDamage(ID));
            eff.damageMax  = effect.damageMax * (1 + PerkManager.GetAbilityDamage(ID));
            eff.stunChance = effect.stunChance * (1 + PerkManager.GetAbilityStunChance(ID));

            eff.slow = PerkManager.ModifySlowWithPerkBonus(effect.slow, ID, 2); //pass 2 to indicate this is for ability
            eff.dot  = PerkManager.ModifyDotWithPerkBonus(effect.dot, ID, 2);

            eff.damageBuff   = effect.damageBuff * (1 + PerkManager.GetAbilityDamageBuff(ID));
            eff.rangeBuff    = effect.rangeBuff * (1 + PerkManager.GetAbilityRangeBuff(ID));
            eff.cooldownBuff = effect.cooldownBuff * (1 + PerkManager.GetAbilityCooldownBuff(ID));
            eff.HPGainMin    = effect.HPGainMin * (1 + PerkManager.GetAbilityHPGain(ID));
            eff.HPGainMax    = effect.HPGainMax * (1 + PerkManager.GetAbilityHPGain(ID));

            return(eff);
        }
Beispiel #2
0
        public AbilityEffect GetActiveEffect()
        {
            AbilityEffect eff = new AbilityEffect();

            /*
             * PerkAbilityModifier gModifier=PerkManager.GetGlobalAbilityModifier();
             * PerkAbilityModifier modifier=PerkManager.GetAbilityModifier(ID);
             *
             * eff.duration=effect.duration * (1+gModifier.effects.duration+modifier.effects.duration);
             * eff.damageMin=effect.damageMin * (1+gModifier.effects.damageMin+modifier.effects.damageMin);
             * eff.damageMax=effect.damageMax * (1+gModifier.effects.damageMax+modifier.effects.damageMax);
             * eff.stunChance=effect.stunChance * (1+gModifier.effects.stunChance+modifier.effects.stunChance);
             *
             * eff.slow=effect.slow.Clone();
             * eff.slow.slowMultiplier*=(1-(gModifier.effects.slow.slowMultiplier+modifier.effects.slow.slowMultiplier));
             * eff.slow.duration*=(1+(gModifier.effects.slow.duration+modifier.effects.slow.duration));
             *
             * eff.damageBuff=effect.damageBuff * (1+gModifier.effects.damageBuff+modifier.effects.damageBuff);
             * eff.rangeBuff=effect.rangeBuff * (1+gModifier.effects.rangeBuff+modifier.effects.rangeBuff);
             * eff.cooldownBuff=effect.cooldownBuff * (1+gModifier.effects.cooldownBuff+modifier.effects.cooldownBuff);
             * eff.HPGainMin=effect.HPGainMin * (1+gModifier.effects.HPGainMin+modifier.effects.HPGainMin);
             * eff.HPGainMax=effect.HPGainMax * (1+gModifier.effects.HPGainMax+modifier.effects.HPGainMax);
             */


            eff.duration   = effect.duration * (1 + PerkManager.GetAbilityDuration(ID));
            eff.damageMin  = effect.damageMin * (1 + PerkManager.GetAbilityDamage(ID));
            eff.damageMax  = effect.damageMax * (1 + PerkManager.GetAbilityDamage(ID));
            eff.stunChance = effect.stunChance * (1 + PerkManager.GetAbilityStunChance(ID));

            eff.slow = PerkManager.ModifySlowWithPerkBonus(effect.slow.Clone(), ID, 2);                 //pass 2 to indicate this is for ability
            eff.dot  = PerkManager.ModifyDotWithPerkBonus(effect.dot.Clone(), ID, 2);

            eff.damageBuff   = effect.damageBuff * (1 + PerkManager.GetAbilityDamageBuff(ID));
            eff.rangeBuff    = effect.rangeBuff * (1 + PerkManager.GetAbilityRangeBuff(ID));
            eff.cooldownBuff = effect.cooldownBuff * (1 + PerkManager.GetAbilityCooldownBuff(ID));
            eff.HPGainMin    = effect.HPGainMin * (1 + PerkManager.GetAbilityHPGain(ID));
            eff.HPGainMax    = effect.HPGainMax * (1 + PerkManager.GetAbilityHPGain(ID));

            return(eff);
        }
        public AbilityEffect Clone()
        {
            AbilityEffect eff = new AbilityEffect();

            eff.duration = duration;

            eff.damageMin  = damageMin;
            eff.damageMax  = damageMax;
            eff.stunChance = stunChance;
            eff.slow       = slow.Clone();
            eff.dot        = dot.Clone();

            eff.slow.duration = eff.duration;
            eff.dot.duration  = eff.duration;

            eff.damageBuff   = damageBuff;
            eff.rangeBuff    = rangeBuff;
            eff.cooldownBuff = cooldownBuff;
            eff.HPGainMin    = HPGainMin;
            eff.HPGainMax    = HPGainMax;

            return(eff);
        }
Beispiel #4
0
        //apply the ability effect, damage, stun, buff and so on
        IEnumerator ApplyAbilityEffect(Ability ab, Vector3 pos, Unit tgtUnit = null)
        {
            yield return(new WaitForSeconds(ab.effectDelay));

            LayerMask mask1 = 1 << LayerManager.LayerTower();
            LayerMask mask2 = 1 << LayerManager.LayerCreep();
            LayerMask mask3 = 1 << LayerManager.LayerCreepF();
            LayerMask mask  = mask1 | mask2 | mask3;

            List <Unit> creepList = new List <Unit>();
            List <Unit> towerList = new List <Unit>();

            if (tgtUnit == null)
            {
                float      radius = ab.requireTargetSelection ? ab.GetAOERadius() : Mathf.Infinity;
                Collider[] cols   = Physics.OverlapSphere(pos, radius, mask);

                if (cols.Length > 0)
                {
                    for (int i = 0; i < cols.Length; i++)
                    {
                        Unit unit = cols[i].gameObject.GetComponent <Unit>();
                        if (unit.unitC != null)
                        {
                            creepList.Add(unit.unitC);
                        }
                        if (unit.unitT != null)
                        {
                            towerList.Add(unit.unitT);
                        }
                    }
                }
            }
            else
            {
                creepList.Add(tgtUnit);
                towerList.Add(tgtUnit);
            }

            AbilityEffect eff = ab.GetActiveEffect();

            for (int n = 0; n < creepList.Count; n++)
            {
                if (eff.damageMax > 0)
                {
                    creepList[n].ApplyDamage(Random.Range(eff.damageMin, eff.damageMax));
                }
                else if (eff.stunChance > 0 && eff.duration > 0)
                {
                    if (Random.Range(0f, 1f) < eff.stunChance)
                    {
                        creepList[n].ApplyStun(eff.duration);
                    }
                }
                else if (eff.slow.IsValid())
                {
                    creepList[n].ApplySlow(eff.slow);
                }
                else if (eff.dot.GetTotalDamage() > 0)
                {
                    creepList[n].ApplyDot(eff.dot);
                }
            }
            for (int n = 0; n < towerList.Count; n++)
            {
                if (eff.duration > 0)
                {
                    if (eff.damageBuff > 0)
                    {
                        towerList[n].ABBuffDamage(eff.damageBuff, eff.duration);
                    }
                    else if (eff.rangeBuff > 0)
                    {
                        towerList[n].ABBuffRange(eff.rangeBuff, eff.duration);
                    }
                    else if (eff.cooldownBuff > 0)
                    {
                        towerList[n].ABBuffCooldown(eff.cooldownBuff, eff.duration);
                    }
                }
                else if (eff.HPGainMax > 0)
                {
                    towerList[n].RestoreHP(Random.Range(eff.HPGainMin, eff.HPGainMax));
                }
            }
        }
        public string GetDesp()
        {
            if (useCustomDesp)
            {
                return(desp);
            }

            string text = "";

            AbilityEffect eff = GetActiveEffect();

            if (eff.damageMax > 0)
            {
                if (requireTargetSelection)
                {
                    text += "Deals " + eff.damageMin + "-" + eff.damageMax + " to hostile target in range\n";
                }
                else
                {
                    text += "Deals " + eff.damageMin + "-" + eff.damageMax + " to all hostile on the map\n";
                }
            }
            if (eff.stunChance > 0 && eff.duration > 0)
            {
                if (requireTargetSelection)
                {
                    text += (eff.stunChance * 100).ToString("f0") + "% chance to stun hostile target for " + eff.duration + "s\n";
                }
                else
                {
                    text += (eff.stunChance * 100).ToString("f0") + "% chance to stun all hostile on the map for " + eff.duration + "s\n";
                }
            }
            if (eff.slow.IsValid())
            {
                if (requireTargetSelection)
                {
                    text += "Slows hostile target down for " + eff.duration + "s\n";
                }
                else
                {
                    text += "Slows all hostile on the map down for " + eff.duration + "s\n";
                }
            }
            if (eff.dot.GetTotalDamage() > 0)
            {
                if (requireTargetSelection)
                {
                    text += "Deals " + eff.dot.GetTotalDamage().ToString("f0") + " to hostile target over " + eff.duration + "s\n";
                }
                else
                {
                    text += "Deals " + eff.dot.GetTotalDamage().ToString("f0") + " to all hostile on the map over " + eff.duration + "s\n";
                }
            }


            if (eff.HPGainMax > 0)
            {
                if (requireTargetSelection)
                {
                    text += "Restore " + eff.HPGainMin + "-" + eff.HPGainMax + " of friendly target HP\n";
                }
                else
                {
                    text += "Restore " + eff.HPGainMin + "-" + eff.HPGainMax + " of all tower HP\n";
                }
            }
            if (eff.duration > 0)
            {
                if (eff.damageBuff > 0)
                {
                    if (requireTargetSelection)
                    {
                        text += "Increase friendly target damage by " + (eff.damageBuff * 100).ToString("f0") + "%\n";
                    }
                    else
                    {
                        text += "Increase all towers damage by " + (eff.damageBuff * 100).ToString("f0") + "%\n";
                    }
                }
                if (eff.rangeBuff > 0)
                {
                    if (requireTargetSelection)
                    {
                        text += "Increase friendly target range by " + (eff.rangeBuff * 100).ToString("f0") + "%\n";
                    }
                    else
                    {
                        text += "Increase all towers range by " + (eff.rangeBuff * 100).ToString("f0") + "%\n";
                    }
                }
                if (eff.cooldownBuff > 0)
                {
                    if (requireTargetSelection)
                    {
                        text += "Decrease friendly target cooldown by " + (eff.cooldownBuff * 100).ToString("f0") + "%\n";
                    }
                    else
                    {
                        text += "Decrease all towers cooldown by " + (eff.cooldownBuff * 100).ToString("f0") + "%\n";
                    }
                }
            }


            return(text);
        }
Beispiel #6
0
        Vector2 DrawAbilityEffect(AbilityEffect effect, float startX, float startY)
        {
            float spaceX = 110;

            EditorGUI.LabelField(new Rect(startX, startY, width, height), "Effects:");

            GUI.Box(new Rect(startX, startY += spaceY, spaceX + 95, 300), "");

            startX += 5;
            startY += 10;

            cont = new GUIContent("Duration:", "Duration of the effects. This is shared by all the effects that may have a duration (stun, dot, slot, buff)");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.duration);

            effect.slow.duration = effect.duration;
            effect.dot.duration  = effect.duration;

            startY += 10;

            cont = new GUIContent("Damage Min/Max:", "Damage to be done to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.damageMin);
            effect.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + 40, startY, 40, height), effect.damageMax);

            cont = new GUIContent("Stun Chance:", "Chance to stun target (creep only). Takes value from 0-1 with 0.3 being 30% to stun the target");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.stunChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.stunChance);


            //~ cont=new GUIContent("Slow:", "Slow speed multiplier to be applied to target (creep only). Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
            cont = new GUIContent("Slow:", "Slow speed multiplier to be applied to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= 3;

            cont = new GUIContent(" - Slow Multiplier:", "Slow speed multiplier to be applied to target (creep only). Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.slow.slowMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.slow.slowMultiplier);


            cont = new GUIContent("Dot:", "Damage over time to be applied to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= 3;
            cont = new GUIContent(" - Interval:", "Duration between each tick. Damage is applied at each tick.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.dot.interval = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.dot.interval);

            cont = new GUIContent(" - Damage:", "Damage applied at each tick");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.dot.value = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.dot.value);

            startY += 10;


            cont = new GUIContent("HP-Gain Min/Max:", "HP to restored to target (tower only)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.HPGainMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.HPGainMin);
            effect.HPGainMax = EditorGUI.FloatField(new Rect(startX + spaceX + 40, startY, 40, height), effect.HPGainMax);

            cont = new GUIContent("Buff:", "Buffs to be applied to the target (tower only)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cont = new GUIContent(" - Damage Buff:", "Damage buff multiplier. Takes value from 0 and above with 0.4 being increase damage by 40%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.damageBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.damageBuff);

            cont = new GUIContent(" - Range Buff:", "Range buff multiplier. Takes value from 0 and above with 0.3 being increase effective range by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.rangeBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.rangeBuff);

            cont = new GUIContent(" - Cooldown Buff:", "Cooldown buff multiplier. Takes value from 0 and above with 0.5 being decrease attack cooldown by 50%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.cooldownBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.cooldownBuff);

            return(new Vector2(startX, startY));
        }
        Vector2 DrawAbilityEffect(AbilityEffect effect, float startX, float startY)
        {
            float spaceX=110;

            EditorGUI.LabelField(new Rect(startX, startY, width, height), "Effects:");

            GUI.Box(new Rect(startX, startY+=spaceY, spaceX+95, 300), "");

            startX+=5;
            startY+=10;

            cont=new GUIContent("Duration:", "Duration of the effects. This is shared by all the effects that may have a duration (stun, dot, slot, buff)");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            effect.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.duration);

            effect.slow.duration=effect.duration;
            effect.dot.duration=effect.duration;

            startY+=10;

            cont=new GUIContent("Damage Min/Max:", "Damage to be done to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            effect.damageMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.damageMin);
            effect.damageMax=EditorGUI.FloatField(new Rect(startX+spaceX+40, startY, 40, height), effect.damageMax);

            cont=new GUIContent("Stun Chance:", "Chance to stun target (creep only). Takes value from 0-1 with 0.3 being 30% to stun the target");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            effect.stunChance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.stunChance);

            //~ cont=new GUIContent("Slow:", "Slow speed multiplier to be applied to target (creep only). Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
            cont=new GUIContent("Slow:", "Slow speed multiplier to be applied to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=3;

                cont=new GUIContent(" - Slow Multiplier:", "Slow speed multiplier to be applied to target (creep only). Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.slow.slowMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.slow.slowMultiplier);

            cont=new GUIContent("Dot:", "Damage over time to be applied to target (creep only)");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=3;
                cont=new GUIContent(" - Interval:", "Duration between each tick. Damage is applied at each tick.");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.dot.interval=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.dot.interval);

                cont=new GUIContent(" - Damage:", "Damage applied at each tick");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.dot.value=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.dot.value);

            startY+=10;

            cont=new GUIContent("HP-Gain Min/Max:", "HP to restored to target (tower only)");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            effect.HPGainMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.HPGainMin);
            effect.HPGainMax=EditorGUI.FloatField(new Rect(startX+spaceX+40, startY, 40, height), effect.HPGainMax);

            cont=new GUIContent("Buff:", "Buffs to be applied to the target (tower only)");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                cont=new GUIContent(" - Damage Buff:", "Damage buff multiplier. Takes value from 0 and above with 0.4 being increase damage by 40%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.damageBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.damageBuff);

                cont=new GUIContent(" - Range Buff:", "Range buff multiplier. Takes value from 0 and above with 0.3 being increase effective range by 30%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.rangeBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.rangeBuff);

                cont=new GUIContent(" - Cooldown Buff:", "Cooldown buff multiplier. Takes value from 0 and above with 0.5 being decrease attack cooldown by 50%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                effect.cooldownBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), effect.cooldownBuff);

            return new Vector2(startX, startY);
        }
		public AbilityEffect GetActiveEffect(){
			AbilityEffect eff=new AbilityEffect();
			eff.duration=effect.duration * (1+PerkManager.GetAbilityDuration(ID));
			eff.damageMin=effect.damageMin * (1+PerkManager.GetAbilityDamage(ID));
			eff.damageMax=effect.damageMax * (1+PerkManager.GetAbilityDamage(ID));
			eff.stunChance=effect.stunChance * (1+PerkManager.GetAbilityStunChance(ID));
			
			eff.slow=PerkManager.ModifySlowWithPerkBonus(effect.slow, ID, 2);	//pass 2 to indicate this is for ability
			eff.dot=PerkManager.ModifyDotWithPerkBonus(effect.dot, ID, 2);
			
			eff.damageBuff=effect.damageBuff * (1+PerkManager.GetAbilityDamageBuff(ID));
			eff.rangeBuff=effect.rangeBuff * (1+PerkManager.GetAbilityRangeBuff(ID));
			eff.cooldownBuff=effect.cooldownBuff * (1+PerkManager.GetAbilityCooldownBuff(ID));
			eff.HPGainMin=effect.HPGainMin * (1+PerkManager.GetAbilityHPGain(ID));
			eff.HPGainMax=effect.HPGainMax * (1+PerkManager.GetAbilityHPGain(ID));
			
			return eff;
		}
		public AbilityEffect Clone(){
			AbilityEffect eff=new AbilityEffect();
			
			eff.duration=duration;
			
			eff.damageMin=damageMin;
			eff.damageMax=damageMax;
			eff.stunChance=stunChance;
			eff.slow=slow.Clone();
			eff.dot=dot.Clone();
			
			eff.slow.duration=eff.duration;
			eff.dot.duration=eff.duration;
			
			eff.damageBuff=damageBuff;
			eff.rangeBuff=rangeBuff;
			eff.cooldownBuff=cooldownBuff;
			eff.HPGainMin=HPGainMin;
			eff.HPGainMax=HPGainMax;
			
			return eff;
		}