private IEnumerator HaloCoroutine(float radius, float width, float speed, HaloEffectMode mode) { float step, from, to; if (mode == HaloEffectMode.Shrink) { from = radius; to = 0f; } else { from = 0f; to = radius; } step = 0f; while (step < 1f) { radius = Mathf.Lerp(from, to, step); this.body.localScale = Vector3.one * (radius * 2f); this.UpdateWidth(ref width, radius); step += speed * Time.deltaTime; yield return(null); } if (mode == HaloEffectMode.Expand) { this.StartCoroutine(this.FadeCoroutine(speed * 1.1f, true)); from = width; to = HALO_MIN_SIZE; step = 0f; while (step < 1f) { radius += speed * Time.deltaTime; this.body.localScale = Vector3.one * (radius * 2f); width = Mathf.Lerp(from, to, step); this.UpdateWidth(ref width, radius); step += HALO_WIDTH_EXPAND_SPEED * Time.deltaTime; yield return(null); } } PoolingManager.instance.Stow(this); }
public void Launch(float radius, float width, HaloEffectMode mode = HaloEffectMode.Shrink) { this.Launch(); this.UpdateWidth(ref width, radius); if (mode == HaloEffectMode.Still) { return; } this.StartCoroutine(this.HaloCoroutine(radius, width, this.haloSpeed, mode)); if (mode == HaloEffectMode.Shrink) { this.StartCoroutine(this.FadeCoroutine(this.haloSpeed * 1.75f, false)); } }