Exemple #1
0
        /// <summary>
        /// Searches for the specified sound with a matching name.
        /// </summary>
        /// <returns>
        /// A reference to a sound, if found. Null reference otherwise.
        /// </returns>
        /// <remarks>
        /// <para>If multiple banks have sounds with a matching name, primary sound bank will be checked first.
        /// Within a bank, the first occurrence of found sound will be used.</para>
        /// </remarks>
        public static Sound GetSound(string name)
        {
            if (shutdown)
            {
                return(null);
            }

            // Check primary bank first
            SoundBank primaryBank = bankManager.PrimaryBank;

            if (primaryBank != null && primaryBank.ContainsAsset(name))
            {
                return(primaryBank.GetSound(name));
            }

            // Check other banks
            for (int i = 0; i < bankManager.Banks.Count; i++)
            {
                SoundBank bank = bankManager.Banks[i];

                // Skip primary bank
                if (bank == primaryBank)
                {
                    continue;
                }

                if (bank.ContainsAsset(name))
                {
                    return(bank.GetSound(name));
                }
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Registers new sound bank.
        /// </summary>
        /// <param name="bank">A reference to a sound bank to register.</param>
        /// <returns>
        /// True, if sound bank was succesfully registered. False otherwise.
        /// </returns>
        public static bool RegisterBank(SoundBank bank)
        {
            if (shutdown)
            {
                return(false);
            }

            return(bankManager.RegisterBank(bank));
        }
Exemple #3
0
        internal void Update(SoundBank bank)
        {
            for (int i = usedSounds.Count - 1; i >= 0; i--)
            {
                SoundInstance instance = usedSounds[i];
                instance.Update();

                if (!instance.Paused && !instance.Playing)
                {
                    ReleaseSound(i);
                }
            }
        }
Exemple #4
0
 internal SoundBus(SoundBank bank_, string name_)
 {
     bank = bank_;
     name = name_;
 }
Exemple #5
0
 public void OnEnable()
 {
     bank = target as SoundBank;
 }