/// <summary> /// A coroutine for repeating an emanation on a delay X times. /// </summary> /// <param name="impulse"></param> /// <param name="delay"></param> /// <param name="count"></param> /// <returns></returns> public IEnumerator RepeatedEmanations(ImpulseGenerator.Impulse impulse, float delay, int count) { impulse.Play(); for (int i = 0; i < count - 1; i++) { yield return(new WaitForSeconds(delay)); impulse.Play(); } }
/// <summary> /// Begins an emanation at the nearest flag from the point. /// Has support for repetitions /// </summary> /// <param name="point">A point near the player's body</param> /// <param name="sequence">The HapticSequence to play on each pad visited.</param> /// <param name="impulseDuration">How long the entire impulse takes to visit each step of the depth</param> /// <param name="depth">The depth of the emanating impulse</param> /// <param name="repeats">Support for repeated impulse</param> /// <param name="delayBetweenRepeats">Do we delay between the impulse plays (delay of 0 will play all at once, having no effect)</param> /// <param name="maxDistance">Will not return locations further than the max distance.</param> public void HitImpulse(Vector3 point, HapticSequence sequence, float impulseDuration = .2f, int depth = 2, int repeats = 0, float delayBetweenRepeats = .15f, float maxDistance = 5.0f) { AreaFlag loc = FindNearestFlag(point, maxDistance); if (loc != AreaFlag.None) { ImpulseGenerator.Impulse imp = ImpulseGenerator.BeginEmanatingEffect(loc, depth).WithEffect(sequence).WithDuration(impulseDuration); if (repeats > 0) { StartCoroutine(RepeatedEmanations(imp, delayBetweenRepeats, repeats)); } else { imp.Play(); } } else { Debug.LogWarning("Invalid Hit at " + point + "\n"); } }
/// <summary> /// A coroutine for playing an impulse AFTER a float delay. /// </summary> /// <param name="impulse"></param> /// <param name="delay"></param> /// <returns></returns> IEnumerator DelayEmanation(ImpulseGenerator.Impulse impulse, float delay) { yield return(new WaitForSeconds(delay)); impulse.Play(); }