Exemplo n.º 1
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager,
                                 GameScreen screenToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            screenToLoad);

            screenManager.AddScreen(loadingScreen);
        }
Exemplo n.º 2
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //Apply settings
            graphics.IsFullScreen = Settings.IsFullScreen;
            if (graphics.IsFullScreen)
            {
                graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }
            else
            {
                //graphics.PreferredBackBufferWidth = Settings.DefaultWindowWidth;
                //graphics.PreferredBackBufferHeight = Settings.DefaultWindowHeight;
                graphics.PreferredBackBufferWidth = 1024;
                graphics.PreferredBackBufferHeight = 768;

            }

            graphics.ApplyChanges();

            //Determine scaling factor. Calculate based on height only (game should fit on 4:3 screens, so
            //height is the main concern when scaling to 16:10 or 16:9. The scaling factor should take into
            //account the 10% border we will assume around the bottom of the screen.
            Settings.ScalingFactor = (float)(graphics.PreferredBackBufferHeight - graphics.PreferredBackBufferHeight * 0.1) / (float)Settings.DefaultWindowHeight;

            //Determine offset so the game will be drawn in the center of the screen.

            Window.Title = Settings.GameTitle;

            //Set up the game objects.
            Components.Add(new GameManagement.InputHandler(this));
            screenManager = new GameManagement.ScreenManager(this);
            Components.Add(screenManager);

            //Add game screens
            screenManager.AddScreen(new Screens.MainMenuScreen());
        }
Exemplo n.º 3
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //Apply settings
            graphics.IsFullScreen = Settings.IsFullScreen;
            if (graphics.IsFullScreen)
            {
                graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }
            else
            {
                //graphics.PreferredBackBufferWidth = Settings.DefaultWindowWidth;
                //graphics.PreferredBackBufferHeight = Settings.DefaultWindowHeight;
                graphics.PreferredBackBufferWidth  = 1024;
                graphics.PreferredBackBufferHeight = 768;
            }

            graphics.ApplyChanges();

            //Determine scaling factor. Calculate based on height only (game should fit on 4:3 screens, so
            //height is the main concern when scaling to 16:10 or 16:9. The scaling factor should take into
            //account the 10% border we will assume around the bottom of the screen.
            Settings.ScalingFactor = (float)(graphics.PreferredBackBufferHeight - graphics.PreferredBackBufferHeight * 0.1) / (float)Settings.DefaultWindowHeight;

            //Determine offset so the game will be drawn in the center of the screen.

            Window.Title = Settings.GameTitle;

            //Set up the game objects.
            Components.Add(new GameManagement.InputHandler(this));
            screenManager = new GameManagement.ScreenManager(this);
            Components.Add(screenManager);


            //Add game screens
            screenManager.AddScreen(new Screens.MainMenuScreen());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor is private, the Loading Screen should be called via the static Load() method.
 /// </summary>
 /// <param name="screenManager">The Screen Manager that the GameScreen should be loaded to.</param>
 /// <param name="screenToLoad">The Screen that needs to be loaded.</param>
 private LoadingScreen(ScreenManager screenManager,
     GameScreen screenToLoad)
 {
     this.screenToLoad = screenToLoad;
 }