Exemplo n.º 1
0
 public void JoinRoom(MatchJoiner match)
 {
     match.connect(networkManager);
     waitScreen.SetActive(true);
     StartCoroutine(WaitForHost());
     ClearRoomList();
 }
Exemplo n.º 2
0
    // Callback funtion for request to get online matchList
    public void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matchList)
    {
        Debug.Log("Got Response for Internet Server List");
        OnLocalMatchList();
        if (success)
        {
            foreach (MatchInfoSnapshot matchInfo in matchList)
            {
                MatchJoiner match = OnlineMatch.GetMatchJoiner(matchInfo);
                AddToList(match);
            }
            if (roomListParent.transform.childCount == 1)
            {
                ServerListStatus.text = "No active servers at the moment.";
            }
            else
            {
                ServerListStatus.text = "Server list ready.";
            }
        }
        else
        {
            if (roomListParent.transform.childCount == 1)
            {
                ServerListStatus.text = "Couldn't connect to Internet. No LAN servers at the moment.";
            }
            else
            {
                ServerListStatus.text = "Couldn't connect to Internet. Showing Local Serves.";
            }

            return;
        }
    }
Exemplo n.º 3
0
    public override void OnReceivedBroadcast(string fromAddress, string data)
    {
        base.OnReceivedBroadcast(fromAddress, data);
        Debug.Log("broadcast received from xyx " + fromAddress + " data = " + data);
        bool        validData = false;
        MatchJoiner match     = LANMatch.GetMatchJoiner(fromAddress, data, out validData);

        if (validData)
        {
            Debug.Log("Valid Data");
            var tuple = new  Tuple <MatchJoiner, float>(match, Time.time + broadcastInterval + 1f);
            if (!localMatches.ContainsKey(fromAddress))
            {
                localMatches.Add(fromAddress, tuple);
            }
            else
            {
                localMatches[fromAddress] = tuple;
            }
        }
        else
        {
            Debug.Log("currupt data received");
        }
    }
Exemplo n.º 4
0
    private void AddToList(MatchJoiner match)
    {
        GameObject   _roomListItemInst  = Instantiate(roomListItemPrefab, roomListParent.transform);
        RoomListItem roomListItemScript = _roomListItemInst.GetComponent <RoomListItem>();

        if (roomListItemScript != null)
        {
            roomListItemScript.Setup(match, JoinRoom);
            roomList.Add(_roomListItemInst);
        }
    }
Exemplo n.º 5
0
    public MatchJoiner[] GetMatchList()
    {
        MatchJoiner[] matches = new MatchJoiner[localMatches.Count];
        int           i       = 0;

        foreach (string match in localMatches.Keys)
        {
            matches[i++] = localMatches[match].Item1;
        }
        return(matches);
    }
Exemplo n.º 6
0
    // updates the possible matches list
    public override void OnReceivedRoomListUpdate()
    {
        RoomInfo[] roomList = PhotonNetwork.GetRoomList();
        if (roomList.Length == 0)
        {
            matchJoinText.text = "No Matches Online";
        }
        else
        {
            matchJoinText.text = "Join Match";
        }

        int currentMatchesCount = this.matchListContent.transform.childCount;

        if (roomList.Length >= currentMatchesCount)
        {
            for (int index = 0; index < (roomList.Length - currentMatchesCount); index++)
            {
                GameObject newMatchBtn = Instantiate(matchPrefabBtn);
                newMatchBtn.transform.SetParent(this.matchListContent, false);
            }
        }
        else
        {
            for (int index = 0; index < (currentMatchesCount - roomList.Length); index++)
            {
                Destroy(this.matchListContent.transform.GetChild(currentMatchesCount - (index + 1)).gameObject);
            }
        }

        for (int index = 0; index < roomList.Length; index++)
        {
            MatchJoiner matchJoiner = this.matchListContent.transform.GetChild(index).GetComponent <MatchJoiner>();
            matchJoiner.UpdateRoom(roomList[index]);

            RectTransform matchJointRect = matchJoiner.GetComponent <RectTransform> ();
            matchJointRect.localPosition = new Vector3(matchJointRect.localPosition.x, -(index * matchJointRect.sizeDelta.y), 0);
        }

        this.matchListContent.sizeDelta = new Vector2(this.matchListContent.sizeDelta.x, roomList.Length * matchPrefabBtn.GetComponent <RectTransform>().sizeDelta.y);
    }
Exemplo n.º 7
0
 public void Setup(MatchJoiner _match, ToJoin _toJoin)
 {
     match             = _match;
     toJoin            = _toJoin;
     roomNameText.text = match.GetName() + "(" + match.GetPlayerCount() + "/" + match.GetSize() + ")";
 }