Ejemplo n.º 1
0
    public void joinGame(GameObject text)
    {
        string roomName = text.GetComponent <InputField>().text;

        if (roomName != null && roomName.Length > 0)
        {
            Debug.Log("Joining room named " + roomName);
            //find the info for the given room
            MatchDesc j = null;
            foreach (MatchDesc d in matches)
            {
                if (roomName.Equals(d.name))
                {
                    j = d;
                    break;
                }
            }
            if (j == null)
            {
                Debug.LogError("Match not found: " + roomName);
                return;
            }
            JoinMatchRequest matchReq = new JoinMatchRequest();
            matchReq.networkId = j.networkId;
            matchReq.password  = "";
            matchMaker.JoinMatch(matchReq, joinGameCallback);
        }
    }
Ejemplo n.º 2
0
    public override void OnMatchList(ListMatchResponse matchList)
    {
        bool      success    = matchList.success;
        int       matchCount = matchList.matches.Count;
        MatchDesc match      = null;
#endif
        if (!success)
        {
            Debug.Log("Failed to retrieve match list");
            return;
        }

        if (matchCount == 0)
        {
            Debug.Log("Match list is empty");
            return;
        }

#if NEW_STUFF
        match = matchList[0];
#else
        match = matchList.matches[0];
#endif

        if (match == null)
        {
            Debug.Log("Match list is empty");
            return;
        }

        Debug.Log("Found a match, joining");

        matchID = match.networkId;
        StartClientAll(match);
    }
Ejemplo n.º 3
0
    public void Setup(MatchDesc _match, JoinRoomDelegate _joinRoomCallback)
    {
        match            = _match;
        joinRoomCallback = _joinRoomCallback;

        roomNameText.text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
    }
Ejemplo n.º 4
0
    public override void OnMatchList(ListMatchResponse matchList)
    {
        bool success = matchList.success;
        int matchCount = matchList.matches.Count;
        MatchDesc match = null;
#endif
        if (!success)
        {
            Debug.Log("Failed to retrieve match list");
            return;
        }

        if (matchCount == 0)
        {
            Debug.Log("Match list is empty");
            return;
        }

#if NEW_STUFF
        match = matchList[0];
#else
        if (natHelper.guid != 0)
        {
            // If we have a guid we can use it to make sure we don't try and join our own old match 
            // This is only necessary thanks to a bug in 5.2 and 5.3 that prevents matches from 
            // being immediately destroyed
            foreach (MatchDesc m in matchList.matches)
            {
                string[] parts = m.name.Split('|');
                ulong hostGUID;
                ulong.TryParse(parts[parts.Length - 1], out hostGUID);
                if (hostGUID == natHelper.guid)
                {
                    Debug.Log("Not joining old match");
                }
                else
                {
                    match = m;
                    break;
                }
            }
        }
        else
        {
            match = matchList.matches[0];
        }
#endif

        if (match == null)
        {
            Debug.Log("Match list is empty");
            return;
        }

        Debug.Log("Found a match, joining");

        matchID = match.networkId;
        StartClientAll(match);
    }
Ejemplo n.º 5
0
        public void Populate(MatchDesc match)
        {
            UI.GameNameText.text    = match.name;
            UI.PlayerCountText.text = string.Format("{0}/{1}", match.currentSize, match.maxSize);

            UI.JoinButton.onClick.RemoveAllListeners();
            UI.JoinButton.onClick.AddListener(() => OnJoinGame.Invoke(match));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 当获取房间列表时,更新UI
 /// </summary>
 /// <param name="matches"></param>
 public void OnGotMatches(List <MatchDesc> matches)
 {
     for (byte i = 0; i < matches.Count; i++)
     {
         MatchDesc match = matches[i];
         m_roomButtons[i].name.text = match.name;
         m_roomButtons[i].size.text = match.currentSize + "/3";
         //是否超出人数
         m_roomButtons[i].button.interactable = match.currentSize < 3;
     }
 }
Ejemplo n.º 7
0
        public void OnListRoomsCallback(ListMatchResponse aResponse)
        {
            //Debug.Log(aResponse.ToString());
            m_roomList = new List <MatchDesc>();
            m_roomList.Clear();
            foreach (MatchDesc match in aResponse.matches)
            {
                m_roomList.Add(match);
            }

            if (m_roomList != null)
            {
                for (int i = 0; i < m_roomList.Count; i++)
                {
                    GameObject roomButton = (GameObject)Instantiate(m_baseButton, m_baseButton.transform.position, m_baseButton.transform.rotation);
                    roomButton.SetActive(true);
                    roomButton.transform.SetParent(m_baseButton.transform.parent);
                    Vector3 position = roomButton.GetComponent <RectTransform>().position;
                    position.y -= i * 30;
                    roomButton.GetComponent <RectTransform>().position = position;
                    MatchDesc roomInfo = m_roomList[i];
                    roomButton.GetComponent <Button>().onClick.AddListener(() => { JoinRoom(roomInfo); });
                    roomButton.transform.GetChild(0).GetComponent <Text>().text = m_roomList[i].name;

                    roomButton.transform.GetChild(1).GetComponent <Text>().text = m_roomList[i].currentSize + "/" + m_roomList[i].maxSize;
                    m_roomButtons.Add(new RoomButton(roomInfo, roomButton.GetComponent <Button>()));
                }

                if (m_roomList.Count > 0)
                {
                    m_refreshLabel.GetComponent <Text>().text = "";
                }
                else
                {
                    m_refreshLabel.GetComponent <Text>().text = "No rooms found...";
                }

                if (m_roomList.Count < 9)
                {
                    m_roomsScrollBar.SetActive(false);
                }
                else
                {
                    m_roomsScrollBar.SetActive(true);
                }
            }
            else
            {
                m_refreshLabel.GetComponent <Text>().text = "No rooms found...";
                m_roomsScrollBar.SetActive(false);
            }
        }
Ejemplo n.º 8
0
        public void Populate(MatchDesc match, LobbyManager lobbyManager, Color c)
        {
            serverInfoText.text = match.name;

            slotInfo.text = match.currentSize.ToString() + "/" + match.maxSize.ToString();;

            NetworkID networkID = match.networkId;

            joinButton.onClick.RemoveAllListeners();
            joinButton.onClick.AddListener(() => { JoinMatch(networkID, lobbyManager); });

            GetComponent <Image>().color = c;
        }
Ejemplo n.º 9
0
    public void SetMatchDescription(MatchDesc matchDesc)
    {
        matchName = matchDesc.name;

        matchPopulationText.text = matchDesc.currentSize.ToString() + "/" + matchDesc.maxSize.ToString();

        if (matchDesc.currentSize == matchDesc.maxSize)
        {
            matchStatusText.text = "Full";
        }

        //matchIDText.text = networkID.ToString();
        matchNameText.text = matchName;
    }
Ejemplo n.º 10
0
 public override void OnMatchList(ListMatchResponse matchList)
 {
     base.OnMatchList(matchList);
     if (matchList.matches.Count <= 0)
     {
         //create matchs
         matchMaker.CreateMatch("server", 2u, false, "", OnMatchCreate);
     }
     else
     {
         //connect
         MatchDesc match = matchList.matches[0];
         matchMaker.JoinMatch(match.networkId, "", OnMatchJoined);
     }
 }
Ejemplo n.º 11
0
        public void JoinMatch(MatchDesc match)
        {
            StartMatchMaker();

            matchMaker.JoinMatch(match.networkId, string.Empty, matchInfo =>
            {
                OnMatchJoined(matchInfo);

                if (matchInfo.success)
                {
                    m_MatchOwnerId = (uint)match.hostNodeId;

                    minPlayers = match.maxSize;

                    OnJoinMatch.Invoke();
                }
            });
        }
Ejemplo n.º 12
0
    public void Populate(MatchDesc matchDesc)
    {
        ClearGameList();

        NetworkID  networkID = matchDesc.networkId;
        GameObject grid      = pool.GetUnit();

        grid.SetActive(true);
        grid.transform.SetParent(container);
        grid.transform.localScale = new Vector3(1, 1, 1);
        grid.GetComponent <MatchGrid>().SetMatchDescription(matchDesc);

        if (matchDesc.currentSize < matchDesc.maxSize)
        {
            var button = grid.GetComponent <Button>();
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() => { JoinMatch(networkID); });
        }
    }
Ejemplo n.º 13
0
    void Update()
    {
        if (matchList.Count > 0)
        {
            GameObject.Find("Content").GetComponent <RectTransform>().sizeDelta = new Vector2(0, (30 * matchList.Count) + 15);

            for (int i = 0; i < matchDisplays.Count; i++)
            {
                string name           = matchList[i].name;
                bool   hasPassword    = matchList[i].isPrivate;
                int    currentPlayers = matchList[i].currentSize;
                int    maxPlayers     = matchList[i].maxSize - 1;
                matchDisplays[i].GetComponent <ServerInfo>().UpdateInfo(name, hasPassword, currentPlayers, maxPlayers);
            }
        }

        if (togglegroup.AnyTogglesOn())
        {
            Toggle[] toggles = GetComponentsInChildren <Toggle>();

            foreach (Toggle t in toggles)
            {
                if (t.isOn)
                {
                    ConnectGame = t.gameObject.GetComponent <ServerInfo>().GetMatchInfo();
                }
            }
        }
        else
        {
            ConnectGame = null;
        }

        if (ConnectGame == null)
        {
            ConnectButton.interactable = false;
        }
        else
        {
            ConnectButton.interactable = true;
        }
    }
Ejemplo n.º 14
0
        public void JoinRoom(MatchDesc aRoomInfo)
        {
            GameObject.Find("Version Text").transform.SetParent(null);
            GameObject.Find("FullScreen").transform.SetParent(null);
            int minLevel    = 0;
            int maxLevel    = 50;
            int playerLevel = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetStats()[0].m_statValue;

            if (playerLevel < minLevel || playerLevel > maxLevel)
            {
                GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You're not in that room's\nlevel range!");
                GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform);
                GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform);
            }
            else
            {
                m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM;
                try
                {
                    BombersNetworkManager.singleton.matchMaker.JoinMatch(aRoomInfo.networkId, "", OnMatchJoined);
                }
                catch (ArgumentException e)
                {
                    m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
                    GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform);
                    GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform);
                    GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You just left that room!");
                    Debug.Log("caught ArgumentException " + e);
                }
                catch (Exception e)
                {
                    m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
                    GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform);
                    GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform);
                    GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Error joining room! Try restarting.");
                    Debug.Log("caught Exception " + e);
                }
            }
        }
Ejemplo n.º 15
0
 void JoinMatch(MatchDesc match)
 {
     matchName = match.name;
     matchSize = (uint)match.currentSize;
     matchMaker.JoinMatch(match.networkId, "", OnMatchJoined);
 }
Ejemplo n.º 16
0
 private void ShowControls()
 {
     this.m_ShowControls = EditorGUILayout.Foldout(this.m_ShowControls, this.m_ShowControlsLabel);
     if (!this.m_ShowControls)
     {
         return;
     }
     if (!string.IsNullOrEmpty(NetworkManager.networkSceneName))
     {
         EditorGUILayout.ObjectField("Current Scene:", NetworkManagerHUDEditor.GetSceneObject(NetworkManager.networkSceneName), typeof(Object), true, new GUILayoutOption[0]);
     }
     EditorGUILayout.Separator();
     if (!NetworkClient.active && !NetworkServer.active && (Object)this.m_Manager.matchMaker == (Object)null)
     {
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Toggle(false, "LAN Host", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartHost();
         }
         if (GUILayout.Toggle(false, "LAN Server", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartServer();
         }
         if (GUILayout.Toggle(false, "LAN Client", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartClient();
         }
         if (GUILayout.Toggle(false, "Start Matchmaker", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartMatchMaker();
             this.m_ShowMatchMaker = true;
         }
         EditorGUILayout.EndHorizontal();
     }
     if (NetworkClient.active && !ClientScene.ready && GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Client Ready"))
     {
         ClientScene.Ready(this.m_Manager.client.connection);
         if (ClientScene.localPlayers.Count == 0)
         {
             ClientScene.AddPlayer((short)0);
         }
     }
     if ((NetworkServer.active || NetworkClient.active) && GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Stop"))
     {
         this.m_Manager.StopServer();
         this.m_Manager.StopClient();
     }
     if (!NetworkServer.active && !NetworkClient.active)
     {
         EditorGUILayout.Separator();
         if ((Object)this.m_Manager.matchMaker != (Object)null && this.m_Manager.matchInfo == null)
         {
             if (this.m_Manager.matches == null)
             {
                 EditorGUILayout.BeginHorizontal();
                 if (GUILayout.Toggle(false, "Create Internet Match", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.matchMaker.CreateMatch(this.m_Manager.matchName, this.m_Manager.matchSize, true, string.Empty, new NetworkMatch.ResponseDelegate <CreateMatchResponse>(this.m_Manager.OnMatchCreate));
                 }
                 if (GUILayout.Toggle(false, "Find Internet Match", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.matchMaker.ListMatches(0, 20, string.Empty, new NetworkMatch.ResponseDelegate <ListMatchResponse>(this.m_Manager.OnMatchList));
                 }
                 if (GUILayout.Toggle(false, "Stop MatchMaker", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.StopMatchMaker();
                 }
                 EditorGUILayout.EndHorizontal();
                 this.m_Manager.matchName = EditorGUILayout.TextField("Room Name:", this.m_Manager.matchName, new GUILayoutOption[0]);
                 this.m_Manager.matchSize = (uint)EditorGUILayout.IntField("Room Size:", (int)this.m_Manager.matchSize, new GUILayoutOption[0]);
                 EditorGUILayout.BeginHorizontal();
                 if (GUILayout.Toggle(false, "Use Local Relay", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.SetMatchHost("localhost", 1337, false);
                 }
                 if (GUILayout.Toggle(false, "Use Internet Relay", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.SetMatchHost("mm.unet.unity3d.com", 80, false);
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Separator();
             }
             else
             {
                 using (List <MatchDesc> .Enumerator enumerator = this.m_Manager.matches.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         MatchDesc current = enumerator.Current;
                         if (GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Join Match:" + current.name))
                         {
                             this.m_Manager.matchName = current.name;
                             this.m_Manager.matchSize = (uint)current.currentSize;
                             this.m_Manager.matchMaker.JoinMatch(current.networkId, string.Empty, new NetworkMatch.ResponseDelegate <JoinMatchResponse>(this.m_Manager.OnMatchJoined));
                         }
                     }
                 }
                 if (GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Stop MatchMaker"))
                 {
                     this.m_Manager.StopMatchMaker();
                 }
             }
         }
     }
     EditorGUILayout.Separator();
 }
Ejemplo n.º 17
0
    public override void OnMatchList(ListMatchResponse matchList)
    {
        bool      success    = matchList.success;
        int       matchCount = matchList.matches.Count;
        MatchDesc match      = null;
#endif
        if (!success)
        {
            Debug.Log("Failed to retrieve match list");
            return;
        }

        if (matchCount == 0)
        {
            Debug.Log("Match list is empty");
            return;
        }

        if (natHelper.guid != 0)
        {
            // If we have a guid we can use it to make sure we don't
            // try and join our own old match. This can happen when quickly switching
            // from hosting to joining because old matches are not cleaned up immediately
            // and there's no way to be notified when they are cleaned up
#if UNITY_5_5
            foreach (MatchInfoSnapshot m in matchList)
#else
            foreach (MatchDesc m in matchList.matches)
#endif
            {
                string[] parts = m.name.Split(':');
                ulong    hostGUID;
                ulong.TryParse(parts[parts.Length - 1], out hostGUID);
                if (hostGUID == natHelper.guid)
                {
                    Debug.Log("Not joining old match");
                }
                else
                {
                    match = m;
                    break;
                }
            }
        }
        else
        {
#if UNITY_5_5
            match = matchList[0];
#else
            match = matchList.matches[0];
#endif
        }

        if (match == null)
        {
            Debug.Log("Match list is empty");
            return;
        }

        Debug.Log("Found a match, joining");

        matchID = match.networkId;
        StartClientAll(match);
    }
Ejemplo n.º 18
0
 public void JoinRoom(MatchDesc _match)
 {
     NetworkManager.singleton.matchMaker.JoinMatch(_match.networkId, "", NetworkManager.singleton.OnMatchJoined);
     ClearRoomList();
     status.text = "Joining Room";
 }
Ejemplo n.º 19
0
    private void OnGUI()
    {
        if (!this.showGUI)
        {
            return;
        }
        zoomRatio = Screen.height / 400f;
        GUI.skin.label.fontSize     = (int)zoomRatio * 15;
        GUI.skin.button.fontSize    = (int)zoomRatio * 15;
        GUI.skin.textField.fontSize = (int)zoomRatio * 15;
        //GUI.skin = customSkin;
        int num1 = 10 + this.offsetX;
        int num2 = 40 + this.offsetY;
        int num3 = 24;

        if (!NetworkClient.active && !NetworkServer.active &&
            (UnityEngine.Object) this.manager.matchMaker == (UnityEngine.Object)null)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           string.Format("LAN Host({0})", Network.player.ipAddress)))
            {
                this.manager.StartHost();
            }
            int num4 = num2 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 105f * zoomRatio, 20f * zoomRatio),
                           "LAN Client(C)"))
            {
                this.manager.StartClient();
                (manager as UManager).SavedIP = manager.networkAddress;
            }
            this.manager.networkAddress =
                GUI.TextField(
                    new Rect((float)(num1 + 100) * zoomRatio, (float)num4 * zoomRatio, 95f * zoomRatio, 20f * zoomRatio),
                    this.manager.networkAddress);
            int num5 = num4 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "LAN Server Only(S)"))
            {
                this.manager.StartServer();
            }
            num2 = num5 + num3;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio),
                          "Server: port=" + (object)this.manager.networkPort);
                num2 += num3;
            }
            if (NetworkClient.active)
            {
                Rect     position = new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio);
                object[] objArray = new object[4];
                int      index1   = 0;
                string   str1     = "Client: address=";
                objArray[index1] = (object)str1;
                int    index2         = 1;
                string networkAddress = this.manager.networkAddress;
                objArray[index2] = (object)networkAddress;
                int    index3 = 2;
                string str2   = " port=";
                objArray[index3] = (object)str2;
                int index4 = 3;
                // ISSUE: variable of a boxed type
                int local = this.manager.networkPort;
                objArray[index4] = (object)local;
                string text = string.Concat(objArray);
                GUI.Label(position, text);
                num2 += num3;
            }
        }
        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Client Ready"))
            {
                ClientScene.Ready(this.manager.client.connection);
                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer((short)0);
                }
            }
            num2 += num3;
        }
        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Stop (X)"))
            {
                this.manager.StopHost();
            }
            num2 += num3;
        }
        if (NetworkServer.active || NetworkClient.active)
        {
            return;
        }
        int num6 = num2 + 10;
        int num7;

        if ((UnityEngine.Object) this.manager.matchMaker == (UnityEngine.Object)null)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Enable Match Maker (M)"))
            {
                this.manager.StartMatchMaker();
            }
            num7 = num6 + num3;
        }
        else
        {
            if (this.manager.matchInfo == null)
            {
                if (this.manager.matches == null)
                {
                    if (
                        GUI.Button(
                            new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                            "Create Internet Match"))
                    {
                        this.manager.matchMaker.CreateMatch(this.manager.matchName, this.manager.matchSize, true,
                                                            string.Empty,
                                                            new NetworkMatch.ResponseDelegate <CreateMatchResponse>(this.manager.OnMatchCreate));
                    }
                    int num4 = num6 + num3;
                    GUI.Label(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                              "Room Name:");
                    this.manager.matchName =
                        GUI.TextField(
                            new Rect((float)(num1 + 100) * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio,
                                     20f * zoomRatio), this.manager.matchName);
                    int num5 = num4 + num3 + 10;
                    if (
                        GUI.Button(
                            new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                            "Find Internet Match"))
                    {
                        this.manager.matchMaker.ListMatches(0, 20, string.Empty,
                                                            new NetworkMatch.ResponseDelegate <ListMatchResponse>(this.manager.OnMatchList));
                    }
                    num6 = num5 + num3;
                }
                else
                {
                    using (List <MatchDesc> .Enumerator enumerator = this.manager.matches.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            MatchDesc current = enumerator.Current;
                            if (
                                GUI.Button(
                                    new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio,
                                             20f * zoomRatio), "Join Match:" + current.name))
                            {
                                this.manager.matchName = current.name;
                                this.manager.matchSize = (uint)current.currentSize;
                                this.manager.matchMaker.JoinMatch(current.networkId, string.Empty,
                                                                  new NetworkMatch.ResponseDelegate <JoinMatchResponse>(this.manager.OnMatchJoined));
                            }
                            num6 += num3;
                        }
                    }
                }
            }
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Change MM server"))
            {
                this.showServer = !this.showServer;
            }
            if (this.showServer)
            {
                int num4 = num6 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Local"))
                {
                    this.manager.SetMatchHost("localhost", 1337, false);
                    this.showServer = false;
                }
                int num5 = num4 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Internet"))
                {
                    this.manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                    this.showServer = false;
                }
                num6 = num5 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Staging"))
                {
                    this.manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                    this.showServer = false;
                }
            }
            int num8 = num6 + num3;
            GUI.Label(new Rect((float)num1 * zoomRatio, (float)num8 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio),
                      "MM Uri: " + (object)this.manager.matchMaker.baseUri);
            int num9 = num8 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num9 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Disable Match Maker"))
            {
                this.manager.StopMatchMaker();
            }
            num7 = num9 + num3;
        }
    }
Ejemplo n.º 20
0
 public RoomButton(MatchDesc aRoom, Button abutton)
 {
     m_room   = aRoom;
     m_button = abutton;
 }
Ejemplo n.º 21
0
        private void OnGUI()
        {
            if (!this.showGUI)
            {
                return;
            }
            int  num1 = 10 + this.offsetX;
            int  num2 = 40 + this.offsetY;
            bool flag = this.manager.client == null || this.manager.client.connection == null || this.manager.client.connection.connectionId == -1;

            if (!this.manager.IsClientConnected() && !NetworkServer.active && (Object)this.manager.matchMaker == (Object)null)
            {
                if (flag)
                {
                    if (Application.platform != RuntimePlatform.WebGLPlayer)
                    {
                        if (GUI.Button(new Rect((float)num1, (float)num2, 200f, 20f), "LAN Host(H)"))
                        {
                            this.manager.StartHost();
                        }
                        num2 += 24;
                    }
                    if (GUI.Button(new Rect((float)num1, (float)num2, 105f, 20f), "LAN Client(C)"))
                    {
                        this.manager.StartClient();
                    }
                    this.manager.networkAddress = GUI.TextField(new Rect((float)(num1 + 100), (float)num2, 95f, 20f), this.manager.networkAddress);
                    int num3 = num2 + 24;
                    if (Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        GUI.Box(new Rect((float)num1, (float)num3, 200f, 25f), "(  WebGL cannot be server  )");
                        num2 = num3 + 24;
                    }
                    else
                    {
                        if (GUI.Button(new Rect((float)num1, (float)num3, 200f, 20f), "LAN Server Only(S)"))
                        {
                            this.manager.StartServer();
                        }
                        num2 = num3 + 24;
                    }
                }
                else
                {
                    GUI.Label(new Rect((float)num1, (float)num2, 200f, 20f), "Connecting to " + this.manager.networkAddress + ":" + (object)this.manager.networkPort + "..");
                    num2 += 24;
                    if (GUI.Button(new Rect((float)num1, (float)num2, 200f, 20f), "Cancel Connection Attempt"))
                    {
                        this.manager.StopClient();
                    }
                }
            }
            else
            {
                if (NetworkServer.active)
                {
                    string text = "Server: port=" + (object)this.manager.networkPort;
                    if (this.manager.useWebSockets)
                    {
                        text += " (Using WebSockets)";
                    }
                    GUI.Label(new Rect((float)num1, (float)num2, 300f, 20f), text);
                    num2 += 24;
                }
                if (this.manager.IsClientConnected())
                {
                    GUI.Label(new Rect((float)num1, (float)num2, 300f, 20f), "Client: address=" + this.manager.networkAddress + " port=" + (object)this.manager.networkPort);
                    num2 += 24;
                }
            }
            if (this.manager.IsClientConnected() && !ClientScene.ready)
            {
                if (GUI.Button(new Rect((float)num1, (float)num2, 200f, 20f), "Client Ready"))
                {
                    ClientScene.Ready(this.manager.client.connection);
                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer((short)0);
                    }
                }
                num2 += 24;
            }
            if (NetworkServer.active || this.manager.IsClientConnected())
            {
                if (GUI.Button(new Rect((float)num1, (float)num2, 200f, 20f), "Stop (X)"))
                {
                    this.manager.StopHost();
                }
                num2 += 24;
            }
            if (NetworkServer.active || this.manager.IsClientConnected() || !flag)
            {
                return;
            }
            int num4 = num2 + 10;
            int num5;

            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                GUI.Box(new Rect((float)(num1 - 5), (float)num4, 220f, 25f), "(WebGL cannot use Match Maker)");
            }
            else if ((Object)this.manager.matchMaker == (Object)null)
            {
                if (GUI.Button(new Rect((float)num1, (float)num4, 200f, 20f), "Enable Match Maker (M)"))
                {
                    this.manager.StartMatchMaker();
                }
                num5 = num4 + 24;
            }
            else
            {
                if (this.manager.matchInfo == null)
                {
                    if (this.manager.matches == null)
                    {
                        if (GUI.Button(new Rect((float)num1, (float)num4, 200f, 20f), "Create Internet Match"))
                        {
                            this.manager.matchMaker.CreateMatch(this.manager.matchName, this.manager.matchSize, true, string.Empty, new NetworkMatch.ResponseDelegate <CreateMatchResponse>(this.manager.OnMatchCreate));
                        }
                        int num3 = num4 + 24;
                        GUI.Label(new Rect((float)num1, (float)num3, 100f, 20f), "Room Name:");
                        this.manager.matchName = GUI.TextField(new Rect((float)(num1 + 100), (float)num3, 100f, 20f), this.manager.matchName);
                        int num6 = num3 + 24 + 10;
                        if (GUI.Button(new Rect((float)num1, (float)num6, 200f, 20f), "Find Internet Match"))
                        {
                            this.manager.matchMaker.ListMatches(0, 20, string.Empty, new NetworkMatch.ResponseDelegate <ListMatchResponse>(this.manager.OnMatchList));
                        }
                        num4 = num6 + 24;
                    }
                    else
                    {
                        using (List <MatchDesc> .Enumerator enumerator = this.manager.matches.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                MatchDesc current = enumerator.Current;
                                if (GUI.Button(new Rect((float)num1, (float)num4, 200f, 20f), "Join Match:" + current.name))
                                {
                                    this.manager.matchName = current.name;
                                    this.manager.matchSize = (uint)current.currentSize;
                                    this.manager.matchMaker.JoinMatch(current.networkId, string.Empty, new NetworkMatch.ResponseDelegate <JoinMatchResponse>(this.manager.OnMatchJoined));
                                }
                                num4 += 24;
                            }
                        }
                    }
                }
                if (GUI.Button(new Rect((float)num1, (float)num4, 200f, 20f), "Change MM server"))
                {
                    this.m_ShowServer = !this.m_ShowServer;
                }
                if (this.m_ShowServer)
                {
                    int num3 = num4 + 24;
                    if (GUI.Button(new Rect((float)num1, (float)num3, 100f, 20f), "Local"))
                    {
                        this.manager.SetMatchHost("localhost", 1337, false);
                        this.m_ShowServer = false;
                    }
                    int num6 = num3 + 24;
                    if (GUI.Button(new Rect((float)num1, (float)num6, 100f, 20f), "Internet"))
                    {
                        this.manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                        this.m_ShowServer = false;
                    }
                    num4 = num6 + 24;
                    if (GUI.Button(new Rect((float)num1, (float)num4, 100f, 20f), "Staging"))
                    {
                        this.manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                        this.m_ShowServer = false;
                    }
                }
                int num7 = num4 + 24;
                GUI.Label(new Rect((float)num1, (float)num7, 300f, 20f), "MM Uri: " + (object)this.manager.matchMaker.baseUri);
                int num8 = num7 + 24;
                if (GUI.Button(new Rect((float)num1, (float)num8, 200f, 20f), "Disable Match Maker"))
                {
                    this.manager.StopMatchMaker();
                }
                num5 = num8 + 24;
            }
        }
Ejemplo n.º 22
0
 public void setData(MatchDesc d)
 {
     listData = d;
 }
Ejemplo n.º 23
0
 public void SetMatchInfo(MatchDesc m)
 {
     matchInfo = m;
 }
Ejemplo n.º 24
0
 public void buttonClicked(MatchDesc desc)
 {
     networkMatch.JoinMatch(desc.networkId, "", OnMatchJoined);
 }