Ejemplo n.º 1
0
        /// <summary>
        ///     Starts the fade out process for the game on play completion.
        /// </summary>
        /// <param name="gameTime"></param>
        private void HandlePlayCompletion(GameTime gameTime)
        {
            if (!Screen.Failed && !Screen.IsPlayComplete)
            {
                return;
            }

            Screen.TimeSincePlayEnded += gameTime.ElapsedGameTime.TotalMilliseconds;

            // If the play was a failure, we want to immediately show
            // a red screen.
            if (Screen.Failed && !ScreenChangedToRedOnFailure)
            {
                Transitioner.Tint  = Color.Red;
                Transitioner.Alpha = 0.65f;

                ScreenChangedToRedOnFailure = true;
            }

            // Load the results screen asynchronously, so that we don't run through any freezes.
            if (!ResultsScreenLoadInitiated)
            {
                Screen.Exit(() => new ResultScreen(Screen), 500);
                ResultsScreenLoadInitiated = true;
            }

            // Don't fade unless we're fully clear to do so.
            if (Screen.TimeSincePlayEnded <= 1200 || !ClearToExitScreen)
            {
                return;
            }

            // If the play was a failure, immediately start fading to black.
            if (Screen.Failed)
            {
                Transitioner.FadeToColor(Color.Black, gameTime.ElapsedGameTime.TotalMilliseconds, 150);
            }

            // Start fading out the screen.
            if (!FadingOnPlayCompletion)
            {
                Transitioner.Animations.Clear();

                // Get the initial alpha of the sceen transitioner, because it can be different based
                // on if the user failed or not, and use this in the Animation
                var initialAlpha = Screen.Failed ? 0.65f : 0;

                Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, initialAlpha, 1, 1000));
                FadingOnPlayCompletion = true;
            }

            if (Screen.TimeSincePlayEnded >= 3000)
            {
                // Change background dim before switching screens.
                BackgroundManager.Background.Dim = 0;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Starts the fade out process for the game on play completion.
        /// </summary>
        /// <param name="gameTime"></param>
        private void HandlePlayCompletion(GameTime gameTime)
        {
            if (!Screen.Failed && !Screen.IsPlayComplete || Screen.Exiting)
            {
                return;
            }

            Screen.TimeSincePlayEnded += gameTime.ElapsedGameTime.TotalMilliseconds;

            // If the play was a failure, we want to immediately show
            // a red screen.
            if (Screen.Failed && !ScreenChangedToRedOnFailure)
            {
                Transitioner.Tint  = Color.Red;
                Transitioner.Alpha = 0.65f;

                ScreenChangedToRedOnFailure = true;
            }

            if (!ResultsScreenLoadInitiated)
            {
                if (Screen.IsPlayTesting)
                {
                    if (AudioEngine.Track.IsPlaying)
                    {
                        AudioEngine.Track.Pause();
                        AudioEngine.Track.Seek(Screen.PlayTestAudioTime);
                    }

                    Screen.Exit(() => new EditorScreen(Screen.OriginalEditorMap));
                    ResultsScreenLoadInitiated = true;
                    return;
                }

                if (Screen.IsCalibratingOffset)
                {
                    Screen.HandleSuggestedOffsetCalculations();
                    ResultsScreenLoadInitiated = true;
                    return;
                }

                // In a multiplayer match
                if (OnlineManager.CurrentGame != null)
                {
                    try
                    {
                        var playingUsers = GetScoreboardUsers();

                        var allPlayersFinished = playingUsers.All(x => x.Processor.TotalJudgementCount == Screen.Ruleset.ScoreProcessor.TotalJudgementCount);

                        if (Screen.LastJudgementIndexSentToServer == Screen.Ruleset.ScoreProcessor.TotalJudgementCount - 1 && allPlayersFinished)
                        {
                            OnlineManager.Client.FinishMultiplayerGameSession();
                            ResultsScreenLoadInitiated = true;
                        }
                    }
                    catch (Exception e)
                    {
                        // ignored
                    }

                    return;
                }

                Screen.Exit(() =>
                {
                    if (Screen.HasQuit && ConfigManager.SkipResultsScreenAfterQuit.Value)
                    {
                        if (ModManager.Mods.HasFlag(ModIdentifier.Paused))
                        {
                            ModManager.RemoveMod(ModIdentifier.Paused);
                        }

                        return(new SelectScreen());
                    }


                    return(new ResultScreen(Screen));
                }, 500);

                ResultsScreenLoadInitiated = true;
            }

            // Don't fade unless we're fully clear to do so.
            if (Screen.TimeSincePlayEnded <= 1200 || !ClearToExitScreen)
            {
                return;
            }

            // If the play was a failure, immediately start fading to black.
            if (Screen.Failed)
            {
                Transitioner.FadeToColor(Color.Black, gameTime.ElapsedGameTime.TotalMilliseconds, 150);
            }

            // Start fading out the screen.
            if (!FadingOnPlayCompletion)
            {
                Transitioner.Animations.Clear();

                // Get the initial alpha of the sceen transitioner, because it can be different based
                // on if the user failed or not, and use this in the Animation
                var initialAlpha = Screen.Failed ? 0.65f : 0;

                Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, initialAlpha, 1, 1000));
                FadingOnPlayCompletion = true;
            }

            if (Screen.TimeSincePlayEnded >= 3000)
            {
                // Change background dim before switching screens.
                BackgroundManager.Background.Dim = 0;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Starts the fade out process for the game on play completion.
        /// </summary>
        /// <param name="gameTime"></param>
        private void HandlePlayCompletion(GameTime gameTime)
        {
            if (!Screen.Failed && !Screen.IsPlayComplete)
            {
                return;
            }

            Screen.TimeSincePlayEnded += gameTime.ElapsedGameTime.TotalMilliseconds;

            // If the play was a failure, we want to immediately show
            // a red screen.
            if (Screen.Failed && !ScreenChangedToRedOnFailure)
            {
                Transitioner.Tint  = Color.Red;
                Transitioner.Alpha = 0.65f;

                ScreenChangedToRedOnFailure = true;
            }

            if (!ResultsScreenLoadInitiated)
            {
                if (Screen.IsPlayTesting)
                {
                    if (AudioEngine.Track.IsPlaying)
                    {
                        AudioEngine.Track.Pause();
                        AudioEngine.Track.Seek(Screen.PlayTestAudioTime);
                    }

                    Screen.Exit(() => new EditorScreen(Screen.OriginalEditorMap));
                    ResultsScreenLoadInitiated = true;
                    return;
                }

                if (Screen.IsCalibratingOffset)
                {
                    Screen.HandleSuggestedOffsetCalculations();
                    ResultsScreenLoadInitiated = true;
                    return;
                }

                Screen.Exit(() =>
                {
                    if (Screen.HasQuit && ConfigManager.SkipResultsScreenAfterQuit.Value)
                    {
                        return(new SelectScreen());
                    }

                    return(new ResultScreen(Screen));
                }, 500);

                ResultsScreenLoadInitiated = true;
            }

            // Don't fade unless we're fully clear to do so.
            if (Screen.TimeSincePlayEnded <= 1200 || !ClearToExitScreen)
            {
                return;
            }

            // If the play was a failure, immediately start fading to black.
            if (Screen.Failed)
            {
                Transitioner.FadeToColor(Color.Black, gameTime.ElapsedGameTime.TotalMilliseconds, 150);
            }

            // Start fading out the screen.
            if (!FadingOnPlayCompletion)
            {
                Transitioner.Animations.Clear();

                // Get the initial alpha of the sceen transitioner, because it can be different based
                // on if the user failed or not, and use this in the Animation
                var initialAlpha = Screen.Failed ? 0.65f : 0;

                Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, initialAlpha, 1, 1000));
                FadingOnPlayCompletion = true;
            }

            if (Screen.TimeSincePlayEnded >= 3000)
            {
                // Change background dim before switching screens.
                BackgroundManager.Background.Dim = 0;
            }
        }