public void ChangeDefinition(Options opti) { definitions = new Dictionary<Key, Keys>(); definitions.Add(Key.Up, opti.Up); definitions.Add(Key.Down, opti.Down); definitions.Add(Key.Left, opti.Left); definitions.Add(Key.Right, opti.Right); definitions.Add(Key.A, opti.A); definitions.Add(Key.B, opti.B); definitions.Add(Key.Start, opti.Start); }
public Options Clone() { Options newOptions = new Options(); newOptions.sound = sound; newOptions.music = music; newOptions.volume = volume; newOptions.fullscreen = fullscreen; newOptions.Up = Up; newOptions.Down = Down; newOptions.Left = Left; newOptions.Right = Right; newOptions.A = A; newOptions.B = B; newOptions.Start = Start; return newOptions; }
Options LoadOptions() { Options opti = new Options(); try { XmlSerializer xS = new XmlSerializer(typeof(Options)); FileStream fS = new FileStream("options.xml", FileMode.Open); XmlTextReader xTR = new XmlTextReader(fS); opti = (Options)xS.Deserialize(xTR); fS.Close(); } catch (Exception) { } return opti; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { controls = new Controls(); globalRandom = new Random(); savedGame = LoadGame(); options = LoadOptions(); ActivateOptions(options); base.Initialize(); }
public void SaveOptions(Options opt) { XmlSerializer xS = new XmlSerializer(typeof(Options)); try { StreamWriter sW = new StreamWriter("options.xml"); xS.Serialize(sW, opt); sW.Close(); } catch { } }
public void ActivateOptions(Options opt) { PlaySound.enabled = opt.sound; PlaySong.enabled = opt.music; PlaySong.SetVolume(opt.volume); controls.ChangeDefinition(opt); ToggleFullScreen(opt.fullscreen); options = opt; }