Exemplo n.º 1
0
        public void TransitionScreen(String name)
        {
            Screen ret = null;
            screens.TryGetValue(name, out ret);

            if (ret != null)
            {
                TransitionNextScreen = ret;

                if (CurrentScreen != null) CurrentScreen.TransitionFrom();

                transition = true;

                if (CurrentScreen != null)
                {
                    fadingOut = true;
                    alpha = 0.0f;
                }
                else
                {
                    CurrentScreen = ret;
                    fadingOut = false;
                    alpha = 1.0f;
                }

                TransitionNextScreen.TransitionTo();
            }
        }
Exemplo n.º 2
0
        public ScreenManager()
        {
            screens = new Dictionary<String, Screen>();

            CurrentScreen = null;
            TransitionNextScreen = null;
        }
Exemplo n.º 3
0
 public void AddScreen(String name, Screen screen)
 {
     screens.Add(name, screen);
 }
Exemplo n.º 4
0
        public void Update(GameTime gameTime)
        {
            if (CurrentScreen == null) return;

            if (transition)
            {
                // Fading out the current screen
                if (fadingOut)
                {
                    double dtime = gameTime.ElapsedGameTime.TotalSeconds;
                    alpha = alpha + (float)(dtime / CurrentScreen.OutTransitionTime);

                    // Do the swap (in the secrecy of the darkness!)
                    if (alpha > 1.0)
                    {
                        alpha = 1.0f;
                        fadingOut = false;

                        CurrentScreen = TransitionNextScreen;
                        TransitionNextScreen = null;
                    }
                }
                // Fading in the new screen
                else
                {
                    double dtime = gameTime.ElapsedGameTime.TotalSeconds;
                    alpha = alpha - (float)(dtime / CurrentScreen.InTransitionTime);

                    // Do the swap (in the secrecy of the darkness!)
                    if (alpha <= 0.0)
                    {
                        alpha = 0.0f;
                        transition = false;
                    }
                }
            }

            if (!fadingOut) CurrentScreen.Update(gameTime);
        }