public static IEnumerator ConnectAndJoinIE(bool spawnAfterLoad) { if (spawnAfterLoad) { SceneManager.sceneLoaded += onLevelWasLoaded; } if (PhotonNetwork.JoinedRoomOrLobby()) { PhotonNetwork.Disconnect(); } while (PhotonNetwork.JoinedRoomOrLobby()) { yield return(new WaitForEndOfFrame()); } "Connecting...".SendProcessing(true); PhotonNetwork.PhotonServerSettings.JoinLobby = false; PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, "2020"); while (!readyToJoinOrCreateRoom) { yield return(new WaitForEndOfFrame()); } //"Connected to master...".SendProcessing(true); RoomOptions roomOptions = new RoomOptions { IsVisible = true, IsOpen = true, MaxPlayers = 10 }; PhotonNetwork.PhotonServerSettings.JoinLobby = true; PhotonNetwork.JoinOrCreateRoom("TestServer`The City`abnormal`999999`day``1", roomOptions, TypedLobby.Default); //ServerList.instance.gameObject.SetActive(false); "Creating a room...".SendProcessing(true); }
/// <summary> /// Start the connection process. /// - If already connected, we attempt joining target room /// - If not yet connected, Connect this application instance to Photon Cloud Network /// </summary> public void Connect(RoomInfo targetRoom) { if (!CheckSelectedSkills()) { return; } CampaignSelectionManager.Instanse.RoomSelector.DisableInteraction(); launcherPanel.ProgressLabel.enabled = true; launcherPanel.ProgressPanel.enabled = true; // keep track of the will to join a room, because when we come back from the game // we will get a callback that we are connected, so we need to know what to do then isNamedConnecting = true; targetRoomName = targetRoom.Name; UpdateCustomProperties(); // We check if we are connected or not, we join if we are , else we initiate the connection to the server. if (PhotonNetwork.connected) { // #Critical: We need at this point to attempt joining a Random Room. // If it fails, we'll get notified in OnPhotonRandomJoinFailed() and we'll create one. PhotonNetwork.JoinRoom(targetRoom.Name); } else { // #Critical, we must first and foremost connect to Photon Online Server. //PhotonNetwork.ConnectUsingSettings(GameVersion); PhotonNetwork.ConnectToRegion(selectedRegion, GameVersion); } }
public void ConnectToMaster() { if (!PhotonNetwork.connected) { PhotonNetwork.ConnectToRegion(selectedRegion, GameVersion); } }
/// <summary> /// Starts initializing and connecting to a game. Depends on the selected network mode. /// Sets the current player name prior to connecting to the servers. /// </summary> public static void StartMatch(NetworkMode mode) { PhotonNetwork.automaticallySyncScene = true; PhotonNetwork.playerName = PlayerPrefs.GetString(PrefsKeys.playerName); switch (mode) { //connects to a cloud game available on the Photon servers case NetworkMode.Online: #if UNITY_WEBGL //best region is not supported on WebGL, choose the location where your server is located, //or implement an option in your game for players to select their preferred location PhotonNetwork.ConnectToRegion(CloudRegionCode.us, appVersion); #else PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.BestRegion; PhotonNetwork.ConnectToBestCloudServer(appVersion); #endif break; //search for open LAN games on the current network, otherwise open a new one case NetworkMode.LAN: PhotonNetwork.ConnectToMaster(PlayerPrefs.GetString(PrefsKeys.serverAddress), 5055, PhotonNetwork.PhotonServerSettings.AppID, appVersion); break; //enable Photon offline mode to not send any network messages at all case NetworkMode.Offline: PhotonNetwork.offlineMode = true; break; } }
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); } }
//Connect to photon servers void ConnectToPhoton() { //connect to photon using setting file in project PhotonNetwork.ConnectUsingSettings(); PhotonNetwork.ConnectToRegion("usw"); //Disable automatic player scene transition PhotonNetwork.AutomaticallySyncScene = false; }
// Use this for initialization void Start() { PhotonNetwork.offlineMode = mp_Options.OfflineMode; //Set what region this client is using //Connect to the cloud using the current game version //PhotonNetwork.ConnectUsingSettings(mp_Options.GameVersion); PhotonNetwork.ConnectToRegion(mp_Options.ServerRegion, mp_Options.GameVersion); }
private void Awake( ) { PhotonNetwork.ConnectToRegion(CloudRegionCode.usw, gameVersion); PhotonNetwork.automaticallySyncScene = true; // Auto join lobby is true by default. I don't know what this does but I guess we don't need it. PhotonNetwork.autoJoinLobby = false; PhotonNetwork.logLevel = PhotonLogLevel.Full; }
public void Update() { if (isConnectAllowed && !PhotonNetwork.connected) { CBUG.Log("Beginning Connection . . ."); isConnectAllowed = false; if (PlayerPrefs.GetInt("Server", 0) == 0) { PhotonNetwork.ConnectToBestCloudServer(version); CBUG.Log("Connecting to Best Region."); } else { PhotonNetwork.ConnectToRegion(isEastServer ? CloudRegionCode.us : CloudRegionCode.usw, version); CBUG.Log("Connecting to Chosen Region."); } CBUG.Log("Version Number is: " + version); PhotonNetwork.sendRate = SendRate; PhotonNetwork.sendRateOnSerialize = SendRate; } if (!PhotonNetwork.connectedAndReady && PhotonNetwork.connecting) { printStatus(); } if (!PhotonNetwork.connected) { return; } //if(PhotonNetwork.room != null) // CBUG.Do("TotalRoomPlayersIs: " + PhotonNetwork.room.playerCount); if (Time.time - previousUpdateTime > ServerUpdateLoopTime) { previousUpdateTime = Time.time; setServerStats(); } //CBUG.Log("CHAR NUM: " + ID_to_CharNum[1]); #region Match Tracking if (readyTotal >= PhotonNetwork.playerList.Length && !startTheMatch && !startCountdown) { startTimer = CountdownLength; startCountdown = true; StartCoroutine(GameCountdown()); } if (startCountdown == true && readyTotal < PhotonNetwork.playerList.Length) { startCountdown = false; } #endregion }
public override void OnEnter() { PhotonNetwork.ConnectToRegion((CloudRegionCode)region.Value, gameVersion.Value); // reset authentication failure properties. PlayMakerPhotonProxy.lastAuthenticationDebugMessage = string.Empty; PlayMakerPhotonProxy.lastAuthenticationFailed = false; Finish(); }
/// <summary> /// Switch connection type /// </summary> /// <param name="type"></param> void Connect() { if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppID)) { Debug.LogWarning("You need your appID, read the documentation for more info!"); return; } //Connect to select region PhotonNetwork.ConnectToRegion(ServerHost, GameVersion); }
public void JoinRegion() { if (!(PlayerPrefs.HasKey("region"))) { GetComponent <UIManager>().OpenCanvas(3); } else { if (PhotonNetwork.connectedAndReady) { PhotonNetwork.Disconnect(); } string _regionCode = PlayerPrefs.GetString("region"); if (_regionCode == "au") { PhotonNetwork.ConnectToRegion(CloudRegionCode.au, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.au); } else if (_regionCode == "asia") { PhotonNetwork.ConnectToRegion(CloudRegionCode.asia, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.au); } else if (_regionCode == "eu") { PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.eu); } else if (_regionCode == "cae") { PhotonNetwork.ConnectToRegion(CloudRegionCode.cae, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.cae); } else if (_regionCode == "jp") { PhotonNetwork.ConnectToRegion(CloudRegionCode.jp, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.jp); } else if (_regionCode == "sa") { PhotonNetwork.ConnectToRegion(CloudRegionCode.sa, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.sa); } else if (_regionCode == "us") { PhotonNetwork.ConnectToRegion(CloudRegionCode.us, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.us); } else if (_regionCode == "usw") { PhotonNetwork.ConnectToRegion(CloudRegionCode.usw, GameName + GameVersion); PhotonNetwork.OverrideBestCloudServer(CloudRegionCode.usw); } } }
public static void ConnectToMaster() { if (PhotonNetwork.NetworkClientState != ClientState.Disconnected) { PhotonNetwork.ConnectUsingSettings(); PhotonNetwork.ConnectToRegion("eu"); } else { Debug.LogWarning("Already connected!"); } }
private void InitializationAllObjects() { StartCoroutine(CheckInternetConnection()); versionNum = Application.version; PhotonNetwork.AutomaticallySyncScene = true; PhotonNetwork.NickName = "Person" + Random.Range(0, 100).ToString(); PhotonNetwork.GameVersion = versionNum; PhotonNetwork.ConnectUsingSettings(); PhotonNetwork.ConnectToRegion("ru"); }
public override void OnDisconnected(DisconnectCause cause) { XDebug.Log("On Disconnected " + cause.ToString(), XDebug.Mask.GameManager, XDebug.Color.Red); if (NetworkData.Instance.UserChoiceRegion != null) { PhotonNetwork.ConnectToRegion(NetworkData.Instance.UserChoiceRegion); } else { PhotonNetwork.ConnectUsingSettings(); } }
public void ConnectToRegion(CloudRegionCode code) { if (PhotonNetwork.connected) { PhotonNetwork.Disconnect(); } PhotonNetwork.offlineMode = false; connecting = true; PhotonNetwork.ConnectToRegion(code, version); PhotonNetwork.sendRate = 30; PhotonNetwork.sendRateOnSerialize = 30; }
public virtual void ConnectToRegion() { isConnectOffline = false; PhotonNetwork.automaticallySyncScene = true; PhotonNetwork.autoJoinLobby = false; PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.PhotonCloud; PhotonNetwork.offlineMode = false; PhotonNetwork.ConnectToRegion(region, gameVersion); if (onConnectingToMaster != null) { onConnectingToMaster.Invoke(); } }
public void OnNewJoin() { newJoin = true; var region = Regions.GetRegionShortName(currentServer.text); if (PhotonNetwork.IsConnected) { PhotonNetwork.Disconnect(); } currentServer.text = "Connecting..."; PhotonNetwork.ConnectToRegion(region); notice.WaitToConnect(); }
/// <summary> /// /// </summary> /// <param name="id"></param> public void ChangeServerCloud(int id) { if (PhotonNetwork.connected) { PhotonNetwork.Disconnect(); Debug.LogWarning("Try again, because still not disconnect"); return; } if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty) { switch (id) { case 0: PhotonNetwork.ConnectToRegion(CloudRegionCode.us, AppVersion); break; case 1: PhotonNetwork.ConnectToRegion(CloudRegionCode.asia, AppVersion); break; case 2: PhotonNetwork.ConnectToRegion(CloudRegionCode.au, AppVersion); break; case 3: PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, AppVersion); break; case 4: PhotonNetwork.ConnectToRegion(CloudRegionCode.jp, AppVersion); break; case 5: PhotonNetwork.ConnectToRegion(CloudRegionCode.cae, AppVersion); break; case 6: PhotonNetwork.ConnectToRegion(CloudRegionCode.sa, AppVersion); break; case 7: PhotonNetwork.ConnectToRegion(CloudRegionCode.usw, AppVersion); break; } } else { Debug.LogWarning("Need your AppId for changer server, please add it in inspector"); } }
public void JoinRegion(string region) { var cloudRegion = (CloudRegionCode)Enum.Parse(typeof(CloudRegionCode), region.ToLower()); if (PhotonNetwork.ConnectToRegion(cloudRegion, "2020")) { // Succeeded Navigate(typeof(ServerList)); } else { // Rip } }
public void ChangeServer(int region) { if (PhotonNetwork.connected) { PhotonNetwork.Disconnect(); WaitForConnectToNew = true; ServerHost = bl_CoopUtils.IntToRegionCode(region); Debug.LogWarning("Wait for the current server disconnect and reconnect to new."); return; } //If disconect, connect again to the select region PhotonNetwork.ConnectToRegion(bl_CoopUtils.IntToRegionCode(region), GameVersion); ServerHost = bl_CoopUtils.IntToRegionCode(region); WaitForConnectToNew = false; this.GetComponent <bl_LobbyUI>().ChangeWindow(6); }
public override void OnEnter() { // reset authentication failure properties. PlayMakerPhotonProxy.lastAuthenticationDebugMessage = string.Empty; PlayMakerPhotonProxy.lastAuthenticationFailed = false; bool _result = PhotonNetwork.ConnectToRegion(region.Value); if (!result.IsNone) { result.Value = _result; } Fsm.Event(_result ? willProceed : willNotProceed); Finish(); }
public bool CreateNamedRoom(string roomName) { isNamedConnecting = true; targetRoomName = roomName; UpdateCustomProperties(); if (!PhotonNetwork.connected) { launcherPanel.ProgressLabel.text = "Can't create room! No connection!"; return(PhotonNetwork.ConnectToRegion(selectedRegion, GameVersion)); } return(PhotonNetwork.CreateRoom(roomName, new RoomOptions { MaxPlayers = MaxPlayersPerRoom }, null)); }
// Start is called before the first frame update void Start() { //print("Connecting to server..."); if (!PhotonNetwork.IsConnected) { PhotonNetwork.AutomaticallySyncScene = true; //PhotonNetwork.SendRate = 20; // 20 on default per second //PhotonNetwork.SerializationRate = 5; // 10 on default per second (the bigger the value , the bigger lag) //AuthenticationValues authValues = new AuthenticationValues("0"); -> treba biti unique //PhotonNetwork.AuthValues = authValues; PhotonNetwork.GameVersion = "0.0.1"; // da se igra ne brejka ako se razlicite verzije spajaju, tu nece bit toga PhotonNetwork.NickName = MasterManager.GameSettings.Nickname; PhotonNetwork.GameVersion = MasterManager.GameSettings.GameVersion; PhotonNetwork.ConnectUsingSettings(); PhotonNetwork.ConnectToRegion("0"); } }
public void DisconnectedFromPhoton() { if (challengeMode.value) { if (challenge.data != null) { PhotonNetwork.ConnectToRegion(challenge.data.message.ToCloudRegionCode(), Application.version); } else { PhotonNetwork.ConnectToRegion(server.value.ToCloudRegionCode(), Application.version); } } else { challenge.data = null; } }
/// <summary> /// Méthode de tentative de connexion au serveur de Photon. /// </summary> public void tryLoggingtoMaster() { if (!PhotonNetwork.connected) { if (MS_WebCloudConnection) { print("<color=green>Trying ConnectToRegion EU : " + MS_ConnVersion + " </color>"); PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, MS_ConnVersion); } else { print("PhotonNetwork.gameVersion: " + PhotonNetwork.gameVersion); print("PhotonNetwork.versionPUN: " + PhotonNetwork.versionPUN); print("<color=green>Trying ConnectToMaster : " + MS_adress + ":" + MS_port + " " + MS_ConnVersion + " " + MS_protocol.ToString() + " </color>"); PhotonNetwork.SwitchToProtocol(MS_protocol); PhotonNetwork.ConnectToMaster(MS_adress, MS_port, MS_appid, MS_ConnVersion); } } }
public static IEnumerator ConnectAndJoinIE(bool spawnAfterLoad) { if (spawnAfterLoad) { SceneManager.sceneLoaded += onLevelWasLoadedSpawn; } SceneManager.sceneLoaded += OnSceneLoaded; if (PhotonNetwork.JoinedRoomOrLobby()) { PhotonNetwork.Disconnect(); } while (PhotonNetwork.JoinedRoomOrLobby()) { yield return(new WaitForEndOfFrame()); } "Connecting...".SendProcessing(true); PhotonNetwork.PhotonServerSettings.JoinLobby = false; PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, "2020"); while (!readyToJoinOrCreateRoom) { yield return(new WaitForEndOfFrame()); } PhotonNetwork.PhotonServerSettings.JoinLobby = false; var roomOptions = new RoomOptions { IsVisible = true, IsOpen = true, MaxPlayers = 10, CustomRoomProperties = new ExitGames.Client.Photon.Hashtable { { "name", "TestDev" }, { "level", "The City - Classic" }, { "gamemode", "Titans" } }, CustomRoomPropertiesForLobby = new[] { "name", "level", "gamemode" } }; PhotonNetwork.PhotonServerSettings.JoinLobby = true; PhotonNetwork.CreateRoom(Guid.NewGuid().ToString(), roomOptions, TypedLobby.Default); "Creating a room...".SendProcessing(true); }
// EXECUTABLE: ---------------------------------------------------------------------------- public override bool InstantExecute(GameObject target, IAction[] actions, int index, params object[] parameters) { if (!string.IsNullOrEmpty(gameVersion.GetValue(target))) { PhotonNetwork.GameVersion = gameVersion.GetValue(target); } bool result = false; switch (method) { case ConnectType.UsingSettings: result = PhotonNetwork.ConnectUsingSettings(); break; case ConnectType.Region: result = PhotonNetwork.ConnectToRegion(GetRegionCode(region)); break; case ConnectType.BestCloudServer: result = PhotonNetwork.ConnectToBestCloudServer(); break; } return(result); }
/// <summary> /// use PhotonNetwork.ConnectToRegion, returns fullname of Region /// </summary> /// <param name="region"></param> public static string ConnectToRegion(Region region) { if (!PhotonNetwork.IsConnected) { if (region != Region.ind) { PhotonNetwork.ConnectToRegion(region.ToString()); } else { PhotonNetwork.ConnectToRegion("in"); } if (PhotonNetwork.IsConnectedAndReady) { Debug.Log(":D"); Photon.Pun.PhotonNetwork.JoinLobby(); } } return(RegionName[(int)region]); }
public void ChangeServerCloud(int id) { if (PhotonNetwork.IsConnected && FirstConnectionMade) { serverchangeRequested = true; ChangeWindow(3); #if LOCALIZATION LoadingScreenText.text = bl_Localization.Instance.GetText(40); #else LoadingScreenText.text = bl_GameTexts.ConnectingToGameServer; #endif StartCoroutine(ShowLoadingScreen()); MenusUI[1].SetActive(false); PendingRegion = id; Invoke("DelayDisconnect", 0.2f); return; } if (!string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime)) { if (!FirstConnectionMade) { PendingRegion = id; serverchangeRequested = true; return; } serverchangeRequested = false; SeverRegionCode code = SeverRegionCode.usw; if (id > 3) { id++; } code = (SeverRegionCode)id; PhotonNetwork.NetworkingClient.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime; PhotonNetwork.ConnectToRegion(code.ToString()); PlayerPrefs.SetString(PropertiesKeys.PreferredRegion, code.ToString()); } else { Debug.LogWarning("Need your AppId for change server, please add it in PhotonServerSettings"); } }