Exemplo n.º 1
0
        public void Remove(ManagedGameComponent component)
        {
            Components.Remove(component);
            _ComponentsToUpdate.Remove(component);

            component.ComponentManager = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private Loader(ManagedGameComponent screenManager, 
                          ManagedGameComponent loadingScreen,
                          ManagedGameComponent[] screensToLoad)
        {
            this._LoadingScreen = loadingScreen;
            this._ScreensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private Loader(ManagedGameComponent screenManager,
                       ManagedGameComponent loadingScreen,
                       ManagedGameComponent[] screensToLoad)
        {
            this._LoadingScreen = loadingScreen;
            this._ScreensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ManagedGameComponent componentManager, 
                                ManagedGameComponent loadingScreen,
                                params ManagedGameComponent[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (ManagedGameComponent screen in componentManager.Components)
                screen.ExitScreen();

            // Create and activate the loading screen.
            Loader _Loader = new Loader(componentManager,loadingScreen,screensToLoad);

            componentManager.Add(_Loader);
        }
Exemplo n.º 5
0
 public void Add(ManagedGameComponent component)
 {
     if (component.ComponentManager == null)
     {
         component.ComponentManager = this;
         component.IsExiting        = false;
         Components.Add(component);
     }
     else
     {
         //exception here?
         //throw new Exception("Component is already being managed by another component");
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Allows the screen to run logic, such as updating the transition position.
        /// Unlike HandleInput, this method is called regardless of whether the screen
        /// is active, hidden, or in the middle of a transition.
        /// </summary>
        ///

        public override void Update(GameTime gameTime)
        {
            // Read the keyboard and gamepad.
            //input.Update();

            // Make a copy of the master screen list, to avoid confusion if
            // the process of updating one screen adds or removes others.
            _ComponentsToUpdate.Clear();

            foreach (ManagedGameComponent screen in Components)
            {
                _ComponentsToUpdate.Add(screen);
            }

            bool otherScreenHasFocus  = !Game.IsActive;
            bool coveredByOtherScreen = false;

            // Loop as long as there are screens waiting to be updated.
            while (_ComponentsToUpdate.Count > 0)
            {
                // Pop the topmost screen off the waiting list.
                ManagedGameComponent screen = _ComponentsToUpdate[_ComponentsToUpdate.Count - 1];

                _ComponentsToUpdate.RemoveAt(_ComponentsToUpdate.Count - 1);

                // Update the screen.
                screen.Update(gameTime);
                screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

                if (screen.ScreenState == ScreenState.TransitionOn ||
                    screen.ScreenState == ScreenState.Active)
                {
                    // If this is the first active screen we came across,
                    // give it a chance to handle input.
                    if (!otherScreenHasFocus)
                    {
                        //screen.HandleInput(input);

                        otherScreenHasFocus = true;
                    }

                    // If this is an active non-popup, inform any subsequent
                    // screens that they are covered by it.
                    if (!screen.IsPopup)
                    {
                        coveredByOtherScreen = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ManagedGameComponent componentManager,
                                ManagedGameComponent loadingScreen,
                                params ManagedGameComponent[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (ManagedGameComponent screen in componentManager.Components)
            {
                screen.ExitScreen();
            }

            // Create and activate the loading screen.
            Loader _Loader = new Loader(componentManager, loadingScreen, screensToLoad);

            componentManager.Add(_Loader);
        }
Exemplo n.º 8
0
        public void Remove(ManagedGameComponent component)
        {
            Components.Remove(component);
            _ComponentsToUpdate.Remove(component);

            component.ComponentManager = null;
        }
Exemplo n.º 9
0
 public void Add(ManagedGameComponent component)
 {
     if (component.ComponentManager == null)
     {
         component.ComponentManager = this;
         component.IsExiting = false;
         Components.Add(component);
     }
     else
     {
         //exception here?
         //throw new Exception("Component is already being managed by another component");
     }
 }