public void OnClickLeaveRoom() { int[] playerIndex = new int[10]; playerIndex = (int[])PhotonNetwork.room.CustomProperties ["PlayerIndex"]; playerIndex [(int)PhotonNetwork.player.CustomProperties ["PlayerID"]] = 0; ExitGames.Client.Photon.Hashtable index = new ExitGames.Client.Photon.Hashtable(); index.Add("PlayerIndex", playerIndex); PhotonNetwork.room.SetCustomProperties(index); PhotonNetwork.DestroyPlayerObjects(PhotonNetwork.player); PhotonNetwork.LeaveRoom(); OnLeftRoom(); ChatRoomCanvas ChatRoomCanvas = GameObject.Find("ChatPanel").GetComponent <ChatRoomCanvas>(); if (ChatRoomCanvas != null) { ChatRoomCanvas.getDisconnected(); } }
/*public override void OnMasterClientSwitched(PhotonPlayer newMasterClient) { * PhotonNetwork.LeaveRoom(); * }*/ // Photon network called whenever you join a room public override void OnJoinedRoom() { foreach (Transform child in this.transform) { Destroy(child.gameObject); } print("Joined ROOM"); ChatRoomCanvas roomcanvas = GameObject.Find("ChatPanel").GetComponent <ChatRoomCanvas> (); FindMyID(); PhotonNetwork.player.NickName = nameInputField.text; PlayerNetwork_Text.Instance.PlayerName = nameInputField.text; roomcanvas.getConnected(); ExitGames.Client.Photon.Hashtable p = new ExitGames.Client.Photon.Hashtable(); p.Add("DeadTimes", 0); p.Add("Kill", 0); p.Add("DragonKill", 0); p.Add("TurtleKill", 0); p.Add("MudKill", 0); p.Add("SkillUse", 0); p.Add("Boss", 0); p.Add("Points", 0); //p.Add ("Name",nameInputField.text); p.Add("Position", new Vector3(0f, 0f, 0f)); p.Add("Dig", 0); p.Add("Jewel", 0); p.Add("Water", 0); p.Add("Lava", 0); p.Add("Stone", 0); p.Add("Cure", 0); p.Add("Title1", 0); p.Add("Title2", 0); p.Add("Title3", 0); p.Add("Title4", 0); PhotonNetwork.player.SetCustomProperties(p); MainCanvasManager.Instance.CurrentRoomCanvas.transform.SetAsLastSibling(); PhotonPlayer[] photonPlayers = PhotonNetwork.playerList; foreach (PhotonPlayer photonPlayer in photonPlayers) { PlayerJoinedRoom(photonPlayer); } }