public override void UnregisterEffect(Creature target) { for (int i = 0; i < target.activeTimedProtections.Count; i++) { TimedProtectionContainer container = target.activeTimedProtections [i]; if (container.protection == this) { target.activeTimedProtections.Remove(container); } } Debug.Log("unregister protection: " + this.name); EffectController.instance.RecalculateProtections(target); }
private IEnumerator ApplyTimedProtection(Creature target, TimedProtectionContainer container) { TimedProtection protection = container.protection as TimedProtection; float startTime = Time.time + protection.timeToStart; float endTime = Time.time + protection.timeToStart + protection.duration; while (Time.time < startTime) { yield return(null); } protection.Perform(target); while (Time.time <= endTime) { endTime = startTime + container.timeToEnd; yield return(null); } protection.UnregisterEffect(target); }
public void StartTimedProtection(Creature target, TimedProtectionContainer protectionContainer) { StartCoroutine(ApplyTimedProtection(target, protectionContainer)); }