public override void Use(GameObject target) { base.Use(target); dot = new DamageOverTimeEffect(target, 50, 0.5f, 10); target.GetComponent <Debuffs>().ServerAddDamageOverTimeEffect(dot); target.GetComponent <PlayerPawn>().movedSquaresEvent.AddListener(RefreshDamage); }
public void ServerBurn() { burnDot = new DamageOverTimeEffect(playerPawn.gameObject, 10, 0.5f, 10); burnDot.instigator = gameObject; burnDot.graphicSprite = fireSprite; playerPawn.GetComponent <Debuffs>().ServerAddDamageOverTimeEffect(burnDot); playerPawn.GetComponent <PlayerPawn>().movedSquaresEvent.AddListener(RefreshDamage); StartCoroutine(BurnRoutine()); }
IEnumerator BurnRoutine() { for (int i = 0; i < 20; i++) { yield return(new WaitForSeconds(0.5f)); burnDot.damage = (int)(burnDot.damage * 1.5f); } burnDot = null; }
IEnumerator StartDOT(DamageOverTimeEffect dot) { dot.SetActive(true); while (dot.expireTime > Time.time) { //Dont tick on first application, cause the damage numbers will clutter up yield return(new WaitForSeconds(dot.period)); health.CmdTakeDamage(dot.instigator, dot.damage * dot.stacks); } dot.SetActive(false); damageOverTimeEffects.Remove(dot); }
public void CmdAddDamageOverTimeEffect(GameObject instigator, int damage, float period, float duration) { DamageOverTimeEffect dot = new DamageOverTimeEffect(gameObject, damage, period, duration); dot.instigator = instigator; damageOverTimeEffects.Add(dot); StartCoroutine(StartDOT(dot)); if (dot.graphicSprite != null) { dot.graphicObject = Instantiate(debuffGraphicPrefab, dot.target.transform.position, Quaternion.identity); dot.graphicObject.transform.SetParent(dot.target.transform); dot.graphicObject.GetComponent <SpriteRenderer>().sprite = dot.graphicSprite; } }
void CmdApplyPoisonDamage(GameObject target) { var debuff = target.GetComponent <Debuffs>(); DamageOverTimeEffect currentEffect = null; List <DamageOverTimeEffect> toBeRemoved = new List <DamageOverTimeEffect>(); //Check if player already has a poison damage effect on the enemy //Also check if any effects are expired and need to be removed for (int i = 0; i < poisonDamageEffects.Count; i++) { if (poisonDamageEffects[i].target == target && poisonDamageEffects[i].IsActive()) { currentEffect = poisonDamageEffects[i]; } if (poisonDamageEffects[i].target == null || !poisonDamageEffects[i].IsActive()) { toBeRemoved.Add(poisonDamageEffects[i]); } } for (int i = 0; i < toBeRemoved.Count; i++) { poisonDamageEffects.Remove(toBeRemoved[i]); } if (currentEffect == null) { currentEffect = new DamageOverTimeEffect(target, (int)Mathf.Ceil(statStruct.damage * statStruct.poisonDamage), 1, 5); currentEffect.instigator = gameObject; poisonDamageEffects.Add(currentEffect); } if (currentEffect.IsActive()) { currentEffect.stacks += 1; if (currentEffect.stacks > maxPoisonStacks) { currentEffect.stacks = maxPoisonStacks; } currentEffect.RefreshDuration(); } else { debuff.ServerAddDamageOverTimeEffect(currentEffect); } }
//Function inherited from Effect.cs to trigger this effect. Sets the target as the damaged character public override void TriggerEffect(Character usingCharacter_, Character targetCharacter_, float timeDelay_ = 0) { //Reference to the effect that's got the least number of ticks left DamageOverTimeEffect lowestTickEffect = null; //Checking the targeted character to see if this effect is already applied to them and how many stacks int stackSize = 0; foreach (Effect e in targetCharacter_.charCombatStats.combatEffects) { //If we find a version of this effect already on the target if (e.effectName == this.effectName) { //We increase the current count for the number of stacks found stackSize += 1; //If the current effect's number of ticks is less than the current lowest tick effect or if the current lowest doesn't exist, this becomes the lowest if (lowestTickEffect == null || e.GetComponent <DamageOverTimeEffect>().ticksLeft < lowestTickEffect.ticksLeft) { lowestTickEffect = e.GetComponent <DamageOverTimeEffect>(); } //If the stack size found is higher than this effect's max stack size, we just refresh the ticks on the effect with the lowest if (stackSize >= this.maxStackSize) { //We refresh the duration of the effect on the target to the max number of ticks lowestTickEffect.ticksLeft = this.numberOfTicks; //And then we destroy this effect's game object Destroy(this.gameObject); } } } this.characterToEffect = targetCharacter_; this.characterWhoTriggered = usingCharacter_; //Adding this effect to the targeted character's combat effects list this.characterToEffect.charCombatStats.combatEffects.Add(this); //Determining how many ticks this effect will have (if it's not unlimited that is) if (!this.unlimitedTicks) { this.ticksLeft = this.numberOfTicks; } }
public void ServerAddDamageOverTimeEffect(DamageOverTimeEffect dot) { if (!isServer) { return; } damageOverTimeEffects.Add(dot); StartCoroutine(StartDOT(dot)); if (dot.graphicSprite != null) { dot.graphicObject = Instantiate(debuffGraphicPrefab, dot.target.transform.position, Quaternion.identity); dot.graphicObject.transform.SetParent(dot.target.transform); dot.graphicObject.GetComponent <SpriteRenderer>().sprite = dot.graphicSprite; } Debug.Log("Added"); }
public void UpdateActiveEffects() { Unit selectedUnit = PlayerManager.m_Instance.GetSelectedUnit(); UpdatePassive(); if (selectedUnit.GetInflictableStatuses().OfType <AttackBuffEffect>().Any()) { m_RagsToRichesEffect.gameObject.SetActive(true); AttackBuffEffect effect = selectedUnit.GetInflictableStatuses().OfType <AttackBuffEffect>().First(); m_RagsToRichesDescription.text = effect.m_StatusDescription.Replace("{increase}", effect.m_AttackIncrease.ToString()).Replace("{duration}", effect.m_RemainingDuration.ToString()); SetupSkin(m_RagsToRichesEffect, effect, selectedUnit); } else { m_RagsToRichesEffect.gameObject.SetActive(false); } if (selectedUnit.GetInflictableStatuses().OfType <AttackDebuffEffect>().Any()) { m_FaminesHungerEffect.gameObject.SetActive(true); AttackDebuffEffect effect = selectedUnit.GetInflictableStatuses().OfType <AttackDebuffEffect>().First(); m_FaminesHungerDescription.text = effect.m_StatusDescription.Replace("{decrease}", effect.m_AttackDecrease.ToString()).Replace("{duration}", effect.m_RemainingDuration.ToString()); SetupSkin(m_FaminesHungerEffect, effect, selectedUnit); } else { m_FaminesHungerEffect.gameObject.SetActive(false); } if (selectedUnit.GetInflictableStatuses().OfType <DamageOverTimeEffect>().Any()) { m_PestilencesMarkEffect.gameObject.SetActive(true); DamageOverTimeEffect effect = selectedUnit.GetInflictableStatuses().OfType <DamageOverTimeEffect>().First(); m_PestilencesMarkDescription.text = effect.m_StatusDescription.Replace("{damage}", effect.m_DamageOverTime.ToString()).Replace("{duration}", effect.m_RemainingDuration.ToString()); SetupSkin(m_PestilencesMarkEffect, effect, selectedUnit); } else { m_PestilencesMarkEffect.gameObject.SetActive(false); } }