Ejemplo n.º 1
0
    /// <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);
    }
Ejemplo n.º 2
0
    /// <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());
        }
    }
Ejemplo n.º 4
0
    /// <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);
    }
Ejemplo n.º 5
0
    /// <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);
        }
    }
Ejemplo n.º 6
0
    /// <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);
        }
    }
Ejemplo n.º 7
0
    /// <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);
        }
    }
Ejemplo n.º 8
0
        //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;
        }
Ejemplo n.º 9
0
    /// <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);
    }
Ejemplo n.º 11
0
 public void Play(SFXObject DesiredSFX)
 {
     SFXManager.Main.Play(DesiredSFX);
 }
Ejemplo n.º 12
0
 /// <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()));
 }
Ejemplo n.º 13
0
 /// <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));
 }
Ejemplo n.º 14
0
    /// <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);
    }
Ejemplo n.º 15
0
    /// <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);
    }
Ejemplo n.º 16
0
 /// <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));
 }
Ejemplo n.º 17
0
 /// <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));
 }
Ejemplo n.º 18
0
 /// <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));
 }