Esempio n. 1
0
 public ScreenManager()
 {
     screens = new Dictionary<String, BaseScreen>();
     transitionIn = false;
     current = null;
     next = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Transition to a new screen
        /// </summary>
        /// <param name="name">Name of the next screen</param>
        public void Transition(String name)
        {
            BaseScreen get = null;

            screens.TryGetValue(name, out get);

            if (get == null)
            {
                return;
            }

            if (current != null)
            {
                next             = get;
                transitionOut    = true;
                transInVariable  = 0.0f;
                transOutVariable = 0.0f;
            }
            else
            {
                current       = get;
                transitionOut = false;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Adds a new screen to the Dictionary
 /// </summary>
 /// <param name="name">Name of the screen for referencing</param>
 /// <param name="screen">The screen being stored</param>
 public void AddScreen(String name, BaseScreen screen)
 {
     screen.Initialize();
     screens.Add(name, screen);
 }
Esempio n. 4
0
        /// <summary>
        /// Updates the Current Screen or transition
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            if (current == null)
                return;

            // Transition to next screen
            if (transitionOut)
            {
                MediaPlayer.Stop();
                switch (current.TransitionOut)
                {
                    case TransitionType.Instant:
                        transitionOut = false;
                        transitionIn = true;
                        break;
                    case TransitionType.Fade:
                        transOutVariable += ProcessFade(1.0f, gameTime);
                        if (transOutVariable >= 1.0)
                        {
                            transOutVariable = 1.0f;
                            transitionOut = false;
                            transitionIn = true;
                        }
                        break;
                    default:
                        break;
                }

                if (current.ControlTransOut)
                    current.Update(gameTime);
            }
            // Transition from last screen
            else if (transitionIn)
            {
                switch (next.TransitionIn)
                {
                    case TransitionType.Instant:
                        transInVariable = 0.0f;
                        transOutVariable = 0.0f;
                        current = next;
                        break;
                    case TransitionType.Fade:
                        if (transInVariable <= 0.0)
                        {
                            current = next;
                        }
                        transInVariable += ProcessFade(1.0f, gameTime);
                        if (transInVariable >= 1.0)
                        {
                            transInVariable = 1.0f;
                            transitionIn = false;
                        }
                        break;
                    default:
                        transInVariable = 0.0f;
                        transOutVariable = 0.0f;
                        current = next;
                        break;
                }
                if (current.ControlTransIn)
                    current.Update(gameTime);
            }
            // Update current Screen
            else
            {
                current.Update(gameTime);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Transition to a new screen
        /// </summary>
        /// <param name="name">Name of the next screen</param>
        public void Transition(String name)
        {
            BaseScreen get = null;
            screens.TryGetValue(name, out get);

            if (get == null)
                return;

            if (current != null)
            {
                next = get;
                transitionOut = true;
                transInVariable = 0.0f;
                transOutVariable = 0.0f;
            }
            else
            {
                current = get;
                transitionOut = false;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Adds a new screen to the Dictionary
 /// </summary>
 /// <param name="name">Name of the screen for referencing</param>
 /// <param name="screen">The screen being stored</param>
 public void AddScreen(String name, BaseScreen screen)
 {
     screen.Initialize();
     screens.Add(name, screen);
 }
Esempio n. 7
0
        /// <summary>
        /// Updates the Current Screen or transition
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            if (current == null)
            {
                return;
            }

            // Transition to next screen
            if (transitionOut)
            {
                MediaPlayer.Stop();
                switch (current.TransitionOut)
                {
                case TransitionType.Instant:
                    transitionOut = false;
                    transitionIn  = true;
                    break;

                case TransitionType.Fade:
                    transOutVariable += ProcessFade(1.0f, gameTime);
                    if (transOutVariable >= 1.0)
                    {
                        transOutVariable = 1.0f;
                        transitionOut    = false;
                        transitionIn     = true;
                    }
                    break;

                default:
                    break;
                }

                if (current.ControlTransOut)
                {
                    current.Update(gameTime);
                }
            }
            // Transition from last screen
            else if (transitionIn)
            {
                switch (next.TransitionIn)
                {
                case TransitionType.Instant:
                    transInVariable  = 0.0f;
                    transOutVariable = 0.0f;
                    current          = next;
                    break;

                case TransitionType.Fade:
                    if (transInVariable <= 0.0)
                    {
                        current = next;
                    }
                    transInVariable += ProcessFade(1.0f, gameTime);
                    if (transInVariable >= 1.0)
                    {
                        transInVariable = 1.0f;
                        transitionIn    = false;
                    }
                    break;

                default:
                    transInVariable  = 0.0f;
                    transOutVariable = 0.0f;
                    current          = next;
                    break;
                }
                if (current.ControlTransIn)
                {
                    current.Update(gameTime);
                }
            }
            // Update current Screen
            else
            {
                current.Update(gameTime);
            }
        }