Beispiel #1
0
        public void MenuScreenEvent(Object o, EventArgs e)
        {
            ScreenDir destination = (ScreenDir)o;
            switch (destination)
            {
                case ScreenDir.Play:

                    gameScreen = new GameScreen(new EventHandler(GameScreenEvent), this.Content);
                    gameScreen.LoadContent(Content);
                    currentScreen = gameScreen;
                    break;
                case ScreenDir.Options:
                    currentScreen = optionsScreen;
                    break;
                case ScreenDir.HighScore:
                    highscoreScreen.SetHighScoreLabel();
                    currentScreen = highscoreScreen;
                    break;
                case ScreenDir.Quit:
                    this.Exit();
                    break;
            }
        }
Beispiel #2
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()
        {
            // TODO: Add your initialization logic here
            menuScreen = new MenuScreen(new EventHandler(MenuScreenEvent));
            gameScreen = new GameScreen(new EventHandler(GameScreenEvent),this.Content);
            optionsScreen = new OptionsScreen(new EventHandler(OptionsScreenEvent), this.graphics);
            highscoreScreen = new HighScoreScreen(new EventHandler(HighScoreScreenEvent), this.Content);
            currentScreen = menuScreen;

            ShapeGenerator.SetGraphicsDevice(this.GraphicsDevice);

            //////////////////////GLOBAL VARIALBLEZ///////////////////
            // Sets the preferred resolution which get used as a basis for game
            // A scale matrix of 1.0f will run at this resolution
            // Xbox resolution / hd resolution is 1280x720 by default
            CUtil.SCREEN_HEIGHT_PREFMAX = 720;
            CUtil.SCREEN_WIDTH_PREFMAX = 1280;

            // Set the default resolutions
            graphics.PreferredBackBufferHeight = CUtil.SCREEN_HEIGHT_PREFMAX;
            graphics.PreferredBackBufferWidth = CUtil.SCREEN_WIDTH_PREFMAX;

            // Set the default scale matrix
            CUtil.ScaleMatrix = Matrix.CreateScale(1.0f);

            CUtil.GraphicsDevice = this.GraphicsDevice;
            CUtil.ContentManager = this.Content;
            CUtil.Graphics = this.graphics;

            if (Options.IsFullScreen)
            {
                graphics.IsFullScreen = Options.IsFullScreen;
                CUtil.SetResolution(CUtil.FullScreenResolution.X, CUtil.FullScreenResolution.Y);
            }
            else
            {
                CUtil.SetResolution(CUtil.InitalResolution.X, CUtil.InitalResolution.Y);
            }

            if (Options.IsLetterBox)
                CUtil.EnableLetterBox();

            CUtil.GenerateMOTD();
            ///////////////////////////////////////////////

            graphics.ApplyChanges();

            MySerializer.SaveConfig();

            base.Initialize();
        }