/// <summary> /// Plays the particle effect /// </summary> protected void DoPlay(ParticleEffectMapping p) { switch (p.effectType) { case ParticleEffectType.ATTACHED_TO_CHARACTER: p.particleSystem.Stop(); if (!p.isStop) { p.particleSystem.Play(); } break; case ParticleEffectType.DETACHED_FROM_CHARACTER: p.particleSystem.transform.parent = null; p.particleSystem.transform.position = ((Component)myCharacter).transform.position + new Vector3(myCharacter.LastFacedDirection * p.offset.x, p.offset.y, p.offset.z); p.particleSystem.Stop(); if (!p.isStop) { p.particleSystem.Play(); } break; case ParticleEffectType.INSTANTIATE_NEW_INSTANCE: GameObject go = (GameObject)GameObject.Instantiate(p.particleSystem.gameObject, p.particleSystem.transform.position, p.particleSystem.transform.rotation); ParticleSystem newPs = go.GetComponent <ParticleSystem>(); // NOTE Note we don't pool here or do anything to force this particle system to destroy or disable itself if (newPs != null) { newPs.Play(); } break; } }
/// <summary> /// Play the sound at an interval. /// </summary> protected IEnumerator RepeatEffect(ParticleEffectMapping p) { yield return(true); DoPlay(p); while (true) { if (TimeManager.Instance.Paused) { yield return(true); } else { yield return(new WaitForSeconds(p.repeatInterval)); // Recheck state if (!TimeManager.Instance.Paused && p.state == myCharacter.AnimationState && (p.groundLayer == 0 || ((1 << myCharacter.GroundLayer) & p.groundLayer) == (1 << myCharacter.GroundLayer))) { DoPlay(p); } } } }