Пример #1
0
 /// <summary>
 /// Stores an option for the game.  Use this for something like screen resolution, music volume, sound volume, etc.
 /// Automatically casts the value to a string!
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public object SetOption(string key, object value)
 {
     if (GameOptions.ContainsKey(key))
     {
         GameOptions[key] = value.ToString();
         return(value);
     }
     GameOptions.Add(key, value.ToString());
     return(value);
 }
Пример #2
0
 /// <summary>
 /// Retrieve an option from the game options but return a default value if that value isn't found.
 /// </summary>
 /// <param name="key">The key to search for.</param>
 /// <param name="onNull">The default value to reutn if that key isn't found.</param>
 /// <returns>The value on the key, or the default value if no key is found.</returns>
 public string GetOption(string key, string onNull = "")
 {
     if (GameOptions.ContainsKey(key))
     {
         return(GameOptions[key]);
     }
     else
     {
         GameOptions.Add(key, onNull);
         return(onNull);
     }
 }