public AbilityEffect Clone() { AbilityEffect eff = new AbilityEffect(); eff.duration = duration; eff.dodgeChance = dodgeChance; eff.effectAtTarget = effectAtTarget; //eff.stat = stat.Clone(); 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); }
public AbilityEffect GetActiveEffect() { AbilityEffect eff = effect.Clone(); 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); }
//apply the ability effect, damage, stun, buff and so on IEnumerator ApplyAbilityEffect(Ability ab, Vector3 pos = default(Vector3), Unit target = null) { yield return(new WaitForSeconds(ab.effectDelay)); LayerMask mask = ab.customMask; List <Unit> unitList = new List <Unit>(); //List<Unit> towerList = new List<Unit>(); if (target) { unitList.Add(target); } if (ab.GetAOERadius() > 0) { 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 && !unit.dead) { unitList.Add(unit); } } } } AbilityEffect eff = ab.GetActiveEffect(); for (int n = 0; n < unitList.Count; n++) { if (eff.damageMax > 0) { unitList[n].ApplyDamage(Random.Range(eff.damageMin, eff.damageMax)); } else if (eff.stunChance > 0 && eff.duration > 0) { if (Random.Range(0f, 1f) < eff.stunChance) { unitList[n].ApplyStun(eff.duration); } } else if (eff.slow.IsValid()) { unitList[n].ApplySlow(eff.slow); } else if (eff.dot.GetTotalDamage() > 0) { unitList[n].ApplyDot(eff.dot); } if (eff.duration > 0) { if (eff.damageBuff > 0) { unitList[n].ApplyBuffDamage(eff.damageBuff, eff.duration); } if (eff.rangeBuff > 0) { unitList[n].ApplyBuffRange(eff.rangeBuff, eff.duration); } if (eff.cooldownBuff > 0) { unitList[n].ApplyBuffCooldown(eff.cooldownBuff, eff.duration); } if (eff.dodgeChance > 0) { unitList[n].ApplyBuffDodgeChance(eff.dodgeChance, eff.duration); } } else if (eff.HPGainMax > 0) { unitList[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); }
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); cont = new GUIContent(" - Dodge buff:", "Dodge buff multiplier. Takes value from 0 and above with 1 being avoid attack"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); effect.dodgeChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.dodgeChance); return(new Vector2(startX, startY)); }