Exemple #1
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()
        {
            base.Initialize();
            //Set the resolution
            graphics.PreferredBackBufferWidth  = 80 * 16;
            graphics.PreferredBackBufferHeight = 60 * 16;
            graphics.ApplyChanges();
            //Give the pixel art sharper edges
            GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
            //Create all the rooms for room transitioning.
            rooms.Add("GameRoom", new GameRoom());
            rooms.Add("MainRoom", new MainRoom());
            rooms.Add("SelectionRoom", new SelectionRoom());
            //Loads old settings.
            bool mute    = false;
            int  setting = 10;

            try {
                string[] lines = System.IO.File.ReadAllLines("./savefile");
                highScore = int.Parse(lines[0]);
                setting   = int.Parse(lines[1]);
                mute      = bool.Parse(lines[2]);
            } catch (Exception e) {
                //Use defaults.
            }
            rooms.Add("SettingsRoom", new SettingsRoom(setting, mute));
            //Start at the main menu.
            activeRoom = rooms["MainRoom"];
            curRoom    = "MainRoom";
        }
Exemple #2
0
 public void SwitchRooms(string room)
 {
     if (rooms.ContainsKey(room))
     {
         prevRoom   = curRoom;
         activeRoom = rooms[room];
         curRoom    = room;
     }
 }
        //Switches to the last room
        public void SelectRoomTwo()
        {
            BaseRoom room = Game1.mainGame.GetRoom("GameRoom");

            if (room.GetType().Equals(typeof(GameRoom)))
            {
                GameRoom game = (GameRoom)room;
                game.SetBuild(1);
                game.Reset();
                Game1.mainGame.SwitchRooms("GameRoom");
            }
        }
Exemple #4
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     builder = new XMLAssetBuilder(Content);
     if (mainGame == null)
     {
         mainGame = this;
         //It's going to upset a couple of people but for the sake of playing animations as expected 60FPS is the way to go
         IsFixedTimeStep = true;
         activeRoom      = null;
         rooms           = new Dictionary <string, BaseRoom>();
     }
 }
        //Updates all the buttons
        public override void Update(GameTime gameTime)
        {
            BaseRoom room = Game1.mainGame.GetRoom("GameRoom");

            if (room.GetType().Equals(typeof(GameRoom)))
            {
                GameRoom      game  = (GameRoom)room;
                KeyboardState state = Keyboard.GetState();
                selectL.Update(gameTime);
                selectR.Update(gameTime);
                PlayerSelect(game);
                select1.Update(gameTime);
                select2.Update(gameTime);
                Game1.mainGame.prevState = state;
            }
        }