示例#1
0
        /// <summary>
        /// Adds an SoundEffect directly into the dictionary, and assign a key to it
        /// </summary>
        /// <param name="sound">The SoundEffect object</param>
        /// <param name="keyName">The key used to refere to the item</param>
        public static SoundEffect Add(SoundEffect sound, string keyName)
        {
            // Check if the key already exists
            if (Content.ContainsKey(keyName))
            {
                throw new ArgumentException("The given key name " + keyName + " already exists in the dictionary", "keyName");
            }

            Content[keyName] = new GDSoundStorageItem(sound, keyName);

            return(sound);
        }
示例#2
0
        /// <summary>
        /// Returns a list of all the items currently stored in the GDSoundStorage class
        /// </summary>
        /// <returns>A list of all the items currently stored in the GDSoundStorage class</returns>
        public static GDSoundStorageItem[] GetAllItems()
        {
            GDSoundStorageItem[] items = new GDSoundStorageItem[Content.Count];
            int i = 0;

            // Traverse the Dictionary that holds all the animation descriptors
            foreach (KeyValuePair <string, GDSoundStorageItem> k in Content)
            {
                items[i++] = k.Value;
            }

            return(items);
        }