public void Setup(MatchInfoSnapshot _room, JoinRoomDelegate _joinRoomCallback)
    {
        room             = _room;
        joinRoomCallback = _joinRoomCallback;

        roomNameText.text = room.name + " (" + room.currentSize + "/" + room.maxSize + ")";
    }
Ejemplo n.º 2
0
 public void JoinRoom(MatchInfoSnapshot match)
 {
     networkManager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     ClearRoomList();
     statusText.text = "Joining...";
     StartCoroutine(ConnectionTimeOut());
 }
Ejemplo n.º 3
0
 public void JoinRoom(MatchInfoSnapshot _match)
 {
     networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     ClearRoomList();
     status.text = "Joining...";
     networkUI.SetActive(false);
 }
Ejemplo n.º 4
0
    private void OnInternetMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
    {
        if (success)
        {
            if (matches.Count != 0)
            {
                Debug.Log("Maths count = " + matches.Count);

                for (int i = matches.Count - 1; i >= 0; i++)
                {
                    MatchInfoSnapshot info = matches[i];
                    if (info.currentSize > 0 && info.currentSize < info.maxSize)
                    {
                        NetworkManager.singleton.matchMaker.JoinMatch(matches[matches.Count - 1].networkId, "", "", "", 0, 0, OnJoinInternetMatch);
                        return;
                    }
                }

                CreateInternetMatch(m_currentRoomeName);
            }
            else
            {
                CreateInternetMatch(m_currentRoomeName);
            }
        }
        else
        {
            EnableButtons(true);
            Debug.LogError("Couldn't connect to match maker : " + extendedInfo);
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Setup the specified info.
    /// </summary>
    /// <param name="info">Info.</param>
    public void Setup(MatchInfoSnapshot info)
    {
        matchInfo = info;

        matchName.text     = info.name;
        onlinePlayers.text = info.currentSize + "/" + info.maxSize;
    }
Ejemplo n.º 6
0
    //this method is called when a list of matches is returned
    private void OnInternetMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
    {
        if (success)
        {
            if (matches.Count != 0)
            {
                //Debug.Log("A list of matches was returned");

                //join the last server (just in case there are two...)
                NetworkManager
                .singleton
                .matchMaker
                .JoinMatch(matches[matches.Count - 1]
                           .networkId,
                           "", "", "", 0, 0,
                           OnJoinInternetMatch);

                matchInfoSnapshot = matches[matches.Count - 1];
            }
            else
            {
                Debug.Log("No matches in requested room!");
                Debug.Log("Creating new room...");

                CreateInternetMatch(matchName);
            }
        }
        else
        {
            Debug.LogError("Couldn't connect to match maker");
            StartCoroutine("RetryJoinMatch");
        }
    }
Ejemplo n.º 7
0
    public void MatchListItemSelected(bool value)
    {
        // This is inconvenient, can't pass WHICH Toggle was selected)... but Toggle Group is set so only one will be active
        Toggle selectedToggle = null;

        foreach (Toggle toggle in netScrollViewContent.GetComponent <ToggleGroup>().ActiveToggles())
        {
            selectedToggle = toggle;
        }

        if (value)
        {
            currentSelectedMatchSnapshot = selectedToggle.GetComponent <NetMatchListItem>().matchInfoSnapshot;
            netJoinButton.interactable   = true;
        }
        else
        {
            if (selectedToggle == null || EventSystem.current.currentSelectedGameObject != selectedToggle.gameObject)
            {
                // Same entry was selected twice (turns it off), so turn off EventSystem UI selection because it looks bad
                netJoinButton.interactable   = false;
                currentSelectedMatchSnapshot = null;
                EventSystem.current.SetSelectedGameObject(null);
            }
        }
    }
Ejemplo n.º 8
0
    private void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> response)
    {
        networkManager.OnMatchList(success, extendedInfo, response);

        int largest = Mathf.Max(response.Count, listItems.Count);

        int activeItems = 0;

        for (int i = 0; i < largest; i++)
        {
            if (response.Count > i)
            {
                MatchInfoSnapshot item = response[i];

                if (listItems.Count <= i)
                {
                    listItems.Add(MakeListItem(i));
                }

                SetListItemValues(item, i);
                activeItems++;
            }
            else if (listItems.Count > i)
            {
                listItems[i].SetActive(false);
            }
        }


        Vector2 sizeDelta = scrollContent.sizeDelta;

        sizeDelta.y             = 31 * activeItems;
        scrollContent.sizeDelta = sizeDelta;
    }
Ejemplo n.º 9
0
 public void Setup(MatchInfoSnapshot matchInfo, JoinRoomDelegate joinCallback)
 {
     Debug.Log("Found match " + matchInfo.name);
     joinRoomCallback  = joinCallback;
     match             = matchInfo;
     roomNameText.text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
 }
Ejemplo n.º 10
0
    public override void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matchList)
    {
        base.OnMatchList(success, extendedInfo, matchList);

        if (success)
        {
            if (matchList.Count > 0)
            {
                MatchInfoSnapshot match = FindMatch(matchList);
                if (match != null)
                {
                    JoinGame(match);
                }
                else
                {
                    infoPanel.GetComponentInChildren <Text>().text = "No empty slot found";
                    StartCoroutine(CloseInfoPanel(2.0f));
                }
            }
            else
            {
                infoPanel.GetComponentInChildren <Text>().text = "No games available";
                StartCoroutine(CloseInfoPanel(2.0f));
            }
        }
    }
Ejemplo n.º 11
0
 private void onMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matchList)
 {
     if (!success)
     {
         Debug.Log("Error looking for default Lobby match.");
         // we are going to refresh it again
     }
     else
     {
         MatchInfoSnapshot found = null;
         if (matchList.Count > 0)
         {
             // There should be only one match ever - the default one
             // but we check just in case
             foreach (MatchInfoSnapshot match in matchList)
             {
                 if (match.name == GAME_MATCH_NAME)
                 {
                     found = match;
                     break;
                 }
             }
         }
         if (found == null)
         {
             // No one has hosted yet.  Try to host.
             lobbyManager.matchMaker.CreateMatch(GAME_MATCH_NAME, (uint)100, true,
                                                 "", "", "", 0, 0, lobbyManager.OnMatchCreate);
         }
         else
         {
             lobbyManager.matchMaker.JoinMatch(found.networkId, "", "", "", 0, 0, lobbyManager.OnMatchJoined);
         }
     }
 }
Ejemplo n.º 12
0
 public void JoinRoom(MatchInfoSnapshot _match)
 {
     networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     ClearRoomList();
     status.text = "Joining...";
     GameManager.HideUI();
 }
Ejemplo n.º 13
0
    public void Setup(MatchInfoSnapshot match, JoinRoomDelegate joinRoomCallback)
    {
        this.match = match;

        this.joinRoomCallback = joinRoomCallback;
        roomNameText.text     = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
    }
Ejemplo n.º 14
0
    public void Setup(MatchInfoSnapshot matchInfo, JoinRoomDelegate joinRoomDelegate)
    {
        this.matchInfo        = matchInfo;
        this.joinRoomDelegate = joinRoomDelegate;

        roomNameText.text = matchInfo.name + " (" + matchInfo.currentSize + "/" + matchInfo.maxSize + ")";
    }
Ejemplo n.º 15
0
    void buttonSetup(Button button, MatchInfoSnapshot match)
    {
        var x = match;

        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(() => { JoinMatch(match); });
    }
    public void Setup(MatchInfoSnapshot _match, JoinRoomDelegate _joinRoomCallback)
    {
        match = _match;
        joinRoomCallback = _joinRoomCallback;

        roomNameText.text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
    }
 public void JoinRoom(MatchInfoSnapshot _match)
 {
     //(netId,password,callback)
     networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     ClearRoomList();
     status.text = "Joining " + _match.name + "...";
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Зайти в комнату
        /// </summary>
        /// <param name="match"></param>
        public void JoinRoom(MatchInfoSnapshot match)
        {
            networkManager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);

            ClearRoomList();
            status.text = "JOINING...";
        }
Ejemplo n.º 19
0
    public void JoinRoom(MatchInfoSnapshot _match)
    {
        Debug.Log("Joining " + _match.name);

        networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
        StartCoroutine(WaitForJoin());
    }
Ejemplo n.º 20
0
    public void Setup(MatchInfoSnapshot _match, JoinRoomDelegate _joinRoomCallback)
    {
        match            = _match;
        joinRoomCallback = _joinRoomCallback;

        roomNameText.text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
    }
Ejemplo n.º 21
0
    IEnumerator WaitForSuccessfulJoin()
    {
        ClearGameList();

        int countdown = 10;

        while (countdown > 0)
        {
            statusText.text = "Joining Game...";

            yield return(new WaitForSeconds(1));

            countdown--;
        }

        // If you're still on the same scene when the countdown is over.
        AudioManager.instance.PlaySound("connection_error");
        statusText.text = "Failed to connect.";
        yield return(new WaitForSeconds(2.5f));

        MatchInfo matchInfo = netMan.matchInfo;

        if (matchInfo != null)
        {
            netMan.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, netMan.OnDropConnection);
            netMan.StopHost();
        }

        matchToJoin = null;

        RefreshGameList();
    }
Ejemplo n.º 22
0
 public void JoinRoom(MatchInfoSnapshot match)
 {
     // Debug.Log("Joining " + match.name);
     networkManager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     ClearRoomList();
     status.text = "Joining...";
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Handles the user intent to join the room associated with the button clicked.
        /// </summary>
        /// <param name="match">The information about the match that the user intents to
        /// join.</param>
#pragma warning disable 618
        private void OnJoinRoomClicked(MatchInfoSnapshot match)
#pragma warning restore 618
        {
            _manager.matchName = match.name;
            _manager.matchMaker.JoinMatch(match.networkId, string.Empty, string.Empty,
                                          string.Empty, 0, 0, OnMatchJoined);
        }
Ejemplo n.º 24
0
    public void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matches)
    {
        if (success)
        {
            int childCount = listOfMatches.transform.childCount;
            for (int i = 0; i < childCount; ++i)
            {
                Destroy(listOfMatches.transform.GetChild(i).gameObject);
            }

            for (int i = 0; i < matches.Count; ++i)
            {
                MatchInfoSnapshot match     = matches[i];
                string            matchName = match.name;
                UnityEngine.Networking.Types.NetworkID networkId = match.networkId;

                GameObject    gameObject = Instantiate(matchEntryPrefab, listOfMatches);
                RectTransform rect       = gameObject.GetComponent <RectTransform>();

                rect.position = new Vector2(10, listOfMatches.position.y - (float)i * 50.0f);

                Text text = gameObject.GetComponentInChildren <Text>();
                text.text = "Match: " + matchName;
                Button button = gameObject.GetComponentInChildren <Button>();

                button.onClick.AddListener(delegate { OnJoinMatchClicked(networkId); });
            }
        }
        else
        {
            Debug.Log("OnMatchList failed");
        }
    }
Ejemplo n.º 25
0
    public void Setup(MatchInfoSnapshot match, JoinRoomDelgate callback)
    {
        desc          = match;
        jRoomCallBack = callback;

        buttonText.text = desc.name + " (" + desc.currentSize + "/" + desc.maxSize + ")";
    }
Ejemplo n.º 26
0
 public void JoinMatch(MatchInfoSnapshot match)
 {
     if ((UnityEngine.Object)NetworkManager.singleton.matchMaker == (UnityEngine.Object)null)
     {
         NetworkManager.singleton.StartMatchMaker();
     }
     NetworkManager.singleton.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
 }
Ejemplo n.º 27
0
    public void Populate(MatchInfoSnapshot vMatch, JC_LobbyManager vLobbyManager, Color vColour)
    {
        mTX_ServerInfoText.text = vMatch.name;
        mTX_PlayersInRoom.text  = vMatch.currentSize.ToString() + " / " + vMatch.maxSize.ToString();

        mBT_JoinButton.onClick.RemoveAllListeners();
        mBT_JoinButton.onClick.AddListener(() => JoinMatch(vMatch.networkId, vLobbyManager));
    }
 public void JoinMatch(MatchInfoSnapshot match)
 {
     if (matchMaker == null)
     {
         StartMatchMaker();
     }
     matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, HandleJoinedMatch);
 }
Ejemplo n.º 29
0
    public void ButtonCancel()
    {
        panelCharacters.SetActive(false);

        selectedMatch = null;

        RefreshRoomList();
    }
Ejemplo n.º 30
0
 public void Init(MatchInfoSnapshot match, Transform parent)
 {
     btnText.text = match.name;
     transform.SetParent(parent);
     transform.localScale    = Vector3.one;
     transform.localPosition = Vector3.zero;
     transform.localRotation = Quaternion.identity;
 }
Ejemplo n.º 31
0
 public void Initialize(MatchInfoSnapshot server, Transform panel)
 {
     content.text = server.name;
     transform.SetParent(panel);
     transform.localScale    = Vector3.one;
     transform.localRotation = Quaternion.identity;
     transform.localPosition = Vector3.zero;
 }
Ejemplo n.º 32
0
    public void Populate(MatchInfoSnapshot 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.º 33
0
 public void JoinRoom(MatchInfoSnapshot _match)
 {
     networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);
     StartCoroutine(WaitForJoin());
 }