예제 #1
0
    public override void OnConnectionFail(DisconnectCause cause)
    {
        if (cause == DisconnectCause.InvalidRegion)
        {
            OnInvalidJoinCodeRegion();
        }
        else
        {
            voosEngine.HackyForceSetIsRunning(false);

            if (Time.unscaledTime > 10f)
            {
                autosaves.SetPaused(true);
                autosaves.TriggerAutosave(autosaveBundleId =>
                {
                    if (numOthersWhenConnected == 0)
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}\nWe've auto-saved the project, so you can recover it and restart the multiplayer session.";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(userMessage,
                                              "Recover Autosave",
                                              () =>
                        {
                            scenes.RestartAndLoadLibraryBundle(gameBundleLibrary.GetBundleEntry(autosaveBundleId), new GameBuilderApplication.PlayOptions());
                        },
                                              "Go to Main Menu",
                                              () => scenes.LoadSplashScreen(),
                                              800f
                                              );
                    }
                    else
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}. Please reconnect.\n<size=80%><color=#888888>NOTE: If the multiplayer game is gone, you can recover the autosave in your Game Library.</color></size>";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(
                            userMessage,
                            $"Reconnect to {roomNameWhenConnected}",
                            () => scenes.JoinMultiplayerGameByCode(roomNameWhenConnected),
                            "Go to Main Menu",
                            () => scenes.LoadSplashScreen(),
                            800f);
                    }
                });
            }
            else
            {
                string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}.";
                Util.LogError(userMessage);
                popups.Show(userMessage, "Back to Main Menu", () =>
                {
                    scenes.LoadSplashScreen();
                });
            }
        }
    }