Esempio n. 1
0
    void OnGUI()
    {
        // You would normally not join a match you created yourself but this is possible here for demonstration purposes.
        if (GUILayout.Button("Create Room"))
        {
            string matchName      = "room";
            uint   matchSize      = 4;
            bool   matchAdvertise = true;
            string matchPassword  = "";

            networkMatch.CreateMatch(matchName, matchSize, matchAdvertise, matchPassword, "", "", 0, 0, OnMatchCreate);
        }

        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", true, 0, 0, OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }
        foreach (var match in matchList)
        {
            if (GUILayout.Button(match.name))
            {
                networkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
            }
        }
    }
    void OnGUI()
    {
        if (GUILayout.Button("Start Match"))
        {
            CreateMatchRequest create = new CreateMatchRequest();
            create.name      = "NewRoom";
            create.size      = 4;
            create.advertise = true;
            create.password  = "";

            networkMatch.CreateMatch(create, OnMatchCreate);
        }

        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }

        foreach (var m in matchList)
        {
            if (GUILayout.Button(m.name))
            {
                networkMatch.JoinMatch(m.networkId, "", OnMatchJoined);
            }
        }
    }
Esempio n. 3
0
    void OnGUI()
    {
        // You would normally not join a match you created yourself but this is possible here for demonstration purposes.
        if (GUILayout.Button("Create Room"))
        {
            CreateMatchRequest create = new CreateMatchRequest();
            create.name      = "NewRoom";
            create.size      = 4;
            create.advertise = true;
            create.password  = "";

            networkMatch.CreateMatch(create, OnMatchCreate);
        }

        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }
        foreach (var match in matchList)
        {
            if (GUILayout.Button(match.name))
            {
                networkMatch.JoinMatch(match.networkId, "", OnMatchJoined);
            }
        }
    }
Esempio n. 4
0
    void OnGUI()
    {
        // You would normally not join a match you created yourself but this is possible here for demonstration purposes.
        if (GUILayout.Button("Create Room"))
        {
            networkMatch.CreateMatch("NewRoom", 4, true, "", "", "", 0, 0, OnMatchCreate);
        }

        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", false, 0, 0, OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }
        foreach (var match in matchList)
        {
            if (GUILayout.Button(match.name))
            {
                networkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
            }
        }
    }
Esempio n. 5
0
    void OnGUI()
    {
        if (GUILayout.Button("Create Room"))
        {
            networkMatch.CreateMatch("New Room", 4, true, "", "", "", 0, 0, OnMatchCreate);
        }

        if (GUILayout.Button("List Rooms"))
        {
            networkMatch.ListMatches(0, 10, "", true, 0, 0, OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current Rooms");

            foreach (var match in matchList)
            {
                if (GUILayout.Button(match.name))
                {
                    if (GUILayout.Button(match.name))
                    {
                        networkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
                    }
                }
            }
        }
    }
Esempio n. 6
0
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         networkMatch.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoined);
     }
 }
        public void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
        {
            if (success && matches != null)
            {
                int foundRoom = -1;
                for (int i = 0; i < matches.Count; i++)
                {
                    if (matches[i].name == roomName)
                    {
                        foundRoom = i;
                    }
                }

                if (foundRoom == -1)
                {
                    networkMatch.CreateMatch(roomName, 1000, true, "", "", "", 0, gameVersion, OnMatchCreated);
                }
                else
                {
                    networkMatch.JoinMatch(matches[foundRoom].networkId, "", "", "", 0, 0, OnMatchJoined);
                }
            }
            else if (!success)
            {
                Debug.LogError("List match failed: " + extendedInfo);
            }
        }
Esempio n. 8
0
    public static void OnMatchList_Aceitar_Convite(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
    {
        if (success && matches != null)
        {
            m_MatchList = matches;
            bool Cod_Valid = false;

            foreach (var match in m_MatchList)
            {
                //if (match.name==PlayerPrefs.GetString("Codigo"))
                //{
                Debug.Log("Codigo de convite valido");
                m_NetworkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
                Cod_Valid = true;
                break;
                //}
            }

            if (Cod_Valid)
            {
                Debug.Log("Codigo de convite valido");
            }
            else
            {
                Debug.Log("Codigo de convite invalido");
                GameObject.Find("Cod_Validator_Component").GetComponent <Text> ().text = "Código Inválido";
            }
        }
        else if (!success)
        {
            Debug.LogError("List match failed: " + extendedInfo);
        }
    }
Esempio n. 9
0
    public void Connect(string pass)
    {
        NetworkLobbyManager manager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkLobbyManager>();;
        NetworkMatch        match   = manager.GetComponent <NetworkLobbyManager>().matchMaker;

        match.JoinMatch(ConnectGame.networkId, pass, manager.OnMatchJoined);
    }
Esempio n. 10
0
 private void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matchList)
 {
     if (success)
     {
         bool isMatch = false;
         if (matchList.Count != 0)
         {
             for (int i = 0; i < matchList.Count; ++i)
             {
                 if (matchList[i].currentSize < matchList[i].maxSize)
                 {
                     isMatch = true;
                     match.JoinMatch(matchList[i].networkId, "", "", "", 0, reqDomain, OnMatchCreateJoin);
                 }
             }
         }
         if (isMatch == false)
         {
             Invoke("Connect", 1f);
         }
     }
     else
     {
         Debug.LogError(extendedInfo);
         Invoke("Connect", 3f);
     }
 }
    public void ConnectToOrCreateMatch(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
    {
        print("NetworkManager: ConnectToOrCreateMatch");
        if (success && matches != null)
        {
            var filteredMatches = new List <MatchInfoSnapshot>(matches); // Filter out matches based on channel and blacklist
            filteredMatches.RemoveAll(
                (MatchInfoSnapshot snapshot) => blackListedMatches.Contains(snapshot.name));
            filteredMatches.RemoveAll(
                (MatchInfoSnapshot snapshot) => !snapshot.name.Contains("ch" + channel));

            if (filteredMatches.Count > 0 && filteredMatches[0].currentSize > 0)
            {
                currentMatch = filteredMatches[0].name;
                print("NetworkManager: Joining match '" + currentMatch
                      + "' with " + filteredMatches[0].currentSize + " players");

                networkMatcher.JoinMatch(filteredMatches[0].networkId, "", "", "", 0, 0, OnMatchJoined);
            }
            else
            {
                createNewMatch();
            }
        }
        else
        {
            print("Failed listing matches: " + extendedInfo);
        }
    }
Esempio n. 12
0
    private void OnGUI()
    {
        if (GUILayout.Button("Create Room"))
        {
            string matchName      = "room";
            uint   matchSize      = 2;
            bool   matchAdvertise = true;
            string matchPassword  = "";

            networkMatch.CreateMatch(matchName, matchSize, matchAdvertise, matchPassword, "", "", 0, 0, OnMatchCreate);
        }

        if (GUILayout.Button("Refresh"))
        {
            networkMatch.ListMatches(0, 20, "", true, 0, 0, OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Available rooms");
        }
        foreach (MatchInfoSnapshot mis in matchList)
        {
            if (GUILayout.Button(mis.name))
            {
                networkMatch.JoinMatch(mis.networkId, "", "", "", 0, 0, OnMatchJoined);
            }
        }
    }
Esempio n. 13
0
    void OnGUI()
    {
        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }
        foreach (var match in matchList)
        {
            if (GUILayout.Button(match.name))
            {
                networkMatch.JoinMatch(match.networkId, "", OnMatchJoined);
            }
        }
    }
Esempio n. 14
0
 public void JoinRoom()
 {
     ListRooms();
     foreach (var match in matchList)
     {
         if (match.name == gameNameField.text)
         {
             networkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
         }
     }
 }
Esempio n. 15
0
    void Start()
    {
        manager = GetComponent <NetworkManager>();
        manager.StartMatchMaker();
        matcher = manager.matchMaker;

        matcher.ListMatches(0, ListSize, "", (matches) => {
            if (matches.success)
            {
                if (matches.matches.Count > 0 && !OnlyHost)
                {
                    matcher.JoinMatch(matches.matches[0].networkId, "", (join) => {
                        if (join.success)
                        {
                            Utility.SetAccessTokenForNetwork(join.networkId, new NetworkAccessToken(join.accessTokenString));
                            NetworkClient client = new NetworkClient();
                            client.RegisterHandler(MsgType.Connect, (connected) => {
                                Debug.Log("Connected");
                            });
                            client.Connect(new MatchInfo(join));
                            manager.StartClient();
                        }
                        else
                        {
                            Debug.LogError("Could not join match");
                        }
                    });
                }
                else
                {
                    matcher.CreateMatch(URandom.value.ToString(), PlayerCountPerRoom, Advertise, "", (created) => {
                        if (created.success)
                        {
                            Debug.Log("Create match succeeded");
                            Utility.SetAccessTokenForNetwork(created.networkId, new NetworkAccessToken(created.accessTokenString));
                            NetworkServer.Listen(new MatchInfo(created), 9000);
                            manager.StartHost();
                            isHost = true;
                        }
                        else
                        {
                            Debug.LogError("Could not create match");
                        }
                    });
                }
            }
            else
            {
                Debug.LogError("Could not recieve list of matchces");
            }
        });
    }
 public void AddListenerMatch(MatchInfoSnapshot gameMatch)
 {
     MenuMangerScript.JoinAMatchButton.GetComponent <Button>().onClick.RemoveAllListeners();
     MenuMangerScript.JoinAMatchButton.GetComponent <Button>().onClick.AddListener(
         delegate {
         if (!hasjoinGame && !hascreatedGame && !ClientScene.ready)
         {
             hasjoinGame = true;
             MenuMangerScript.loadanimation.SetActive(true);
             MenuMangerScript.erroranimation.SetActive(false);
             networkMatch.JoinMatch(gameMatch.networkId, "", "", "", 0, 1, OnMatchJoined);
         }
     });
 }
Esempio n. 17
0
        public void JoinFirstInternetMatch()
        {
            if (IsActive)
            {
                return;
            }

            networkMatch.ListMatches(0, 1, "", true, 0, 0, (success, info, matches) =>
            {
                if (success && matches.Count > 0)
                {
                    networkMatch.JoinMatch(matches[0].networkId, "", "", "", 0, 0, OnMatchJoined);
                }
            });
        }
Esempio n. 18
0
    public IEnumerator JoinMatch(int mcount, List <MatchInfoSnapshot> matches)
    {
        yield return(new WaitForSeconds(1f));

        bool reached = false;

        if (mcount > 0)
        {
            int selectedMatch = Random.Range(0, mcount);
            int count         = 0;
            foreach (var match in matches)
            {
                if (count == selectedMatch)
                {
                    create.gameObject.SetActive(false);
                    join.gameObject.SetActive(false);

                    manager.matchName = match.name;
                    manager.matchSize = (uint)match.currentSize;

                    /* PARAMETERS for CreateMatch()
                     * netID: The network identity of the match to be joined
                     * matchPassword: Password required to join this room (Will never be used...for now)
                     * publicClientAddress: For online activity (should be fine if it's blank)
                     * privateClientAddress: For local players (not necessary...for now)
                     * eloScoreForMatch: Skills, bonueses, etc.
                     * requestDomain: Perfect for future enhancements for different tiers (or difficulty)
                     * callBack: Callback for when the function completes
                     */
                    //manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, OnJoinInternetMatch);
                    //NetworkManager.singleton.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, OnJoinInternetMatch);
                    networkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnJoinInternetMatch);
                    reached = true;
                    break;
                }
                count++;
            }
            if (!reached)
            {
                UpdateErrorMessage("Error Selecting Matches");
            }
        }
        else
        {
            UpdateErrorMessage("No matches at this time");
        }
    }
Esempio n. 19
0
    public void OnMatchList(ListMatchResponse matchListResponse)
    {
        foreach (MatchDesc desc in matchListResponse.matches)
        {
            if (desc.name.Equals(nameText.text))
            {
                networkMatch.JoinMatch(desc.networkId, "", OnMatchJoined);
                matchFound = true;
                break;
            }
        }

        if (!matchFound)
        {
            print("Match could not be found");
        }
    }
Esempio n. 20
0
    public void OnJoinButtonClick()
    {
        string strBabyName = m_InputField.text;

        m_NetworkMatch.ListMatches(0, 1, m_InputField.text, true, 0, 0, (success, info, matches) =>
        {
            if (success && matches.Count > 0)
            {
                m_NetworkMatch.JoinMatch(matches[0].networkId, "", "", "", 0, 0, OnMatchJoined);
            }
            else
            {
                m_StateDisplay.text = "没有找到与宝贝名字相同的连接";
            }
        });
        PlayerPrefs.SetString("BabyName", strBabyName);
        m_StateDisplay.text = "正在连接中";
    }
Esempio n. 21
0
    //----------------------------------------------------------------------------------------------------
    /// <summary>
    /// フレームメソッド
    /// </summary>
    void Update()
    {
        //待機状態
        if (m_isStandbyState)
        {
            return;
        }

        //部屋作成中
        if (m_isCreateRoom)
        {
            //更新
            m_match.ListMatches(0, 20, "", true, 0, 0, OnMatchList);

            //使用中のネットワークIDを取得
            if (matches.Count >= 1 && matchInfo != null)
            {
                m_networkIdInUse = (UInt64)matchInfo.networkId;
                m_isStandbyState = true;
            }
            return;
        }

        //リストマッチの更新
        if (matches == null)
        {
            //更新
            m_match.ListMatches(0, 20, "", true, 0, 0, OnMatchList);
        }
        else if (matches.Count >= 1 && IsMatch())
        {
            //ルームに参加
            m_match.JoinMatch((UnityEngine.Networking.Types.NetworkID)m_networkIdInUse, "", "", "", 0, 0, OnMatchJoined);
            m_isJoinRoom     = true;
            m_isStandbyState = true;
        }
        else
        {
            //ルームの作成
            matchName = ROOM_NAME + DateTime.Now.ToLongTimeString();
            m_match.CreateMatch(matchName, matchSize, true, "", "", "", 0, 0, OnMatchCreate);
            m_isCreateRoom = true;
        }
    }
 public void ConnectToOrCreateMatch(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
 {
     if (success)
     {
         if (singlePlayerDebug && matches != null && matches.Count > 0)
         {
             networkMatcher.JoinMatch(matches[0].networkId, "", "", "", 0, 0, OnMatchJoined);
         }
         else
         {
             print("Matches (" + matches.Count + "): " + matches);
             networkMatcher.CreateMatch("defaultRoomTest", 20, true, "", "mm.unet.unity3d.com", "", 0, 0, OnMatchCreate);
         }
     }
     else if (!success)
     {
         print("Failed listing matches: " + extendedInfo);
     }
 }
Esempio n. 23
0
    void Start()
    {
        manager = GetComponent<NetworkManager>();
        manager.StartMatchMaker();
        matcher = manager.matchMaker;

        matcher.ListMatches(0, ListSize, "", (matches) => {
            if (matches.success) {
                if (matches.matches.Count > 0 && !OnlyHost) {
                    matcher.JoinMatch(matches.matches[0].networkId, "", (join) => {
                        if (join.success) {
                            Utility.SetAccessTokenForNetwork(join.networkId, new NetworkAccessToken(join.accessTokenString));
                            NetworkClient client = new NetworkClient();
                            client.RegisterHandler(MsgType.Connect, (connected) => {
                                Debug.Log("Connected");
                            });
                            client.Connect(new MatchInfo(join));
                            manager.StartClient();
                        } else {
                            Debug.LogError("Could not join match");
                        }
                    });
                } else {
                    matcher.CreateMatch(URandom.value.ToString(), PlayerCountPerRoom, Advertise, "", (created) => {
                        if (created.success) {
                            Debug.Log("Create match succeeded");
                            Utility.SetAccessTokenForNetwork(created.networkId, new NetworkAccessToken(created.accessTokenString));
                            NetworkServer.Listen(new MatchInfo(created), 9000);
                            manager.StartHost();
                            isHost = true;
                        } else {
                            Debug.LogError("Could not create match");
                        }
                    });
                }
            } else {
                Debug.LogError("Could not recieve list of matchces");
            }
        });
    }
Esempio n. 24
0
    public void OnMatchList(ListMatchResponse matchListResponse)
    {
        if (matchListResponse.success && matchListResponse.matches != null)
        {
            matchList = matchListResponse.matches;

            foreach (Transform child in matchesPanel)
            {
                Destroy(child.gameObject);
            }

            foreach (var match in matchList)
            {
                string buttonText = "Join match: " + match.name;

                GameObject goButton = (GameObject)Instantiate(matchButtonPrefab);
                goButton.transform.SetParent(matchesPanel, false);
                goButton.transform.FindChild("Text").GetComponent <Text>().text = buttonText;

                Button tempButton = goButton.GetComponent <Button>();
                tempButton.onClick.AddListener(() => networkMatch.JoinMatch(match.networkId, "", OnMatchJoined));
            }
        }
    }
Esempio n. 25
0
 public void buttonClicked(MatchDesc desc)
 {
     networkMatch.JoinMatch(desc.networkId, "", OnMatchJoined);
 }
Esempio n. 26
0
 public void OnMatchList(ListMatchResponse matchListResponse, NetworkMatch networkMatch, NetworkMatch.ResponseDelegate<JoinMatchResponse> OnMatchJoined)
 {
     foreach (MatchDesc md in matchListResponse.matches)
     {
         GameObject newButton = GameObject.Instantiate(joinButtonPrefab);
         newButton.transform.parent = joinGameUI.transform;
         newButton.transform.localPosition = new Vector2(newButton.transform.position.x, joinListY);
         newButton.GetComponentInChildren<Text>().text = md.name;
         newButton.GetComponent<Button>().onClick.AddListener(() => {
             networkMatch.JoinMatch(md.networkId, "", OnMatchJoined);
         });
         joinListY -= 20;
         joinGameButtons.Add(newButton);
     }
 }
Esempio n. 27
0
 public void JoinGame(MatchInfoSnapshot info)
 {
     networkMatch.JoinMatch(info.networkId, "", "", "", 0, 0, OnMatchJoined);
 }
Esempio n. 28
0
    void OnGUI()
    {
        if (string.IsNullOrEmpty(Application.cloudProjectId))
        {
            GUILayout.Label("You must set up the project first. See the Multiplayer tab in the Service Window");
        }
        else
        {
            GUILayout.Label("Cloud Project ID: " + Application.cloudProjectId);
        }

        if (m_MatchJoined)
        {
            GUILayout.Label("Match joined '" + m_MatchName + "' on Matchmaker server");
        }
        else if (m_MatchCreated)
        {
            GUILayout.Label("Match '" + m_MatchName + "' created on Matchmaker server");
        }

        GUILayout.Label("Connection Established: " + m_ConnectionEstablished);

        if (m_MatchCreated || m_MatchJoined)
        {
            GUILayout.Label("Relay Server: " + m_MatchInfo.address + ":" + m_MatchInfo.port);
            GUILayout.Label("NetworkID: " + m_MatchInfo.networkId + " NodeID: " + m_MatchInfo.nodeId);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Outgoing message:");
            m_NetworkMessage = GUILayout.TextField(m_NetworkMessage);
            GUILayout.EndHorizontal();
            GUILayout.Label("Last incoming message: " + m_LastReceivedMessage);

            if (m_ConnectionEstablished && GUILayout.Button("Send message"))
            {
                m_Writer.SeekZero();
                m_Writer.Write(m_NetworkMessage);
                byte error;
                for (int i = 0; i < m_ConnectionIds.Count; ++i)
                {
                    NetworkTransport.Send(m_HostId,
                                          m_ConnectionIds[i], 0, m_Writer.AsArray(), m_Writer.Position, out error);
                    if ((NetworkError)error != NetworkError.Ok)
                    {
                        Debug.LogError("Failed to send message: " + (NetworkError)error);
                    }
                }
            }

            if (GUILayout.Button("Shutdown"))
            {
                m_NetworkMatch.DropConnection(m_MatchInfo.networkId,
                                              m_MatchInfo.nodeId, 0, OnConnectionDropped);
            }
        }
        else
        {
            if (GUILayout.Button("Create Room"))
            {
                m_NetworkMatch.CreateMatch(m_MatchName, 4, true, "", "", "", 0, 0, OnMatchCreate);
            }

            if (GUILayout.Button("Join first found match"))
            {
                m_NetworkMatch.ListMatches(0, 1, "", true, 0, 0, (success, info, matches) =>
                {
                    if (success && matches.Count > 0)
                    {
                        m_NetworkMatch.JoinMatch(matches[0].networkId, "", "", "", 0, 0, OnMatchJoined);
                    }
                });
            }

            if (GUILayout.Button("List rooms"))
            {
                m_NetworkMatch.ListMatches(0, 20, "", true, 0, 0, OnMatchList);
            }

            if (m_MatchList.Count > 0)
            {
                GUILayout.Label("Current rooms:");
            }
            foreach (var match in m_MatchList)
            {
                if (GUILayout.Button(match.name))
                {
                    m_NetworkMatch.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
                }
            }
        }
    }
Esempio n. 29
0
        private void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }
            int  num  = 10 + offsetX;
            int  num2 = 40 + offsetY;
            bool flag = manager.client == null || manager.client.connection == null || manager.client.connection.connectionId == -1;

            if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
            {
                if (flag)
                {
                    if (Application.platform != RuntimePlatform.WebGLPlayer)
                    {
                        if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Host(H)"))
                        {
                            manager.StartHost();
                        }
                        num2 += 24;
                    }
                    if (GUI.Button(new Rect(num, num2, 105f, 20f), "LAN Client(C)"))
                    {
                        manager.StartClient();
                    }
                    manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress);
                    num2 += 24;
                    if (Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        GUI.Box(new Rect(num, num2, 200f, 25f), "(  WebGL cannot be server  )");
                        num2 += 24;
                    }
                    else
                    {
                        if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only(S)"))
                        {
                            manager.StartServer();
                        }
                        num2 += 24;
                    }
                }
                else
                {
                    GUI.Label(new Rect(num, num2, 200f, 20f), "Connecting to " + manager.networkAddress + ":" + manager.networkPort + "..");
                    num2 += 24;
                    if (GUI.Button(new Rect(num, num2, 200f, 20f), "Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                if (NetworkServer.active)
                {
                    string text = "Server: port=" + manager.networkPort;
                    if (manager.useWebSockets)
                    {
                        text += " (Using WebSockets)";
                    }
                    GUI.Label(new Rect(num, num2, 300f, 20f), text);
                    num2 += 24;
                }
                if (manager.IsClientConnected())
                {
                    GUI.Label(new Rect(num, num2, 300f, 20f), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                    num2 += 24;
                }
            }
            if (manager.IsClientConnected() && !ClientScene.ready)
            {
                if (GUI.Button(new Rect(num, num2, 200f, 20f), "Client Ready"))
                {
                    ClientScene.Ready(manager.client.connection);
                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer(0);
                    }
                }
                num2 += 24;
            }
            if (NetworkServer.active || manager.IsClientConnected())
            {
                if (GUI.Button(new Rect(num, num2, 200f, 20f), "Stop (X)"))
                {
                    manager.StopHost();
                }
                num2 += 24;
            }
            if (NetworkServer.active || manager.IsClientConnected() || !flag)
            {
                return;
            }
            num2 += 10;
            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)");
                return;
            }
            if (manager.matchMaker == null)
            {
                if (GUI.Button(new Rect(num, num2, 200f, 20f), "Enable Match Maker (M)"))
                {
                    manager.StartMatchMaker();
                }
                num2 += 24;
                return;
            }
            if (manager.matchInfo == null)
            {
                if (manager.matches == null)
                {
                    if (GUI.Button(new Rect(num, num2, 200f, 20f), "Create Internet Match"))
                    {
                        NetworkMatch   matchMaker     = manager.matchMaker;
                        string         matchName      = manager.matchName;
                        uint           matchSize      = manager.matchSize;
                        NetworkManager networkManager = manager;
                        matchMaker.CreateMatch(matchName, matchSize, matchAdvertise: true, "", "", "", 0, 0, networkManager.OnMatchCreate);
                    }
                    num2 += 24;
                    GUI.Label(new Rect(num, num2, 100f, 20f), "Room Name:");
                    manager.matchName = GUI.TextField(new Rect(num + 100, num2, 100f, 20f), manager.matchName);
                    num2 += 24;
                    num2 += 10;
                    if (GUI.Button(new Rect(num, num2, 200f, 20f), "Find Internet Match"))
                    {
                        NetworkMatch   matchMaker2     = manager.matchMaker;
                        NetworkManager networkManager2 = manager;
                        matchMaker2.ListMatches(0, 20, "", filterOutPrivateMatchesFromResults: false, 0, 0, networkManager2.OnMatchList);
                    }
                    num2 += 24;
                }
                else
                {
                    for (int i = 0; i < manager.matches.Count; i++)
                    {
                        MatchInfoSnapshot matchInfoSnapshot = manager.matches[i];
                        if (GUI.Button(new Rect(num, num2, 200f, 20f), "Join Match:" + matchInfoSnapshot.name))
                        {
                            manager.matchName = matchInfoSnapshot.name;
                            NetworkMatch   matchMaker3     = manager.matchMaker;
                            NetworkID      networkId       = matchInfoSnapshot.networkId;
                            NetworkManager networkManager3 = manager;
                            matchMaker3.JoinMatch(networkId, "", "", "", 0, 0, networkManager3.OnMatchJoined);
                        }
                        num2 += 24;
                    }
                    if (GUI.Button(new Rect(num, num2, 200f, 20f), "Back to Match Menu"))
                    {
                        manager.matches = null;
                    }
                    num2 += 24;
                }
            }
            if (GUI.Button(new Rect(num, num2, 200f, 20f), "Change MM server"))
            {
                m_ShowServer = !m_ShowServer;
            }
            if (m_ShowServer)
            {
                num2 += 24;
                if (GUI.Button(new Rect(num, num2, 100f, 20f), "Local"))
                {
                    manager.SetMatchHost("localhost", 1337, https: false);
                    m_ShowServer = false;
                }
                num2 += 24;
                if (GUI.Button(new Rect(num, num2, 100f, 20f), "Internet"))
                {
                    manager.SetMatchHost("mm.unet.unity3d.com", 443, https: true);
                    m_ShowServer = false;
                }
                num2 += 24;
                if (GUI.Button(new Rect(num, num2, 100f, 20f), "Staging"))
                {
                    manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, https: true);
                    m_ShowServer = false;
                }
            }
            num2 += 24;
            GUI.Label(new Rect(num, num2, 300f, 20f), "MM Uri: " + manager.matchMaker.baseUri);
            num2 += 24;
            if (GUI.Button(new Rect(num, num2, 200f, 20f), "Disable Match Maker"))
            {
                manager.StopMatchMaker();
            }
            num2 += 24;
        }
Esempio n. 30
0
 public void StartClient(NetworkID networkId, string password)
 {
     m_NetworkMatch.JoinMatch(networkId, password, "", "", 0, 0, OnMatchJoined);
 }