当前位置: 首页>>代码示例>>C#>>正文


C# CloudRegionCode类代码示例

本文整理汇总了C#中CloudRegionCode的典型用法代码示例。如果您正苦于以下问题:C# CloudRegionCode类的具体用法?C# CloudRegionCode怎么用?C# CloudRegionCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloudRegionCode类属于命名空间,在下文中一共展示了CloudRegionCode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectRegion

    public void SelectRegion(int index)
    {
        PhotonNetwork.PhotonServerSettings.ServerAddress = cloudServers[index].address;

        CloudRegionCode region = new CloudRegionCode();

        switch (index)
        {
            case 0:
                region = CloudRegionCode.asia;
                break;

            case 1:
                region = CloudRegionCode.us;
                break;

            case 2:
                region = CloudRegionCode.eu;
                break;

            case 3:
                region = CloudRegionCode.jp;
                break;

            case 4:
                region = CloudRegionCode.au;
                break;
        }

        PhotonNetwork.OverrideBestCloudServer(region);

        GameManager.instance.network.Connect();

        Application.LoadLevel("2_Lobby");
    }
开发者ID:anitricks,项目名称:FruityDeathmatch,代码行数:35,代码来源:RegionSelection.cs

示例2: ConnectToRegionMaster

    /// <summary>
    /// Connects you to a specific region's Master Server, using the Name Server to find the IP.
    /// </summary>
    /// <returns>If the operation could be sent. If false, no operation was sent.</returns>
    public bool ConnectToRegionMaster(CloudRegionCode region)
    {
        if (PhotonHandler.AppQuits)
        {
            Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits.");
            return false;
        }

        IsUsingNameServer = true;
        this.CloudRegion = region;

        if (this.State == global::PeerState.ConnectedToNameServer)
        {
            return this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, region.ToString());
        }

        #if RHTTP
        string address = (this.UsedProtocol == ConnectionProtocol.RHttp) ? this.NameServerAddressHttp : this.NameServerAddress;
        #else
        string address = this.NameServerAddress;
        #endif

        if (!address.Contains(":"))
        {
            int port = 0;
            ProtocolToNameServerPort.TryGetValue(this.UsedProtocol, out port);
            address = string.Format("{0}:{1}", address, port);
            //Debug.Log("Server to connect to: "+ address + " settings protocol: " + PhotonNetwork.PhotonServerSettings.Protocol);
        }
        if (!base.Connect(address, "ns"))
        {
            return false;
        }

        this.State = global::PeerState.ConnectingToNameServer;
        return true;
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:41,代码来源:NetworkingPeer.cs

示例3: OverrideBestCloudServer

 /// <summary>Overwrites the region that is used for ConnectToBestCloudServer(string gameVersion).</summary>
 /// <remarks>
 /// This will overwrite the result of pinging all cloud servers.
 /// Use this to allow your users to save a manually selected region in the prefs.
 /// </remarks>
 public static void OverrideBestCloudServer(CloudRegionCode region)
 {
     PhotonHandler.BestRegionCodeInPreferences = region;
 }
开发者ID:Kaljo123,项目名称:Teleport,代码行数:9,代码来源:PhotonNetwork.cs

示例4: ConnectToRegion

    /// <summary>
    /// Connects to the Photon Cloud region of choice.
    /// </summary>
    public static bool ConnectToRegion(CloudRegionCode region, string gameVersion)
    {
        if (PhotonServerSettings == null)
        {
            Debug.LogError("Can't connect: ServerSettings asset must be in any 'Resources' folder as: " + PhotonNetwork.serverSettingsAssetFile);
            return false;
        }

        if (PhotonServerSettings.HostType == ServerSettings.HostingOption.OfflineMode)
        {
            return PhotonNetwork.ConnectUsingSettings(gameVersion);
        }

        networkingPeer.IsInitialConnect = true;
        networkingPeer.SetApp(PhotonServerSettings.AppID, gameVersion);

        if (region != CloudRegionCode.none)
        {
            Debug.Log("ConnectToRegion: " + region);
            return networkingPeer.ConnectToRegionMaster(region);
        }

        return false;
    }
开发者ID:Kaljo123,项目名称:Teleport,代码行数:27,代码来源:PhotonNetwork.cs

示例5: PingAvailableRegionsCoroutine

    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != PeerState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != PeerState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return new WaitForSeconds(0.25f); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        //#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
        //#pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
        //if (PhotonPeer.NoSocket)
        //{
        //    if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
        //    {
        //        Debug.Log("PUN disconnects to re-use native sockets for pining servers and to find the best.");
        //    }
        //    PhotonNetwork.Disconnect();
        //}
        //#pragma warning restore 0162
        //#endif

        PhotonPingManager pingManager = new PhotonPingManager();
        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return new WaitForSeconds(0.1f); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;
        PhotonHandler.BestRegionCodeCurrently = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
开发者ID:minhdu,项目名称:mmo-client,代码行数:58,代码来源:PhotonHandler.cs

示例6: OnGuiSetupCloudAppId

    protected virtual void OnGuiSetupCloudAppId()
    {
        GUILayout.Label(CurrentLang.AppIdLabel);

        GUILayout.BeginHorizontal();
        this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId);

        open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false));

        GUILayout.EndHorizontal();

        if (open) GUILayout.Label(CurrentLang.AppIdInfoLabel);



        EditorGUILayout.Separator();

        GUILayout.Label(CurrentLang.CloudRegionLabel);

        GUILayout.BeginHorizontal();
        int toolbarValue = GUILayout.Toolbar((int)selectedRegion, CloudServerRegionNames);   // the enum CloudRegionCode is converted into a string[] in init (toolbar can't use enum)
        helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false));
        GUILayout.EndHorizontal();


        if (helpRegion) GUILayout.Label(CurrentLang.RegionalServersInfo);
        PhotonEditor.selectedRegion = (CloudRegionCode)toolbarValue;

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button(CurrentLang.CancelButton))
        {
            GUIUtility.keyboardControl = 0;
            this.ReApplySettingsToWindow();
        }



        if (GUILayout.Button(CurrentLang.SaveButton))
        {
            GUIUtility.keyboardControl = 0;
            this.cloudAppId = this.cloudAppId.Trim();
            PhotonEditor.Current.UseCloud(this.cloudAppId);

            PhotonEditor.Current.PreferredRegion = PhotonEditor.selectedRegion;
            PhotonEditor.Current.HostType = (PhotonEditor.Current.PreferredRegion == CloudRegionCode.none)
                                                ? ServerSettings.HostingOption.BestRegion
                                                : ServerSettings.HostingOption.PhotonCloud;
            PhotonEditor.Save();

            Inspect();
            EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton);
        }

        GUILayout.EndHorizontal();



        GUILayout.Space(20);

        GUILayout.Label(CurrentLang.SetupOwnServerLabel);

        if (GUILayout.Button(CurrentLang.SelfHostSettingsButton))
        {
            //this.photonAddress = ServerSettings.DefaultServerAddress;
            //this.photonPort = ServerSettings.DefaultMasterPort;
            this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
        }

        EditorGUILayout.Separator();
        GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel);
        if (GUILayout.Button(CurrentLang.ComparisonPageButton))
        {
            Application.OpenURL(UrlCompare);
        }
    }
开发者ID:AsifAhmed16,项目名称:Operation-Hatirjheel,代码行数:77,代码来源:PhotonEditor.cs

示例7: ConnectToRegionMaster

    /// <summary>
    /// Connects you to a specific region's Master Server, using the Name Server to find the IP.
    /// </summary>
    /// <returns>If the operation could be sent. If false, no operation was sent.</returns>
    public bool ConnectToRegionMaster(CloudRegionCode region)
    {
        if (PhotonHandler.AppQuits)
        {
            Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits.");
            return false;
        }

        IsUsingNameServer = true;
        this.CloudRegion = region;

        if (this.State == global::PeerState.ConnectedToNameServer)
        {
            AuthenticationValues auth = this.CustomAuthenticationValues ?? new AuthenticationValues() { UserId = this.PlayerName };
            return this.OpAuthenticate(this.mAppId, this.mAppVersionPun, auth, region.ToString(), requestLobbyStatistics);
        }

        string address = this.NameServerAddress;
        if (!base.Connect(address, "ns"))
        {
            return false;
        }

        this.State = global::PeerState.ConnectingToNameServer;
        return true;
    }
开发者ID:houseofkohina,项目名称:ProjectDoge,代码行数:30,代码来源:NetworkingPeer.cs

示例8: PingAvailableRegionsCoroutine

    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != ClientState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return new WaitForSeconds(0.25f); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        PhotonPingManager pingManager = new PhotonPingManager();
        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return new WaitForSeconds(0.1f); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;
        PhotonHandler.BestRegionCodeCurrently = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:45,代码来源:PhotonHandler.cs

示例9: UseCloud

 public void UseCloud(string cloudAppid, CloudRegionCode code)
 {
     this.HostType = HostingOption.PhotonCloud;
     this.AppID = cloudAppid;
     this.PreferredRegion = code;
 }
开发者ID:Ralph89,项目名称:SoccerRally,代码行数:6,代码来源:ServerSettings.cs

示例10: ConnectToRegionMaster

    /// <summary>
    /// Connects you to a specific region's Master Server, using the Name Server to find the IP.
    /// </summary>
    /// <returns>If the operation could be sent. If false, no operation was sent.</returns>
    public bool ConnectToRegionMaster(CloudRegionCode region)
    {
        if (PhotonHandler.AppQuits)
        {
            Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits.");
            return false;
        }

        IsUsingNameServer = true;
        this.CloudRegion = region;

        if (this.State == ClientState.ConnectedToNameServer)
        {
            return this.CallAuthenticate();
        }

        this.SetupProtocol(ServerConnection.NameServer);
        if (!base.Connect(this.NameServerAddress, "ns", this.TokenForInit))
        {
            return false;
        }

        this.State = ClientState.ConnectingToNameServer;
        return true;
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:29,代码来源:NetworkingPeer.cs

示例11: RegionToString

 /// <summary>
 /// 
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public static string RegionToString(CloudRegionCode code)
 {
     switch (code)
     {
         case CloudRegionCode.asia:
             return "ASIA";
         case CloudRegionCode.au:
             return "AUSTRALIA";
         case CloudRegionCode.eu:
             return "EUROPE";
         case CloudRegionCode.jp:
             return "JAPAN";
         case CloudRegionCode.us:
             return "USA";
     }
     return "NONE"; // equal a none
 }
开发者ID:tegleg,项目名称:mfp,代码行数:22,代码来源:bl_CoopUtils.cs

示例12: RegionCodeToInt

 /// <summary>
 /// 
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public static int RegionCodeToInt(CloudRegionCode code)
 {
     switch (code)
     {
         case CloudRegionCode.asia:
             return 0;
         case CloudRegionCode.au:
             return 1;
         case CloudRegionCode.eu:
             return 2;
         case CloudRegionCode.jp:
             return 3;
         case CloudRegionCode.us:
             return 4;
     }
     return 5; // equal a none
 }
开发者ID:tegleg,项目名称:mfp,代码行数:22,代码来源:bl_CoopUtils.cs

示例13: ChangeServer

 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);
 }
开发者ID:tegleg,项目名称:mfp,代码行数:16,代码来源:bl_Lobby.cs


注:本文中的CloudRegionCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。