예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
0
        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;
        }
예제 #4
0
        /// <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();
        }
예제 #5
0
        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
            {

            }
        }
예제 #6
0
        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;
        }