Disconnect() 공개 정적인 메소드

Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFromPhoton on completition.
When the client is connected, the server is being informed that this client disconnects. This speeds up leave/disconnect messages for players in the same room as you (otherwise the server would timeout this client's connection). When used in offlineMode, the state-change and event-call OnDisconnectedFromPhoton are immediate. Offline mode is set to false as well. Once disconnected, the client can connect again. Use ConnectUsingSettings.
public static Disconnect ( ) : void
리턴 void
예제 #1
0
 public void LeaveRoom()
 {
     PhotonNetwork.Disconnect();
     SceneManager.LoadSceneAsync("Lobby");
 }
예제 #2
0
 public void OnLogoutButtonClicked()
 {
     PhotonNetwork.Disconnect();
 }
예제 #3
0
 /// <summary>Called by Unity when the application is closed. Disconnects.</summary>
 protected void OnApplicationQuit()
 {
     PhotonHandler.AppQuits = true;
     PhotonHandler.StopFallbackSendAckThread();
     PhotonNetwork.Disconnect();
 }
예제 #4
0
 public void DisconnectFromServer()
 {
     PhotonNetwork.Disconnect();
     statusText.text = "Disconnected from master server";
 }
예제 #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="id"></param>
    public void ChangeWindow(int id)
    {
        switch (id)
        {
        case 0:
            PlayerNameWindow.SetActive(true);
            MenuWindow.SetActive(false);
            HostRoomWindow.SetActive(false);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(false);
            ConnectingWindow.SetActive(false);
            break;

        case 1:
            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(true);
            HostRoomWindow.SetActive(false);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(true);
            ConnectingWindow.SetActive(false);
            break;

        case 2:    // Host Room
            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(true);
            HostRoomWindow.SetActive(true);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(false);
            if (OptionMenuOpen)
            {
                ChangeWindow(3);
            }
            break;

        case 3:    //Options
            if (!OptionsWindow.activeSelf)
            {
                OptionsWindow.SetActive(true);
            }
            OptionMenuOpen = !OptionMenuOpen;
            Animation a = OptionsWindow.GetComponent <Animation>();
            if (OptionMenuOpen)
            {
                a["OptionsWindow"].speed = 1.0f;
                a.CrossFade("OptionsWindow", 0.2f);
            }
            else
            {
                if (a["OptionsWindow"].time == 0.0f)
                {
                    a["OptionsWindow"].time = a["OptionsWindow"].length;
                }
                a["OptionsWindow"].speed = -1.0f;
                a.CrossFade("OptionsWindow", 0.2f);
            }
            break;

        case 4:    //Menu Window
            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(true);
            HostRoomWindow.SetActive(true);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(false);
            break;

        case 5:    //Create Room
            StartCoroutine(FadeIn(1));
            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(false);
            HostRoomWindow.SetActive(false);
            PreSceneWindow.SetActive(true);
            SearchWindow.SetActive(false);
            PreScene.enabled = true;
            if (OptionMenuOpen)
            {
                ChangeWindow(3);
            }
            break;

        case 6:    //Connecting...
            StartCoroutine(FadeIn(1));
            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(false);
            HostRoomWindow.SetActive(false);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(false);
            ConnectingWindow.SetActive(true);
            SelectServerWindow.SetActive(false);
            PreScene.enabled = false;
            if (OptionMenuOpen)
            {
                ChangeWindow(3);
            }
            break;

        case 7:    //Select server
            if (PhotonNetwork.connected)
            {
                PhotonNetwork.Disconnect();
            }

            PlayerNameWindow.SetActive(false);
            MenuWindow.SetActive(false);
            HostRoomWindow.SetActive(false);
            PreSceneWindow.SetActive(false);
            SearchWindow.SetActive(false);
            ConnectingWindow.SetActive(false);
            SelectServerWindow.SetActive(true);
            break;
        }
    }
예제 #6
0
 public void LeaveRoom()
 {
     PhotonNetwork.Disconnect();
     //PhotonNetwork.LeaveRoom();
     PhotonNetwork.LoadLevel("LauncherScene");
 }
 public void DisconnectFromServer()
 {
     PhotonNetwork.Disconnect();
 }
예제 #8
0
 public void LeaveServer()
 {
     CBUG.Log("Leaving server . . .");
     PhotonNetwork.Disconnect();
     inLobby = false;
 }
예제 #9
0
 public void ExitButton()
 {
     PlayerPrefs.Save();
     PhotonNetwork.Disconnect();
     Application.Quit();
 }
예제 #10
0
 public void QuitBt()
 {
     PhotonNetwork.Disconnect();
     SceneManager.LoadScene("Menu");//1번씬(현재씬) 다시 로드
 }
예제 #11
0
 public void DisconnectPublicArea()
 {
     _onPublicArea = false;
     PhotonNetwork.Disconnect();
 }
예제 #12
0
 public override void OnJoinRoomFailed(short returnCode, string message)
 {
     startButton.SetActive(true);
     messageText.text = "ルームへの参加に失敗しました。。\nもう一度お試しください。";
     PhotonNetwork.Disconnect();
 }
예제 #13
0
 public void AskForExit()
 {
     PhotonNetwork.Disconnect();
     controller.launchLoginMenu();
 }
예제 #14
0
 public static void Reconnect()
 {
     FengGameManagerMKII.NeedRejoin = true;
     PhotonNetwork.Disconnect();
 }
예제 #15
0
 private void OnDestroy()
 {
     PhotonNetwork.Disconnect();
 }
 /// <summary>
 /// Called when the local player left the room. We need to load the launcher scene.
 /// </summary>
 public override void OnLeftRoom()
 {
     SceneManager.LoadScene(0);
     PhotonNetwork.Disconnect();
 }
예제 #17
0
    /*
     * Renders the lobby room and player create menu
     */
    void OnGUI()
    {
        // lobby
        if (gameState == GameState.InLobby)
        {
            GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));

            playerName = GUILayout.TextField(playerName);
            roomName   = GUILayout.TextField(roomName);
            if (GUILayout.Button("Create"))
            {
                PhotonNetwork.JoinOrCreateRoom(roomName, null, null);
            }

            // Display a list of available rooms on the server
            foreach (RoomInfo game in PhotonNetwork.GetRoomList())
            {
                if (GUILayout.Button(game.name + " " + game.playerCount + "/" + game.maxPlayers))
                {
                    PhotonNetwork.JoinOrCreateRoom(game.name, null, null);
                }
            }

            GUILayout.EndArea();
        }

        // room
        if (gameState == GameState.InRoom)
        {
            GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
            GUILayout.Box("Your current score: " + PhotonNetwork.player.GetScore());

            // Class selection
            GUILayout.Label("Choose your class");
            if (GUILayout.Button("SWAT"))
            {
                spawnPlayer(SWAT);
            }
            if (GUILayout.Button("Assault"))
            {
                spawnPlayer(Assault);
            }

            GUILayout.Label("");
            if (GUILayout.Button("Quit room"))
            {
                PhotonNetwork.Disconnect();
                SceneManager.LoadScene(0);
            }

            GUILayout.EndArea();
        }

        if (gameState == GameState.Die)
        {
            GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
            GUILayout.Box("You Died");

            if (GUILayout.Button("Back to room"))
            {
                PhotonNetwork.Destroy(ragDoll);
                OnJoinedRoom();
            }

            GUILayout.EndArea();
        }
    }
 private void DisconnectServerOnClickListener()
 {
     PhotonNetwork.Disconnect();
 }
예제 #19
0
파일: Match.cs 프로젝트: FW-ship/Erase
 public void MatchEnd()
 {
     PhotonNetwork.Disconnect();
 }
예제 #20
0
 /// <summary>
 /// Dispose method. Disconnects from Photon, and destroys the GameObject.
 /// </summary>
 public void Dispose()
 {
     PhotonNetwork.Disconnect();
     Destroy(this.gameObject);
 }
예제 #21
0
    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
    }
예제 #22
0
 public void DisConnect() => PhotonNetwork.Disconnect();
예제 #23
0
 public override void OnLeftRoom()
 {
     PhotonNetwork.Disconnect();
 }
예제 #24
0
 void OnApplicationQuit()
 {
     PhotonNetwork.Disconnect();
 }
예제 #25
0
 private void OnClick()
 {
     PhotonNetwork.Disconnect();
     PhotonNetwork.ConnectToMaster("app-eu.exitgamescloud.com", 0x13bf, FengGameManagerMKII.applicationId, UIMainReferences.version);
     FengGameManagerMKII.OnPrivateServer = false;
 }
예제 #26
0
        private void Update()
        {
            if (LoadSaveScript.loadLevel != "")
            {
                LoadSaveScript.loadLevelTimer -= Time.fixedDeltaTime;
                if (LoadSaveScript.loadLevelTimer <= 0)
                {
                    musicSource.Stop();
                    if (singleplayer)
                    {
                        SceneManager.LoadSceneAsync(LoadSaveScript.loadLevel);
                    }
                    else
                    {
                        PhotonNetwork.LoadLevel(LoadSaveScript.loadLevel);
                    }
                    LoadSaveScript.loadLevel = "";
                }
                return;
            }

            if (timerActive && !gameStarted)
            {
                timerToStart     -= Time.deltaTime;
                sendMessageTimer -= Time.deltaTime;
                if (sendMessageTimer <= 0)
                {
                    AddMessasgeToChat(String.Format("Game will start in {0:F0}", timerToStart));
                    sendMessageTimer = 1.0f;
                }
                if (timerToStart <= 0)
                {
                    AddMessasgeToChat(String.Format("Game started..."));
                    gameStarted = true;

                    if (PhotonNetwork.InRoom)
                    {
                        PhotonNetwork.CurrentRoom.IsOpen    = false;
                        PhotonNetwork.CurrentRoom.IsVisible = false;
                    }

                    UI.document.Run("CreateLoadingScreen", "Level initialization");
                    LoadSaveScript.loadLevel      = "Levels/Map1";
                    LoadSaveScript.loadLevelTimer = 0.7f;
                    return;
                }
            }
            string className = "";
            var    element   = PowerUI.CameraPointer.All[0].ActiveOver;

            if (element != null)
            {
                className = element.className;
            }

            if (UnityEngine.Input.GetMouseButtonUp(0) || UnityEngine.Input.GetKeyDown(KeyCode.Return) || UnityEngine.Input.GetKeyDown(KeyCode.Escape))
            {
                bool changed = SettingsScript.ChangeTabOrSaveSettings(className, windowSettings: "settingsContainer", saveClassName: "saveSettings", errorClassName: "messageSettings", mainMenu: true);
                if (changed)
                {
                    musicSource.volume = PlayerPrefs.GetFloat("musicMenuVolume");
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    return;
                }

                if (className.Contains("singleplayer") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    singleplayer = true;
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    GameInfo.playerSpectate = false;
                    GameInfo.NPCList.Clear();
                    UI.document.innerHTML = RoomHTMLFile.text;
                    GameInfo.SetReady(false);
                    GameInfo.mapSize = GameInfo.defaultMapSize;
                    GameInfo.mapSeed = UnityEngine.Random.Range(0, 1000);
                    UpdateRoomView();
                    return;
                }
                if (className.Contains("load") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    singleplayer = true;
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    UI.document.innerHTML = LoadingHTMLFile.text;
                    LoadSaveScript.UpdateSaveList();

                    foreach (Dom.Element loadingButton in UI.document.getElementsByClassName("loadingButton"))
                    {
                        loadingButton.onclick = GameMenuBehavior.LoadFileClick;
                    }
                    return;
                }
                if (className.Contains("multiplayer") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    singleplayer = false;
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    if (PlayerPrefs.GetString("username") == "")
                    {
                        CreateConnectDialog();
                    }
                    else
                    {
                        Connect(PlayerPrefs.GetString("username"));
                    }
                }
                if (className.Contains("menuElement settings") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    UI.document.innerHTML = SettingsHTMLFile.text;
                    SettingsScript.CreateSettings("settingsContainer", true);
                    return;
                }
                if (className.Contains("exit") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    Application.Quit();
                    return;
                }
                else if ((className.Contains("ConnectDialog") && UnityEngine.Input.GetMouseButtonUp(0)) ||
                         UI.document.getElementsByClassName("ConnectDialog").length > 0 && UnityEngine.Input.GetKeyDown(KeyCode.Return))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    string error = SettingsScript.SaveSettings();
                    if (error != "")
                    {
                        UI.document.getElementsByClassName("error")[0].innerText = error;
                    }
                    else
                    {
                        DeleteDialog();
                        Connect(PlayerPrefs.GetString("username"));
                    }
                }
                else if (className.Contains("backToMenu") && UI.document.getElementsByClassName("settingsBlock").length > 0 && UnityEngine.Input.GetMouseButtonUp(0) || UnityEngine.Input.GetKeyDown(KeyCode.Escape))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    UI.document.innerHTML = MenuHTMLFile.text;
                    return;
                }

                // Singleplayer
                else if (singleplayer && ((className.Contains("backToMenu") && UnityEngine.Input.GetMouseButtonUp(0)) || UnityEngine.Input.GetKeyDown(KeyCode.Escape)))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    gameStarted           = false;
                    UI.document.innerHTML = MenuHTMLFile.text;
                }
                else if (singleplayer && (className.Contains("setReady") && UnityEngine.Input.GetMouseButtonUp(0)))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    GameInfo.SetReady(!GameInfo.isPlayerReady);
                    UpdateRoomView();
                }

                else if (((className.Contains("backToMenu") && UnityEngine.Input.GetMouseButtonUp(0)) || UnityEngine.Input.GetKeyDown(KeyCode.Escape)) && !PhotonNetwork.InRoom)
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    PhotonNetwork.Disconnect();
                    CreateMessage("Disconnecting...");
                }
                else if (className.Contains("refreshMenu") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    UpdateLobbyListView();
                }
                else if (className.Contains("restoreSettings") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    SettingsScript.SetDefaultSettingsIfNotSetted(force: true);
                    SettingsScript.CreateSettings("settingsContainer", true);
                    musicSource.volume = PlayerPrefs.GetFloat("musicMenuVolume");
                    var messageDiv = UI.document.getElementsByClassName("messageSettings")[0];
                    messageDiv.innerHTML   = "Default settings are set!";
                    messageDiv.style.color = "green";
                    return;
                }

                else if (className.Contains("createRoomDialog") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    CreateRoomMenu();
                }

                else if (className.Contains("roomInLobby") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    CreateMessage(String.Format("Connecting to \"{0}\"...", element.innerText));
                    PhotonNetwork.JoinRoom(element.innerText);
                }

                else if (className.Contains("deleteDialog") && UnityEngine.Input.GetMouseButtonUp(0))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    DeleteDialog();
                }

                else if ((className.Contains("RoomDialog") && UnityEngine.Input.GetMouseButtonUp(0)) || UI.document.getElementsByClassName("inputMaxplayers").length > 0 && UnityEngine.Input.GetKeyDown(KeyCode.Return))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    string roomName   = UI.document.getElementsByClassName("inputName")[0].innerText;
                    string maxplayers = UI.document.getElementsByClassName("inputMaxplayers")[0].innerText;
                    if (!Regex.Match(maxplayers, @"^[2-9][0-9]*$", RegexOptions.IgnoreCase).Success)
                    {
                        UI.document.getElementsByClassName("error")[0].innerText = "Wrong maxplayers value";
                    }
                    else if (roomName.Length <= 0)
                    {
                        UI.document.getElementsByClassName("error")[0].innerText = "Empty room name";
                    }
                    else
                    {
                        DeleteDialog();
                        CreateMessage("Creating...");
                        PhotonNetwork.JoinOrCreateRoom(roomName, new RoomOptions {
                            MaxPlayers = (byte)int.Parse(maxplayers)
                        }, TypedLobby.Default);
                    }
                }

                else if ((PhotonNetwork.InRoom || singleplayer) && ((className.Contains("backToMenu") && UnityEngine.Input.GetMouseButtonUp(0)) || UnityEngine.Input.GetKeyDown(KeyCode.Escape)))
                {
                    timerActive = false;
                    PhotonNetwork.LeaveRoom();
                    CreateMessage("Leaving...");
                }
                else if (PhotonNetwork.InRoom && (UnityEngine.Input.GetKeyDown(KeyCode.Return) || (className.Contains("chatSend") && UnityEngine.Input.GetMouseButtonUp(0))))
                {
                    string chatInput = UI.document.getElementsByClassName("chatInput")[0].getAttribute("value");
                    if (chatInput != null && chatInput.Length > 0)
                    {
                        UI.document.getElementsByClassName("chatInput")[0].setAttribute("value", "");
                        GetComponent <PhotonView>().RPC(
                            "AddMessasgeToChat", PhotonTargets.All, new string[1] {
                            String.Format("{0}: {1}", PhotonNetwork.NickName, chatInput)
                        }
                            );
                    }
                }
                else if (PhotonNetwork.InRoom && (className.Contains("setReady") && UnityEngine.Input.GetMouseButtonUp(0)))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    GameInfo.SetReady(!GameInfo.isPlayerReady);
                }

                // Create NPC
                else if (GameInfo.IsMasterClient() && (className.Contains("CreateNPC") && UnityEngine.Input.GetMouseButtonUp(0)))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    GameInfo.CreateNPC(GameInfo.NPCList.Count + 1 % 9);
                    if (singleplayer)
                    {
                        UpdateRoomView();
                    }
                    return;
                }
                // Kick
                else if (GameInfo.IsMasterClient() && (className.Contains("kick") && UnityEngine.Input.GetMouseButtonUp(0)))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    if (element.parentElement.className.Contains("NPC"))
                    {
                        int index = int.Parse(new Regex(@"NPCINDEX(\d+)").Match(element.className).Groups[1].Value);
                        GameInfo.DeleteNPC(index);
                        if (singleplayer)
                        {
                            UpdateRoomView();
                        }
                        return;
                    }
                    else
                    {
                        string kickUsername = element.parentElement.textContent;
                        AddMessasgeToChat(String.Format("{0} kicked user {1}", PhotonNetwork.LocalPlayer.NickName, kickUsername));
                        GetComponent <PhotonView>().RPC("KickPlayer", PhotonTargets.All, kickUsername);
                        return;
                    }
                }
                if ((className.Contains("spectator") && UnityEngine.Input.GetMouseButtonUp(0)) && element.parentElement.innerText.Contains(GameInfo.GetNickName()))
                {
                    soundsSource.PlayOneShot(clickSound, PlayerPrefs.GetFloat("interfaceVolume"));
                    GameInfo.SetSpectator(!GameInfo.playerSpectate);
                    if (singleplayer)
                    {
                        UpdateRoomView();
                    }
                    return;
                }

                // Change map size
                var mapElements = UI.document.getElementsByClassName("MapSize");
                if (mapElements.length > 0)
                {
                    int newSize = int.Parse(mapElements[0].id);
                    if (newSize != GameInfo.mapSize)
                    {
                        GameInfo.SetMapSize(newSize);
                        if (singleplayer)
                        {
                            UpdateRoomView();
                        }
                        return;
                    }
                }

                // Change team
                if (UI.document.getElementsByAttribute("name", "teamSelect").length > 0)
                {
                    foreach (Dom.Element selectElement in UI.document.getElementsByAttribute("name", "teamSelect"))
                    {
                        int teamSelect = int.Parse(selectElement.id);
                        if (selectElement.className.Contains(GameInfo.GetNickName()))
                        {
                            if (GameInfo.playerTeam != teamSelect)
                            {
                                GameInfo.SetTeam(teamSelect);
                            }
                        }
                        else if (GameInfo.IsMasterClient() && selectElement.parentElement.className.Contains("NPC"))
                        {
                            // Debug.Log("NPC (" + selectElement.parentElement.className + "): " + teamSelect);
                            int index = int.Parse(new Regex(@"NPCINDEX(\d+)").Match(selectElement.parentElement.className).Groups[1].Value);
                            if (GameInfo.NPCList[index] != teamSelect)
                            {
                                GameInfo.ChangeNPCTeam(index, teamSelect);
                            }
                        }
                    }
                }
            }
        }
 public void Offline()
 {
     // playFab = false;
     offlineButtonPressed = true;
     PhotonNetwork.Disconnect();
 }
예제 #28
0
 public void disconnectToRoom()
 {
     PhotonNetwork.Disconnect();
     Application.LoadLevel(roomToLoad);
 }
예제 #29
0
 /// <summary>
 /// 연결 해제시 실행
 /// </summary>
 public void Disconnect()
 {
     PhotonNetwork.Disconnect();
 }
예제 #30
0
 /// <summary>
 /// Go to title scene and disconnect on photon network.
 /// </summary>
 public void GoTitleAndDisconnectPhotonNetwork()
 {
     PhotonNetwork.Disconnect();
     Application.LoadLevel("SelectServer");
 }