private IEnumerator HandleLongTimeDamager(ITimedDamageInfo timedDmgInf, HealthChangeTyp healthChangeTyp) { IDamageInfo timeLessDmg = (IDamageInfo)timedDmgInf; while (timedDmgInf.RunTime > 0) { ChangeHealth(timeLessDmg); float secondsToWait = timedDmgInf.Frequency; yield return(new WaitForSeconds(secondsToWait)); timedDmgInf.RunTime -= secondsToWait; } }
public override void AddLongTimeDamager(ITimedDamageInfo timedDmgInf, HealthChangeTyp healthChangeTyp) { if (!ResolveLongTimeDamagerConflicts(timedDmgInf)) { return; } if (timedDmgInf.AddBehaivior == ITimedDamageInfo.AddingBehaivior.Replace) { int index = TryGetLongTimeDangerIndex(timedDmgInf.DmgTyp); if (index != -1) { RemoveLongTimeDamager(index); } dmgBuffer.Add(timedDmgInf); longTimeDamageHandler.Add(StartCoroutine(HandleLongTimeDamager(timedDmgInf, healthChangeTyp))); } else if (timedDmgInf.AddBehaivior == ITimedDamageInfo.AddingBehaivior.AddMostDangerous) { ITimedDamageInfo output; int index = TryGetNextLongTimeDanger(timedDmgInf.DmgTyp, 0, out output); if (index == -1) { dmgBuffer.Add(timedDmgInf); longTimeDamageHandler.Add(StartCoroutine(HandleLongTimeDamager(timedDmgInf, healthChangeTyp))); return; } do { if (output.Damage < timedDmgInf.Damage) { output.Damage = timedDmgInf.Damage; return; } if (output.Frequency < timedDmgInf.Frequency) { output.Frequency = timedDmgInf.Frequency; return; } index++; } while ((index = TryGetNextLongTimeDanger(timedDmgInf.DmgTyp, index, out output)) != -1); } else { dmgBuffer.Add(timedDmgInf); longTimeDamageHandler.Add(StartCoroutine(HandleLongTimeDamager(timedDmgInf, healthChangeTyp))); } }
public abstract void AddLongTimeDamager(ITimedDamageInfo timedDmgInf, HealthChangeTyp changeTyp);