public override void Draw(GameTime gameTime) { base.Draw(gameTime); if (State != ScreenState.Hidden) { var sceneObjects = (from s in VisualObjects where s.Visible orderby s.DrawOrder ascending select s).ToList(); foreach (VisualObject vo in sceneObjects) { vo.Draw(gameTime); } if (State == ScreenState.TransitionOn || State == ScreenState.TransitionOff || State == ScreenState.Behind) { // Use our Custom one unless they have their own hooked if (OnScreenTransition != null) { OnScreenTransition.Invoke(); } else { SpriteBatch.Begin(SpriteSortMode, BlendState.AlphaBlend); SpriteBatch.Draw(black, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), new Color(255, 255, 255, screenAlpha)); SpriteBatch.End(); } } } }
/*----------Functions----------*/ //PROTECTED /// <summary> /// Process the transition between active screens /// </summary> protected override void TransitionToPendingScreen() { // Reset the active control elements GUIUtility.hotControl = GUIUtility.keyboardControl = 0; // Get the hash keys for the different elements int toHash = transitionTo.GetHashCode(); int fromHash = (activeScreen != null ? activeScreen.GetHashCode() : 0); // Close out the previous screen if it was in use if (activeScreen != null && stateScreens.ContainsKey(fromHash) && stateScreens[fromHash] != null) { stateScreens[fromHash].OnClose(Data); } // Raise the state changed event OnScreenTransition?.Invoke(this, new ScreenStateTransitionEventArgs( transitionTo, stateScreens.ContainsKey(toHash) ? stateScreens[toHash] : null, activeScreen, activeScreen != null && stateScreens.ContainsKey(fromHash) ? stateScreens[fromHash] : null )); // Set the required values activeScreen = transitionTo; transitionTo = null; // Open the new screen for display if it can if (stateScreens.ContainsKey(toHash) && stateScreens[toHash] != null) { stateScreens[toHash].OnOpened(Data); } }