Esempio n. 1
0
        public Game1()
        {
            if (!File.Exists(Path.Combine(_userConfigPath, "config.us")))
            {
                CreateUserConfig();
            }

            var config = XDocument.Load(Path.Combine(_userConfigPath, "config.us"));
            var username = config.Root.Element("Username");
            Global.PlayerName = username.Value;

            Graphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height,
                PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width,
                IsFullScreen = Global.IsFullScreen
            };

            Graphics.ApplyChanges();
            Global.DeviceInUse = Graphics;
            Content.RootDirectory = "Content";
            Global.GameInProgress = this;
            var screenManager = new ScreenManager.ScreenManager(this);

            Components.Add(screenManager);
            MediaPlayer.IsMuted = true;

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new IntroScreen(), null);
        }
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager.ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            _loadingIsSlow = loadingIsSlow;
            _screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager.ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (var screen in screenManager.GetScreens())
                screen.ExitScreen();

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

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }