123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807 |
- // --------------------------------------------------------------------------------------------------------------------
- // <copyright file="PunCockpit.cs" company="Exit Games GmbH">
- // Part of: Pun Cockpit Demo
- // </copyright>
- // <author>developer@exitgames.com</author>
- // --------------------------------------------------------------------------------------------------------------------
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using UnityEngine.UI;
- using Photon.Pun.Demo.Cockpit.Forms;
- using Photon.Pun.Demo.Shared;
- using Photon.Realtime;
- using Hashtable = ExitGames.Client.Photon.Hashtable;
- namespace Photon.Pun.Demo.Cockpit
- {
- /// <summary>
- /// UI based work in progress to test out api and act as foundation when dealing with room, friends and player list
- /// </summary>
- public class PunCockpit : MonoBehaviourPunCallbacks
- {
- public static PunCockpit Instance;
- public static bool Embedded;
- public static string EmbeddedGameTitle = "";
- public bool debug = false;
- public string UserId { get; set; }
- public Text Title;
- public Text StateText; // set in inspector
- public Text UserIdText; // set in inspector
- [Header("Demo Integration")]
- public CanvasGroup MinimalCanvasGroup;
- public CanvasGroup MaximalCanvasGroup;
- public GameObject MinimizeButton;
- public GameObject MinimalUIEmbeddHelp;
- [Header("Connection UI")]
- public GameObject ConnectingLabel;
- public GameObject ConnectionPanel;
- public GameObject AdvancedConnectionPanel;
- public Dropdown ConnectAsDropDown;
- [Header("Common UI")]
- public GameObject InfosPanel;
- public GameObject MinimalUiInfosPanel;
- [Header("Lobby UI")]
- public GameObject LobbyPanel;
- public Selectable JoinLobbyButton;
- public RoomListView RoomListManager;
- public FriendListView FriendListManager;
- public GameObject RoomListMatchMakingForm;
- [Header("Game UI")]
- public GameObject GamePanel;
- public PlayerListView PlayerListManager;
- public PlayerDetailsController PlayerDetailsManager;
- public InputField RoomCustomPropertyInputfield;
- [Header("Photon Settings")]
- /// <summary>
- /// The game version override. This is one way to let the user define the gameversion, and set it properly right after we call connect to override the server settings
- /// Check ConnectAndJoinRandom.cs for another example of gameversion overriding
- /// </summary>
- public string GameVersionOverride = String.Empty;
- /// <summary>
- /// The reset flag for best cloud ServerSettings.
- /// This is one way to let the user define if bestcloud cache should be reseted when connecting.
- /// </summary>
- public bool ResetBestRegionCodeInPreferences = false;
- [Header("Room Options")]
- public int MaxPlayers = 4;
- public int PlayerTtl = 0;
- public int EmptyRoomTtl = 0;
- public string Plugins = "";
- public bool PublishUserId = true;
- public bool IsVisible = true;
- public bool IsOpen = true;
- //public bool CheckUserOnJoin = false;
- public bool CleanupCacheOnLeave = true;
- public bool DeleteNullProperties = false;
- [Header("Room Options UI")]
- public IntInputField PlayerTtlField;
- public IntInputField EmptyRoomTtlField;
- public IntInputField MaxPlayersField;
- public StringInputField PluginsField;
- public BoolInputField PublishUserIdField;
- public BoolInputField IsVisibleField;
- public BoolInputField IsOpenField;
- public BoolInputField CleanupCacheOnLeaveField;
- // public BoolInputField CheckUserOnJoinField;
- public BoolInputField DeleteNullPropertiesField;
- [Header("Friends Options")]
- public FriendListView.FriendDetail[] FriendsList =
- new FriendListView.FriendDetail[]{
- new FriendListView.FriendDetail("Joe","Joe"),
- new FriendListView.FriendDetail("Jane","Jane"),
- new FriendListView.FriendDetail("Bob","Bob")
- };
- [Header("Modal window")]
- public CanvasGroup ModalWindow;
- public RegionListView RegionListView;
- public Text RegionListLoadingFeedback;
- public void Start()
- {
- Instance = this;
- // doc setup
- DocLinks.Language = DocLinks.Languages.English;
- DocLinks.Product = DocLinks.Products.Pun;
- DocLinks.Version = DocLinks.Versions.V2;
- //
- ModalWindow.gameObject.SetActive (false);
- MaximalCanvasGroup.gameObject.SetActive(true);
- this.UserIdText.text = "";
- this.StateText.text = "";
- this.StateText.gameObject.SetActive(true);
- this.UserIdText.gameObject.SetActive(true);
- this.Title.gameObject.SetActive(true);
- this.ConnectingLabel.SetActive(false);
- this.LobbyPanel.SetActive(false);
- this.GamePanel.SetActive(false);
- if (string.IsNullOrEmpty(UserId))
- {
- UserId = "user" + Environment.TickCount % 99; //made-up username
- }
- PlayerTtlField.SetValue(this.PlayerTtl);
- EmptyRoomTtlField.SetValue(this.EmptyRoomTtl);
- MaxPlayersField.SetValue(this.MaxPlayers);
- PluginsField.SetValue(this.Plugins);
- PublishUserIdField.SetValue(this.PublishUserId);
- IsVisibleField.SetValue(this.IsVisible);
- IsOpenField.SetValue(this.IsOpen);
- CleanupCacheOnLeaveField.SetValue(this.CleanupCacheOnLeave);
- //CheckUserOnJoinField.SetValue (this.CheckUserOnJoin);
- DeleteNullPropertiesField.SetValue(this.DeleteNullProperties);
- // prefill dropdown selection of users
- ConnectAsDropDown.ClearOptions();
- ConnectAsDropDown.AddOptions(FriendsList.Select(x => x.NickName).ToList());
- // check the current network status
- if (PhotonNetwork.IsConnected)
- {
- if (PhotonNetwork.Server == ServerConnection.GameServer)
- {
- this.OnJoinedRoom ();
- }
- else if (PhotonNetwork.Server == ServerConnection.MasterServer || PhotonNetwork.Server == ServerConnection.NameServer)
- {
-
- if (PhotonNetwork.InLobby)
- {
- this.OnJoinedLobby ();
- }
- else
- {
- this.OnConnectedToMaster ();
- }
- }
- }else
- {
- this.SwitchToSimpleConnection();
- if (!Embedded)
- {
- MinimizeButton.SetActive(false);
- SwitchtoMaximalPanel();
- }
- else
- {
- this.Title.text = EmbeddedGameTitle;
- SwitchtoMinimalPanel();
- }
- }
- }
- public void SwitchtoMinimalPanel()
- {
- MinimalCanvasGroup.gameObject.SetActive(true);
- MaximalCanvasGroup.alpha = 0f;
- MaximalCanvasGroup.blocksRaycasts = false;
- MaximalCanvasGroup.interactable = false;
- }
- public void SwitchtoMaximalPanel()
- {
- MinimalUIEmbeddHelp.SetActive(false);
- MinimalCanvasGroup.gameObject.SetActive(false);
- MaximalCanvasGroup.alpha = 1f;
- MaximalCanvasGroup.blocksRaycasts = true;
- MaximalCanvasGroup.interactable = true;
- }
- public void SwitchToAdvancedConnection()
- {
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(true);
- }
- public void SwitchToSimpleConnection()
- {
- this.ConnectionPanel.gameObject.SetActive(true);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- }
- public void ToggleInfosInMinimalPanel()
- {
- MinimalUiInfosPanel.SetActive(!MinimalUiInfosPanel.activeSelf);
- }
- public void RequestInfosPanel(GameObject Parent)
- {
- if (Parent != null)
- {
- InfosPanel.transform.SetParent(Parent.transform, false);
- }
- }
- public void OnUserIdSubmited(string userId)
- {
- this.UserId = userId;
- this.Connect();
- }
- public void SetPlayerTtlRoomOption(int value)
- {
- this.PlayerTtl = value;
- if (debug) Debug.Log("PunCockpit:PlayerTtl = " + this.PlayerTtl);
- }
- public void SetEmptyRoomTtlRoomOption(int value)
- {
- this.EmptyRoomTtl = value;
- if (debug) Debug.Log("PunCockpit:EmptyRoomTtl = " + this.EmptyRoomTtl);
- }
- public void SetMaxPlayersRoomOption(int value)
- {
- this.MaxPlayers = value;
- if (debug) Debug.Log("PunCockpit:MaxPlayers = " + this.MaxPlayers);
- }
- public void SetPluginsRoomOption(string value)
- {
- this.Plugins = value;
- if (debug) Debug.Log("PunCockpit:Plugins = " + this.Plugins);
- }
- public void SetPublishUserId(bool value)
- {
- this.PublishUserId = value;
- if (debug) Debug.Log("PunCockpit:PublishUserId = " + this.PublishUserId);
- }
- public void SetIsVisible(bool value)
- {
- this.IsVisible = value;
- if (debug) Debug.Log("PunCockpit:IsVisible = " + this.IsVisible);
- }
- public void SetIsOpen(bool value)
- {
- this.IsOpen = value;
- if (debug) Debug.Log("PunCockpit:IsOpen = " + this.IsOpen);
- }
- // public void SetCheckUserOnJoin(bool value)
- // {
- // this.CheckUserOnJoin = value;
- // Debug.Log ("CheckUserOnJoin = " + this.CheckUserOnJoin);
- // }
- public void SetResetBestRegionCodeInPreferences(bool value)
- {
- this.ResetBestRegionCodeInPreferences = value;
- if (debug) Debug.Log("PunCockpit:ResetBestRegionCodeInPreferences = " + this.ResetBestRegionCodeInPreferences);
- }
- public void SetCleanupCacheOnLeave(bool value)
- {
- this.CleanupCacheOnLeave = value;
- if (debug) Debug.Log("PunCockpit:CleanupCacheOnLeave = " + this.CleanupCacheOnLeave);
- }
- public void SetDeleteNullProperties(bool value)
- {
- this.DeleteNullProperties = value;
- if (debug) Debug.Log("PunCockpit:DeleteNullProperties = " + this.DeleteNullProperties);
- }
- LoadBalancingClient _lbc;
- bool _regionPingProcessActive;
- List<Region> RegionsList;
- /// <summary>
- /// in progress, not fully working
- /// </summary>
- public void PingRegions()
- {
- ModalWindow.gameObject.SetActive (true);
- RegionListLoadingFeedback.text = "Connecting to NameServer...";
- _regionPingProcessActive = true;
- if (debug) Debug.Log("PunCockpit:PingRegions:ConnectToNameServer");
- _lbc = new LoadBalancingClient();
-
- _lbc.AddCallbackTarget(this);
- _lbc.StateChanged += OnStateChanged;
- _lbc.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
- _lbc.ConnectToNameServer ();
- }
- void Update()
- {
- if (_lbc!=null) _lbc.Service();
- if (RegionsList !=null)
- {
- if (this.ModalWindow.gameObject.activeInHierarchy) {
- if (PunCockpit.Instance.debug) Debug.Log("PunCockpit:OnRegionsPinged");
- this.RegionListView.OnRegionListUpdate (RegionsList);
- }
- _lbc = null;
- RegionListLoadingFeedback.text = string.Empty;
- RegionsList = null;
- }
- }
- void OnStateChanged(ClientState previousState, ClientState state)
- {
- if (state == ClientState.ConnectedToNameServer) {
- _lbc.StateChanged -= this.OnStateChanged;
- if (debug) Debug.Log("PunCockpit:OnStateChanged: ClientState.ConnectedToNameServer. Waiting for OnRegionListReceived callback.");
- RegionListLoadingFeedback.text = "Waiting for application Region List...";
- }
- }
- public override void OnRegionListReceived(RegionHandler regionHandler)
- {
- if (PunCockpit.Instance.debug)
- Debug.Log ("PunCockpit:OnRegionListReceived: " + regionHandler);
- if (_regionPingProcessActive)
- {
- RegionListLoadingFeedback.text = "Pinging Regions...";
- _regionPingProcessActive = false;
- regionHandler.PingMinimumOfRegions (OnRegionsPinged, null);
- }
- }
-
- private void OnRegionsPinged(RegionHandler regionHandler)
- {
- RegionsList = regionHandler.EnabledRegions.OrderBy(x=>x.Ping).ToList();
- // will check this on Update() to get back to the main thread.
- }
- public void CloseRegionListView()
- {
- RegionsList = null;
- if (_lbc != null) {
- _lbc.Disconnect ();
- _lbc = null;
- }
- _regionPingProcessActive = false;
- this.RegionListView.ResetList ();
- this.ModalWindow.gameObject.SetActive (false);
- }
- public void LoadLevel(string level)
- {
- if (debug) Debug.Log("PunCockpit:LoadLevel(" +level+")");
- PhotonNetwork.LoadLevel(level);
- }
- public void SetRoomCustomProperty(string value)
- {
- if (debug) Debug.Log("PunCockpit:SetRoomCustomProperty() c0 = " + value);
- PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { "C0", value } });
- }
- private string roomNameToEnter;
- public void JoinRoom(string roomName)
- {
- this.RoomListManager.ResetList();
- this.LobbyPanel.gameObject.SetActive(false);
- this.ConnectingLabel.SetActive(true);
- this.roomNameToEnter = roomName;
- PhotonNetwork.JoinRoom(roomName);
- }
- public void CreateRoom()
- {
- this.CreateRoom(null, null, LobbyType.Default);
- }
- public void CreateRoom(string roomName, string lobbyName = "MyLobby", LobbyType lobbyType = LobbyType.SqlLobby, string[] expectedUsers = null)
- {
- if (debug) Debug.Log("PunCockpit:CreateRoom roomName:" + roomName + " lobbyName:" + lobbyName + " lobbyType:" + lobbyType + " expectedUsers:" + (expectedUsers == null ? "null" : expectedUsers.ToStringFull()));
- this.RoomListManager.ResetList();
- this.LobbyPanel.gameObject.SetActive(false);
- this.ConnectingLabel.SetActive(true);
- RoomOptions _roomOptions = this.GetRoomOptions();
- if (debug) Debug.Log("PunCockpit:Room options <" + _roomOptions + ">");
- TypedLobby sqlLobby = new TypedLobby(lobbyName, lobbyType);
- bool _result = PhotonNetwork.CreateRoom(roomName, _roomOptions, sqlLobby, expectedUsers);
- if (debug) Debug.Log("PunCockpit:CreateRoom() -> " + _result);
- }
- public void JoinRandomRoom()
- {
- PhotonNetwork.JoinRandomRoom();
- }
- public void LeaveRoom()
- {
- PlayerListManager.ResetList();
- this.GamePanel.gameObject.SetActive(false);
- this.ConnectingLabel.SetActive(true);
- PhotonNetwork.LeaveRoom();
- }
- public void Connect()
- {
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- PhotonNetwork.AuthValues = new AuthenticationValues();
- PhotonNetwork.AuthValues.UserId = this.UserId;
- this.ConnectingLabel.SetActive(true);
- PhotonNetwork.ConnectUsingSettings();
- //if (GameVersionOverride != string.Empty) {
- // PhotonNetwork.GameVersion = "28"; // GameVersionOverride;
- // }
- }
- public void ReConnect()
- {
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- PhotonNetwork.AuthValues = new AuthenticationValues();
- PhotonNetwork.AuthValues.UserId = this.UserId;
- this.ConnectingLabel.SetActive(true);
- PhotonNetwork.Reconnect();
- }
- public void ReconnectAndRejoin()
- {
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- PhotonNetwork.AuthValues = new AuthenticationValues();
- PhotonNetwork.AuthValues.UserId = this.UserId;
- this.ConnectingLabel.SetActive(true);
- PhotonNetwork.ReconnectAndRejoin();
- }
- public void ConnectToBestCloudServer()
- {
- PhotonNetwork.NetworkingClient.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- PhotonNetwork.AuthValues = new AuthenticationValues();
- PhotonNetwork.AuthValues.UserId = this.UserId;
- this.ConnectingLabel.SetActive(true);
- if (this.ResetBestRegionCodeInPreferences) {
- ServerSettings.ResetBestRegionCodeInPreferences ();
- }
- PhotonNetwork.ConnectToBestCloudServer();
- if (GameVersionOverride != string.Empty) {
- PhotonNetwork.GameVersion = GameVersionOverride;
- }
- }
- public void ConnectToRegion(string region)
- {
- if (debug) Debug.Log("PunCockpit:ConnectToRegion(" + region + ")");
- PhotonNetwork.NetworkingClient.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
- this.ConnectionPanel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- PhotonNetwork.AuthValues = new AuthenticationValues();
- PhotonNetwork.AuthValues.UserId = this.UserId;
- this.ConnectingLabel.SetActive(true);
- bool _result = PhotonNetwork.ConnectToRegion(region);
- if (GameVersionOverride != string.Empty) {
- PhotonNetwork.GameVersion = GameVersionOverride;
- }
- if (debug) Debug.Log("PunCockpit:ConnectToRegion(" + region + ") ->" + _result);
- }
- public void ConnectOffline()
- {
- if (debug) Debug.Log("PunCockpit:ConnectOffline()");
- PhotonNetwork.OfflineMode = true;
- }
- public void JoinLobby()
- {
- if (debug) Debug.Log("PunCockpit:JoinLobby()");
- bool _result = PhotonNetwork.JoinLobby();
- if (!_result) {
- Debug.LogError ("PunCockpit: Could not joinLobby");
- }
- }
- public void Disconnect()
- {
- if (debug) Debug.Log("PunCockpit:Disconnect()");
- PhotonNetwork.Disconnect();
- }
- public void OpenDashboard()
- {
- Application.OpenURL("https://dashboard.photonengine.com");
- }
- #region CONNECT UI
- public void OnDropdownConnectAs(int dropdownIndex)
- {
- if (debug) Debug.Log("PunCockpit:OnDropdownConnectAs(" + dropdownIndex + ")");
- this.UserId = this.FriendsList[dropdownIndex].UserId;
- PlayerPrefs.SetString(UserIdUiForm.UserIdPlayerPref, this.UserId);
- StartCoroutine(OnDropdownConnectAs_CB());
- }
- IEnumerator OnDropdownConnectAs_CB()
- {
- // wait for the dropdown to animate.
- yield return new WaitForSeconds(0.2f);
- this.Connect();
- }
- #endregion
- #region IN LOBBY UI
- public void OnLobbyToolsViewTabChanged(string tabId)
- {
- // Debug.Log("PunCockpit:OnLobbyToolsViewTabChanged("+tabId+")");
- }
- #endregion
- #region IN ROOM UI
- public void OnSelectPlayer()
- {
- }
- #endregion
- #region PUN CallBacks
- public override void OnConnected()
- {
- if (debug) Debug.Log("PunCockpit:OnConnected()");
- this.ConnectingLabel.SetActive(false);
- this.UserIdText.text = "UserId:" + this.UserId + " Nickname:" + PhotonNetwork.NickName;
- }
- public override void OnDisconnected(DisconnectCause cause)
- {
- if (debug) Debug.Log("PunCockpit:OnDisconnected("+cause+")");
- this.ConnectingLabel.SetActive(false);
- this.UserIdText.text = string.Empty;
- this.StateText.text = string.Empty;
- this.GamePanel.gameObject.SetActive(false);
- this.LobbyPanel.gameObject.SetActive(false);
- this.ConnectionPanel.gameObject.SetActive(true);
- }
- public override void OnConnectedToMaster()
- {
- if (debug) Debug.Log("PunCockpit:OnConnectedToMaster()");
- this.StateText.text = "Connected to Master" + (PhotonNetwork.OfflineMode ? " <Color=Red><b>Offline</b></color>" : "");
- this.SetUpLobbyGenericUI();
- }
- public override void OnJoinedLobby()
- {
- this.StateText.text = "Connected to Lobby";
- if (debug) Debug.Log("PunCockpit:OnJoinedLobby()");
- this.SetUpLobbyGenericUI();
- }
- void SetUpLobbyGenericUI()
- {
- this.ConnectingLabel.gameObject.SetActive(false);
- this.AdvancedConnectionPanel.gameObject.SetActive(false);
- this.LobbyPanel.gameObject.SetActive(true);
- this.RoomListManager.OnJoinedLobbyCallBack();
- this.FriendListManager.SetFriendDetails(this.FriendsList);
- JoinLobbyButton.interactable = !PhotonNetwork.InLobby && !PhotonNetwork.OfflineMode;
- RoomListManager.gameObject.SetActive(!PhotonNetwork.OfflineMode);
- FriendListManager.gameObject.SetActive(!PhotonNetwork.OfflineMode);
- RoomListMatchMakingForm.SetActive(!PhotonNetwork.InLobby);
- }
- public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
- {
- if (debug) Debug.Log("PunCockpit:OnRoomPropertiesUpdate() " + propertiesThatChanged.ToStringFull());
- if (propertiesThatChanged.ContainsKey("C0"))
- {
- RoomCustomPropertyInputfield.text = propertiesThatChanged["C0"].ToString();
- }
- }
- public override void OnLeftLobby()
- {
- if (debug) Debug.Log("PunCockpit:OnLeftLobby()");
- this.RoomListManager.ResetList();
- this.LobbyPanel.gameObject.SetActive(false);
- }
- public override void OnCreateRoomFailed(short returnCode, string message)
- {
- if (debug) Debug.Log("PunCockpit:OnCreateRoomFailed(" + returnCode + "," + message + ")");
- }
- public override void OnJoinRandomFailed(short returnCode, string message)
- {
- if (debug) Debug.Log("PunCockpit:OnJoinRandomFailed(" + returnCode + "," + message + ")");
- }
- public override void OnJoinedRoom()
- {
- this.StateText.text = "Connected to GameServer " + (PhotonNetwork.OfflineMode ? " <Color=Red><b>Offline</b></color>" : "");
- if (debug) Debug.Log("PunCockpit:OnJoinedRoom()");
- this.ConnectingLabel.gameObject.SetActive(false);
- this.PlayerListManager.ResetList();
- this.GamePanel.gameObject.SetActive(true);
- this.PlayerDetailsManager.SetPlayerTarget(PhotonNetwork.LocalPlayer);
- }
- public override void OnJoinRoomFailed(short returnCode, string message)
- {
- switch (returnCode)
- {
- case ErrorCode.JoinFailedFoundInactiveJoiner:
- if (!string.IsNullOrEmpty(this.roomNameToEnter))
- {
- PhotonNetwork.RejoinRoom(this.roomNameToEnter);
- this.roomNameToEnter = null;
- }
- break;
- }
- }
- public override void OnLeftRoom()
- {
- if (debug) Debug.Log("PunCockpit:OnLeftRoom()");
- this.GamePanel.gameObject.SetActive(false);
- if (PhotonNetwork.OfflineMode)
- {
- this.ConnectingLabel.gameObject.SetActive(false);
- this.ConnectionPanel.gameObject.SetActive (true);
- }
- }
- #endregion
- RoomOptions GetRoomOptions()
- {
- RoomOptions _roomOptions = new RoomOptions();
- _roomOptions.MaxPlayers = (byte)this.MaxPlayers;
- _roomOptions.IsOpen = this.IsOpen;
- _roomOptions.IsVisible = this.IsVisible;
- _roomOptions.EmptyRoomTtl = this.EmptyRoomTtl;
- _roomOptions.PlayerTtl = this.PlayerTtl;
- _roomOptions.PublishUserId = this.PublishUserId;
- _roomOptions.CleanupCacheOnLeave = this.CleanupCacheOnLeave;
- _roomOptions.DeleteNullProperties = this.DeleteNullProperties;
- _roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", "Hello" } };
- _roomOptions.CustomRoomPropertiesForLobby = new string[] { "C0" };
- return _roomOptions;
- }
- }
- }
|