Example #1
0
 public void ShowExitPopup(string exitPrompt, string exitButtonPrompt, System.Action callback)
 {
     if (GameBuilderApplication.IsTutorialMode)
     {
         ExitPopupWithoutSave(exitPrompt, exitButtonPrompt, callback);
     }
     else
     {
         SavePopup(() => sceneController.LoadSplashScreen());
     }
 }
Example #2
0
 private void OnQuitClicked()
 {
     // Hack: if Ctrl + Shift is held, then just dismiss the error.
     if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift))
     {
         errorCanvas.gameObject.SetActive(false);
         return;
     }
     scenes.LoadSplashScreen();
     //Application.Quit();
     //#if UNITY_EDITOR
     //UnityEditor.EditorApplication.isPlaying = false;
     //#endif
 }
Example #3
0
    void Report()
    {
        string description = descriptionInputText.text;

        if (description.IsNullOrEmpty())
        {
            return;
        }

        if (!PhotonNetwork.isMasterClient && reportee != PhotonNetwork.masterClient)
        {
            networking.SendReportToMasterClient(reportee.NickName, description);
        }

#if USE_PUN
        object steamId = "(N/A)";
        reportee.CustomProperties.TryGetValue((object)NetworkingController.SteamIdPlayerProperty, out steamId);
#endif

        // Feedback
        if (reportee != PhotonNetwork.masterClient)
        {
            popups.Show("Thank you for reporting the player. We will review your message and take appropriate action if necessary. The Game Master has also been notified and may kick the player from the game.", "OK", () => { }, 800f);
        }
        else
        {
            popups.Show(new DynamicPopup.Popup
            {
                fullWidthButtons = true,
                textWrapWidth    = 800f,
                getMessage       = () => $"Thank you for reporting the player. We will review your message and take appropriate action if necessary. Would you like to leave the current game or continue playing?",
                buttons          = new List <PopupButton.Params>()
                {
                    new PopupButton.Params {
                        getLabel = () => "Leave Game", onClick = () => scenes.LoadSplashScreen()
                    },
                    new PopupButton.Params {
                        getLabel = () => "Continue Playing", onClick = () => { }
                    }
                }
            });
        }

        if (kicking)
        {
            networking.KickPlayer(reportee);
        }
        Close();
    }
Example #4
0
 void LoadMultiplayerSplashMenu()
 {
     SplashScreenController.debugShortcutToMpJoin = true;
     loadingScreen.ShowAndDo(() => sceneController.LoadSplashScreen());
 }
    void Start()
    {
#if USE_PUN
        StartCoroutine(PumpPlayerInitCoroutine());

        var diag = GetComponent <PhotonStatsGui>();
        if (diag != null)
        {
            diag.enabled = false;
        }

        try
        {
            // Don't destroy things created by clients. We will need to clean up the
            // player ghost object only. Even if we're not the master client, we still
            // need this. Because if the master quits, we might become the master, and
            // we need to prevent Photon from destroying all objects!
            if (!PhotonNetwork.inRoom)
            {
                PhotonNetwork.autoCleanUpPlayerObjects = false;
            }
            else
            {
                // Setting this causes an error if we're in a room, but we should make
                // sure it's false still.
                Debug.Assert(PhotonNetwork.autoCleanUpPlayerObjects == false);
            }

            PhotonNetwork.autoJoinLobby = false;
            bool isMultiplayer = GameBuilderApplication.CurrentGameOptions.playOptions.isMultiplayer;

            System.DateTime banLastDate;
            if (isMultiplayer && IsUserBanned(GetSteamID(), out banLastDate))
            {
                popups.Show($"You have been temporarily banned from multiplayer games for reported inappropriate or abusive behavior. You will be able to play again after {banLastDate.ToString("MMMM dd, yyyy")}.", "Back", () =>
                {
                    scenes.LoadSplashScreen();
                }, 800f);
                return;
            }

            if (isMultiplayer)
            {
                Util.Log($"Multiplayer!");
                SetupPlayerProperties();
                mode = Mode.Online;
                PhotonNetwork.offlineMode = false;
            }
            else
            {
            }

            if (PhotonNetwork.connected && PhotonNetwork.inRoom)
            {
                // We are still connected and in a room. This is a map switch.
                mode = Mode.Online;
                Util.Log($"StayOnline mode. Pretending we just joined the room.");
                didSwitchMaps = true;
                OnJoinedRoom();
            }
            else if (PhotonNetwork.connected && PhotonNetwork.insideLobby && isMultiplayer)
            {
                // Joining or creating.

                string roomToJoin = GameBuilderApplication.CurrentGameOptions.joinCode;
                if (!roomToJoin.IsNullOrEmpty())
                {
                    // We're joining a room from the lobby
                    Util.Log($"Trying to join room {roomToJoin}..");
                    // Try to join existing room
                    PhotonNetwork.JoinRoom(roomToJoin.ToLower());
                }
                else
                {
                    // We're creating a new game, and happen to be in a lobby already.
                    TryCreateRoom();
                }
            }
            else
            {
                switch (mode)
                {
                case Mode.Online:
                    string gameVersion = GetPhotonGameVersion();
                    // If we're trying to join a game, make sure we connect to their region.
                    string joinCode = GameBuilderApplication.CurrentGameOptions.joinCode;
                    if (joinCode == "*")
                    {
                        // TEMP join random visible game in best region
                        PhotonNetwork.ConnectToBestCloudServer(gameVersion);
                    }
                    else if (joinCode != null)
                    {
                        string regionCodeStr = joinCode.Split(JoinCodeSeparator)[0];
                        try
                        {
                            CloudRegionCode regionCode = (CloudRegionCode)System.Int32.Parse(regionCodeStr);
                            PhotonNetwork.ConnectToRegion(regionCode, gameVersion);
                        }
                        catch (System.OverflowException)
                        {
                            OnInvalidJoinCodeRegion();
                        }
                    }
                    else
                    {
                        // Ok we're starting a new game, so just connect to the best.
                        PhotonNetwork.ConnectToBestCloudServer(gameVersion);
                    }
                    break;

                case Mode.Offline:
                    if (PhotonUtil.ActuallyConnected())
                    {
                        PhotonNetwork.Disconnect();
                    }
                    DestroyImmediate(GetComponent <ExitGames.UtilityScripts.PlayerRoomIndexing>());
                    Util.Log($"Starting offline mode, t = {Time.realtimeSinceStartup}");
                    PhotonNetwork.offlineMode = true;
                    break;
                }
            }
        }
        catch (System.FormatException e)
        {
            OnFatalError(BadJoinCodeMessage);
        }
        catch (System.Exception e)
        {
            OnFatalError(e.ToString());
        }
#else
        // Non-PUN route
        mode = Mode.Offline;
        StartCoroutine(NonPunStartRoutine());
#endif
    }
Example #6
0
    public void Setup()
    {
        Util.FindIfNotSet(this, ref userMain);
        Util.FindIfNotSet(this, ref dynamicPopup);
        Util.FindIfNotSet(this, ref sceneController);

        systemMenuUI.showTooltipsToggle.onValueChanged.AddListener(userMain.ToggleTooltips);
        controlsMenu.invertMouseLookToggle.onValueChanged.AddListener(userMain.ToggleMouseInvert);
        systemMenuUI.autoPauseToggle.onValueChanged.AddListener(userMain.ToggleAutoPause);
        systemMenuUI.hideAvatarToggle.onValueChanged.AddListener(userMain.SetHideAvatarInTopDown);

        systemMenuUI.sfxSlider.onValueChanged.AddListener(userMain.SetSFXVolume);
        systemMenuUI.musicSlider.onValueChanged.AddListener(userMain.SetMusicVolume);
        controlsMenu.mouseWheelSensitivitySlider.onValueChanged.AddListener(userMain.SetMouseWheelSensitivity);
        controlsMenu.mouseLookSensitivitySlider.onValueChanged.AddListener(userMain.SetMouseSensitivity);

        systemMenuUI.closeButton.onClick.AddListener(Close);
        systemMenuUI.controlsButton.onClick.AddListener(ControlsMenuOpen);
        systemMenuUI.graphicsButton.onClick.AddListener(GraphicsMenuOpen);

        controlsMenu.resetToDefaultAction = ResetControlSettingsToDefaults;
        controlsMenu.onBack  = ControlsMenuBack;
        controlsMenu.onClose = ControlsMenuClose;

        graphicsMenu.onBack  = GraphicsMenuBack;
        graphicsMenu.onClose = GraphicsMenuClose;

        if (GameBuilderApplication.IsStandaloneExport)
        {
            systemMenuUI.exitButtonText.text = "Quit";
            systemMenuUI.exitToMainMenuButton.onClick.AddListener(() => Application.Quit());
        }
        else
        {
            systemMenuUI.exitToMainMenuButton.onClick.AddListener(() => userMain.ShowExitPopup("Exit to Main Menu?", "Exit", () => sceneController.LoadSplashScreen()));
        }
    }
Example #7
0
 void QuitToMainMenu()
 {
     CancelPopups();
     CloseToggles();
     sceneController.LoadSplashScreen();
 }