/// <summary>Delays the playing of an SFXObject.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <returns>The Coroutine for delaying this SFXObject.</returns> public Coroutine PlaySuspended(SFXObject SFX, float DelayDuration, float Volume, float Pitch) { SequencedStartJobs.RemoveAll((Coroutine x) => x == null); Coroutine StartJob = StartCoroutine(DelayedPlay(SFX, DelayDuration, Volume, Pitch)); SequencedStartJobs.Add(StartJob); return(StartJob); }
/// <summary>Delays the playing of an SFXObject.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <param name="Parent">Parent transform to assign to the SFXObject (Optional).</param> /// <param name="IsGlobalPosition">If the position to play the SFXObject at is global or local to the parent.</param> /// <returns>The Coroutine for delaying this SFXObject.</returns> public Coroutine PlaySuspended(SFXObject SFX, Vector3 Position, float DelayDuration, float Volume, float Pitch, Transform Parent = null, bool IsGlobalPosition = true) { SequencedStartJobs.RemoveAll((Coroutine x) => x == null); Coroutine StartJob = StartCoroutine(DelayedPlay(SFX, Position, DelayDuration, Volume, Pitch, Parent, IsGlobalPosition)); SequencedStartJobs.Add(StartJob); return(StartJob); }
public IEnumerator PlaySFX(SFXObject sFX, float delay) { yield return(new WaitForSeconds(delay)); SFXManager.Main.Play(sFX); if (!Defender.IsAI && !IsHealing) { SFXManager.Main.Play(Defender.Actor.DamageVoices.Get()); } }
/// <summary>Finds the desired SFXObject in the SFXManager's Library.</summary> /// <param name="SFXName">The name of the SFXObject in the SFXObjectLibrary.</param> /// <returns>The retrieved SFXObject.</returns> private SFXObject FindSFXObjectInLibrary(string SFXName) { SFXObject DesiredSFXObject = SFXObjectLibrary.FirstOrDefault((SFXObject x) => x.SFXName == SFXName); if (DesiredSFXObject == null) { Debug.LogError("No SFXObject named '" + SFXName + "' was found in the SFXObjectLibrary of the SFXManager."); } return(DesiredSFXObject); }
/// <summary>Plays an SFXObject from the SFXObjectLibrary on the SFXManager with the default delay settings.</summary> /// <param name="SFXName">The name of the SFXObject in the SFXObjectLibrary.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine PlayFromSFXObjectLibrary(string SFXName) { SFXObject DesiredSFXObject = FindSFXObjectInLibrary(SFXName); if (DesiredSFXObject != null) { return(Play(DesiredSFXObject)); } else { return(null); } }
/// <summary>Plays an SFXObject from the SFXObjectLibrary on the SFXManager in 3D space.</summary> /// <param name="SFXName">The name of the SFXObject in the SFXObjectLibrary.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <param name="Parent">Parent transform to assign to the SFXObject (Optional).</param> /// <param name="IsGlobalPosition">If the position to play the SFXObject at is global or local to the parent.</param> /// <returns>The Coroutine for delaying this SFXObject.</returns public Coroutine PlayFromSFXObjectLibrary(string SFXName, Vector3 Position, float DelayDuration, float Volume, float Pitch, Transform Parent = null, bool IsGlobalPosition = true) { SFXObject DesiredSFXObject = FindSFXObjectInLibrary(SFXName); if (DesiredSFXObject != null) { return(Play(DesiredSFXObject, Position, DelayDuration, Volume, Pitch, Parent, IsGlobalPosition)); } else { return(null); } }
/// <summary>Plays an SFXObject from the SFXObjectLibrary on the SFXManager.</summary> /// <param name="SFXName">The name of the SFXObject in the SFXObjectLibrary.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <returns>The Coroutine for delaying this SFXObject.</returns public Coroutine PlayFromSFXObjectLibrary(string SFXName, float DelayDuration, float Volume, float Pitch) { SFXObject DesiredSFXObject = FindSFXObjectInLibrary(SFXName); if (DesiredSFXObject != null) { return(Play(DesiredSFXObject, DelayDuration, Volume, Pitch)); } else { return(null); } }
//Initialises inspector private void OnEnable() { //Retrieves the SFXObject and adds a SFXLayer if none are present SFXObjectInstance = (SFXObject)target; if (SFXObjectInstance.SFXLayers == null || SFXObjectInstance.SFXLayers.Length == 0) { SFXObjectInstance.SFXLayers = new SFXLayer[1]; } //Caches serialised properties SFXName = serializedObject.FindProperty("SFXName"); FixedVolume = serializedObject.FindProperty("FixedVolume"); MinVolume = serializedObject.FindProperty("MinVolume"); MaxVolume = serializedObject.FindProperty("MaxVolume"); RandomizeVolume = serializedObject.FindProperty("RandomizeVolume"); FixedPitch = serializedObject.FindProperty("FixedPitch"); MinPitch = serializedObject.FindProperty("MinPitch"); MaxPitch = serializedObject.FindProperty("MaxPitch"); RandomizePitch = serializedObject.FindProperty("RandomizePitch"); DelaySFX = serializedObject.FindProperty("DelaySFX"); FixedDelay = serializedObject.FindProperty("FixedDelayTime"); MinDelay = serializedObject.FindProperty("MinDelayTime"); MaxDelay = serializedObject.FindProperty("MaxDelayTime"); RandomizeDelay = serializedObject.FindProperty("RandomizeDelay"); SFXLayers = serializedObject.FindProperty("SFXLayers"); LimitPolyphony = serializedObject.FindProperty("LimitPolyphony"); MaxVoices = serializedObject.FindProperty("MaxVoices"); MinSeparation = serializedObject.FindProperty("MinSeparation"); //Creates the Edition list display SFXLayerListDisplay = new ReorderableList(serializedObject, SFXLayers, true, true, true, true); //Overrides list drawing SFXLayerListDisplay.onAddCallback = AppendNewSFXLayer; SFXLayerListDisplay.drawHeaderCallback = DrawSFXLayerListHeader; SFXLayerListDisplay.drawElementCallback = DrawSFXLayerInspector; SFXLayerListDisplay.elementHeightCallback = DetermineSFXLayerInspectorHeight; }
/// <summary>Determines which SFXObject will be played next.</summary> private void SelectNext() { int NewID = 0; switch (Randomization) { //Selects random case RandomMode.AllowRepeats: NewID = SFXObjectsToPlay.RandomIndex(); break; //Selects random until a new SFXObject is selected case RandomMode.DisallowRepeats: do { NewID = SFXObjectsToPlay.RandomIndex(); } while (NewID == LastID); break; case RandomMode.FullyUnique: { //Moves to the next SFXObject NewID = LastID + 1; if (NewID >= SFXObjectsToPlay.Count) { //Loops back and randomizes list SFXObject LastSFX = SFXObjectsToPlay[LastID]; NewID -= SFXObjectsToPlay.Count; do { SFXObjectsToPlay.Randomize(); } while (SFXObjectsToPlay[0] != LastSFX); } break; } } //Updates ID LastID = NewID; }
public IEnumerator PlaySFX(SFXObject sFX, float delay) { yield return(new WaitForSeconds(delay)); SFXManager.Main.Play(sFX); }
public void Play(SFXObject DesiredSFX) { SFXManager.Main.Play(DesiredSFX); }
/// <summary>Plays an SFXObject with the default delay settings.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine Play(SFXObject SFX) { return(Play(SFX, SFX.GetDelayDuration())); }
/// <summary>Plays an SFXObject.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine Play(SFXObject SFX, float DelayDuration) { return(SFX.Play(DelayDuration)); }
/// <summary>Plays the SFXObject after the specified delay.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <param name="Parent">Parent transform to assign to the SFXObject (Optional).</param> /// <param name="IsGlobalPosition">If the position to play the SFXObject at is global or local to the parent.</param> private IEnumerator DelayedPlay(SFXObject SFX, Vector3 Position, float DelayDuration, float Volume, float Pitch, Transform Parent = null, bool IsGlobalPosition = true) { yield return(new WaitForUnpausedSeconds(DelayDuration)); Play(SFX, Position, 0, Volume, Pitch, Parent, IsGlobalPosition); }
/// <summary>Plays the SFXObject after the specified delay.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> private IEnumerator DelayedPlay(SFXObject SFX, float DelayDuration, float Volume, float Pitch) { yield return(new WaitForUnpausedSeconds(DelayDuration)); Play(SFX, 0, Volume, Pitch); }
/// <summary>Plays an SFXObject.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine Play(SFXObject SFX, float DelayDuration, float Volume, float Pitch) { return(SFX.Play(DelayDuration, Volume, Pitch)); }
/// <summary>Plays an SFXObject with the default delay settings.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="Parent">Parent transform to assign to the SFXObject (Optional).</param> /// <param name="IsGlobalPosition">If the position to play the SFXObject at is global or local to the parent.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine Play(SFXObject SFX, Vector3 Position, Transform Parent = null, bool IsGlobalPosition = true) { return(Play(SFX, Position, SFX.GetDelayDuration(), Parent, IsGlobalPosition)); }
/// <summary>Plays an SFXObject.</summary> /// <param name="SFX">The SFXObject to play.</param> /// <param name="Position">The position in 3D space to play the SFXObject at.</param> /// <param name="DelayDuration">Duration of the global delay for the SFXObject.</param> /// <param name="Volume">The volume multiplier of the SFXObject to be used.</param> /// <param name="Pitch">The pitch multiplier of the SFXObject to be used.</param> /// <param name="Parent">Parent transform to assign to the SFXObject (Optional).</param> /// <param name="IsGlobalPosition">If the position to play the SFXObject at is global or local to the parent.</param> /// <returns>The Coroutine for delaying this SFXObject (null if no delay is applied).</returns> public Coroutine Play(SFXObject SFX, Vector3 Position, float DelayDuration, float Volume, float Pitch, Transform Parent = null, bool IsGlobalPosition = true) { return(SFX.Play(Position, DelayDuration, Volume, Pitch, Parent, IsGlobalPosition)); }