public virtual IEnumerator OnStart(BuffInstance instance) { OnStartBurst(instance); OnStartLoop(instance); instance.period = instance.target.StartCoroutine(OnPeriod(instance)); yield return(null); }
public void RemoveBuff(BuffInstance instance) { if (!instance.removed) { buffs.Remove(instance); instance.removed = true; } }
protected void OnStartLoop(BuffInstance instance) { if (startLoopParticle != null) { ParticleSystem ps = GameObject.Instantiate(startLoopParticle, instance.target.transform). GetComponent <ParticleSystem>(); ps.transform.localPosition = startLoopOffset; ps.Play(true); instance.startLoopParticle = ps.gameObject; } }
public virtual IEnumerator OnPeriod(BuffInstance instance) { while (!instance.canExpire || instance.duration > 0) { OnPeriodBurst(instance); instance.target.StartCoroutine(DoOnPeriod(instance)); yield return(new WaitForSeconds(periodInterval)); instance.duration -= periodInterval; } instance.Stop(); }
protected void OnPeriodBurst(BuffInstance instance) { if (periodBurstParticle != null) { if (periodBurstAttach) { ParticleSystem ps = GameObject.Instantiate(periodBurstParticle, instance.target.transform). GetComponent <ParticleSystem>(); ps.transform.localPosition = periodBurstOffset; ps.Play(true); GameObject.Destroy(ps.gameObject, ps.main.duration); } else { ParticleSystem ps = GameObject.Instantiate(periodBurstParticle, instance.target.transform.position + instance.target.transform.rotation * periodBurstOffset, instance.target.transform.rotation). GetComponent <ParticleSystem>(); ps.Play(true); GameObject.Destroy(ps.gameObject, ps.main.duration); } } }
public void AddBuff(BuffInstance instance) { buffs.Add(instance); StartCoroutine(instance.buff.OnStart(instance)); }
public virtual IEnumerator OnEnd(BuffInstance instance) { OnEndBurst(instance); yield return(null); }
protected virtual IEnumerator DoOnPeriod(BuffInstance instance) { yield return(null); }
protected override IEnumerator DoOnPeriod(BuffInstance instance) { instance.target.Heal(healthPerPeriod); yield return(null); }