Beispiel #1
0
        /// <summary>
        /// Creates a new instance of JoshoEngine.
        /// </summary>
        /// <param name="game">Game class to inject the JoshoEngine into.</param>
        /// <param name="initialScreen">The initial GameScreen to add.</param>
        public static void CreateEngine(Game game, GameScreen initialScreen)
        {
            if (!engineRunning)
            {
                Debug.WriteLine("[JoshoEngine] Injecting engine...");

                // Create the screen manager component.
                myScreenManager = new ScreenManager(game);

				myScreenManager.Initialize ();

                // Add the screen manager to the component stack.
                game.Components.Add(myScreenManager);

                // We've started the engine!
                engineRunning = true;

                Debug.WriteLine("[JoshoEngine] Injected new engine instance.");

                // Add the initial screen to the ScreenManager
                myScreenManager.AddScreen(initialScreen);
            }
            else
                Debug.WriteLine("[JoshoEngine] Engine instance already created!");
        }
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if (isInitialized)
            {
                screen.UnloadContent();
            }

            screens.Remove(screen);
            screensToUpdate.Remove(screen);

            // if there is a screen still in the manager, update TouchPanel
            // to respond to gestures that screen is interested in.
            if (screens.Count > 0)
            {
            }
        }
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen)
        {
            screenLoaded = false;

            screen.ControllingPlayer = null;
            screen.ScreenManager = this;
            screen.IsExiting = false;

            // If we have a graphics device, tell the screen to load content.
            if (isInitialized)
            {
                screen.LoadContent();
            }

            screens.Add(screen);

            screenLoaded = true;
        }