Example #1
0
    public virtual void roomListCallback(ListMatchResponse resp)
    {
        if (!doRefresh)
        {
            return; //refreshes halted
        }
        Debug.Log("Found " + resp.matches.Count + " rooms");
        matches = resp.matches;
        //cleanup existing list
        foreach (Transform child in roomListParent.transform)
        {
            Destroy(child.gameObject);
        }
        foreach (MatchDesc d in resp.matches)
        {
            GameObject go = GameObject.Instantiate(roomTextPrefab);
            go.GetComponentInChildren <Text>().text = d.name + "\t(" + d.currentSize + "/" + d.maxSize + ")"; //may be sub-sub component
            go.transform.SetParent(roomListParent.transform, false);                                          //Just parent the object to the panel and let the panel lay it out

            //setup data for the selection obj
            RoomData rd = go.AddComponent <RoomData>();
            rd.setReceiver(joinRoomInput);
            rd.setData(d);
        }
        OnMatchList(resp); //maybe unnecessary
    }
Example #2
0
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         m_MatchList = matchListResponse.matches;
     }
 }
Example #3
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);
    }
Example #4
0
 private void OnInternetMatchList(ListMatchResponse matchListResponse)
 {
     ClearMatchList();
     if (matchListResponse.success)
     {
         state.text = "";
         if (matchListResponse.matches.Count != 0)
         {
             foreach (MatchDesc match in matchListResponse.matches)
             {
                 GameObject obj  = Instantiate(Prefab);
                 RoomScript room = obj.GetComponent <RoomScript>();
                 if (room != null)
                 {
                     room.match  = match;
                     room.RoomUI = GameObject.Find("RoomsUI");
                     room.Setup();
                 }
                 obj.transform.parent = Content.transform;
                 matchList.Add(obj);
             }
         }
         else
         {
             state.text = "Sorry, No Rooms :(";
         }
     }
     else
     {
         state.text = "Not Connect :(";
     }
 }
        public void OnGUIMatchList(ListMatchResponse response)
        {
            if (response.matches.Count == 0)
            {
                if (currentPage == 0)
                {
                    noServerFound.SetActive(true);
                }

                currentPage = previousPage;

                return;
            }

            noServerFound.SetActive(false);
            foreach (Transform t in serverListRect)
            {
                Destroy(t.gameObject);
            }

            for (int i = 0; i < response.matches.Count; ++i)
            {
                GameObject o = Instantiate(serverEntryPrefab) as GameObject;

                o.GetComponent <LobbyServerEntry>().Populate(response.matches[i], lobbyManager, (i % 2 == 0) ? OddServerColor : EvenServerColor);

                o.transform.SetParent(serverListRect, false);
            }
        }
Example #6
0
    private void _OnListMatch (ListMatchResponse response)
    {
        m_waitingPanel.SetActive(false);
        if (response.success)
        {
            m_matchUI.GetComponentInChildren<CanvasGroup>().interactable = true;
            matches = response.matches;

            for (byte i = 0; i < matches.Count; i++)
            {
                Text[] texts = roomButtons[i].GetComponentsInChildren<Text>();
                //房间名称
                texts[0].text = matches[i].name;
                //当前人数
                texts[1].text = matches[i].currentSize + "/" + m_roomSize;

                //是否超出人数
                roomButtons[i].interactable = matches[i].currentSize < m_roomSize;
            }

            for (byte i = (byte)matches.Count; i < m_resultPageSize; i++)
            {
                Text[] texts = roomButtons[i].GetComponentsInChildren<Text>();
                texts[0].text = "";
                texts[1].text = "*/*";
                roomButtons[i].interactable = false;
            }

        }
        else
        {
            m_waitingPanel.SetActive(false);
            _Error("FAILED TO LIST ROOMS");
        }
    }
Example #7
0
    public void OnMatchList(ListMatchResponse matchList)
    {
        status.text = "";

        if (matchList == null)
        {
            status.text = "No rooms found";
            return;
        }

        foreach (MatchDesc match in matchList.matches)
        {
            GameObject _roomListItemGO = Instantiate(roomListItemPrefab);
            _roomListItemGO.transform.SetParent(roomListParent);

            RoomListItem _roomListItem = _roomListItemGO.GetComponent <RoomListItem>();
            if (_roomListItem != null)
            {
                _roomListItem.Setup(match, JoinRoom);
            }

            roomList.Add(_roomListItemGO);
        }

        if (roomList.Count == 0)
        {
            status.text = "0 rooms";
        }
    }
Example #8
0
    public void Show(ListMatchResponse matchList)
    {
        base.Show();

        Test.s_Singleton.matches = matchList.matches;

        var hooks = canvas.GetComponent <JoinMatchHooks>();

        if (hooks == null)
        {
            return;
        }

        hooks.OnReturnToMMHook = OnGUIReturnToMatchMaker;
        hooks.OnGameHook       = OnGUIJoin;

        for (int i = 0; i < 6; i++)
        {
            hooks.SetMatchName(i, "");
        }

        for (int i = 0; i < matchList.matches.Count; i++)
        {
            var match = matchList.matches[i];
            hooks.SetMatchName(i, match.name);
        }

        EventSystem.current.SetSelectedGameObject(hooks.firstButton.gameObject);
    }
Example #9
0
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         networkMatch.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoined);
     }
 }
Example #10
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);
    }
Example #11
0
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         Debug.Log("no match found");
         networkMatch.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoined);
     }
 }
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         matchsFound = true;
         MyNetworkManager.singleton.OnMatchList(matchListResponse);
     }
 }
Example #13
0
 public virtual void OnMatchList(ListMatchResponse matchList)
 {
     if (LogFilter.logDebug)
     {
         Debug.Log("NetworkManager OnMatchList ");
     }
     matches = matchList.matches;
 }
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     Debug.Log("OnMatchList Entered");
     if (matchListResponse.success && matchListResponse.matches != null)
     {
         Debug.Log("matchListResponse.success && matchListResponse.matches != null statement true");
         networkMatch.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoined);
     }
 }
Example #15
0
        public void OnMatchList(ListMatchResponse response)
        {
            var matchList = response.matches;
#endif
            results.Resize(matchList.Count);
            for (int i = 0; i < matchList.Count; i++)
            {
                results.Set(i, new MatchInfoObject(matchList[i]));
            }
        }
Example #16
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);
            }
        }
Example #17
0
 private void onMatchList(ListMatchResponse listResponse)
 {
     if (listResponse.success && listResponse.matches != null && listResponse.matches.Count == 1)
     {
         JoinMatch(listResponse.matches[0].networkId, "", onMatchJoined);
     }
     else
     {
         joinButton.gameObject.SetActive(true);
         hostButton.gameObject.SetActive(true);
         Debug.LogError("Failed to join match");
     }
 }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="response"></param>
 private void _OnListMatch(ListMatchResponse response)
 {
     MatchUI.instance.StopWait();
     if (response.success)
     {
         matches = response.matches;
         //填充房间列表UI
         MatchUI.instance.OnGotMatches(response.matches);
     }
     else
     {
     }
 }
Example #19
0
    public override void OnMatchList(ListMatchResponse matchList)
    {
        base.OnMatchList(matchList);

        // auto join room if found
        foreach (MatchDesc match in matchList.matches)
        {
            if (match.name == RoomName)
            {
                JoinMatch(match);
                return;
            }
        }
    }
Example #20
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);
     }
 }
Example #21
0
 public void OnMatchList(ListMatchResponse matchListResponse)
 {
     if (matchListResponse.success && matchListResponse.matches.Count > 0)
     {
         matchList = matchListResponse.matches;
         PopulateServerList();
         Debug.Log("MATCHES FOUND");
         GameObject.Find("NoMatchesText").GetComponent <Text>().enabled = false;
     }
     else
     {
         Debug.Log("NO MATCHES FOUND");
         GameObject.Find("NoMatchesText").GetComponent <Text>().enabled = true;
     }
 }
Example #22
0
    public void OnMatchList(ListMatchResponse matchList)
    {
        if (matchList == null)
        {
            Debug.Log("null Match List returned from server");
            return;
        }

        roomList = new List <MatchDesc>();
        roomList.Clear();
        foreach (MatchDesc match in matchList.matches)
        {
            roomList.Add(match);
        }
    }
        private void OnMatchList(ListMatchResponse response)
        {
            if (response.success)
            {
                this.matches      = response.matches;
                this.errorMessage = "";
            }
            else
            {
                this.matches      = null;
                this.errorMessage = "Error getting match list";
            }

            this.listingMatches       = false;
            this.lastMatchListingTime = Time.time;
        }
Example #24
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");
        }
    }
Example #25
0
    private void OnMatchList(ListMatchResponse response)
    {
        if (response.matches.Count == 0)
        {
            gameListMenu.ClearGameList();
        }

        for (int i = 0; i < response.matches.Count; i++)
        {
            /*if(response.matches[0].hostNodeId == (NodeID)lobbyManager.currentNodeID)
             * {
             *  Debug.Log("Host is me");
             *  continue;
             * }*/
            gameListMenu.Populate(response.matches[i]);
        }
    }
Example #26
0
    void OnGUIMatchList(ListMatchResponse matchList)
    {
        Test.s_Singleton.connectingCanvas.Hide();

        if (matchList.success)
        {
            Test.s_Singleton.joinMatchCanvas.Show(matchList);
        }
        else if (matchList.matches.Count == 0)
        {
            Debug.LogWarning("No Matched found.");
            Show();
        }
        else
        {
            Debug.LogError("Error finding matches");
            Show();
        }
    }
Example #27
0
    public void OnMatchList(ListMatchResponse matchList)
    {
        status.text = "";

        if (matchList = null)
        {
            status.text = "Couldn't get room list.";
            return;
        }

        ClearRoomList();
        foreach (MatchDesc match in matchList.matches)
        {
            GameObject _roomListItemGo = Instantiate(roomListItemPrefab);
            _roomListItemGo.transform.SetParent(roomListParent);
            //Have a component sit on the gameobject that will
            //take care of setting up the name/amount of users
            //as well as setting up a callback function that will join the game.
        }
    }
Example #28
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));
            }
        }
    }
    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);
    }
Example #30
0
 void OnMatchListAndJoin(ListMatchResponse matchList)
 {
     manager.matches = matchList.matches;
     Join();
 }