Esempio n. 1
0
    // RoomReceived is called for every room in every updated room list. Parameter room is the room info of the received room.
    private void RoomReceived(Photon.Realtime.RoomInfo room)
    {
        // Find the index of the received room. This will be -1 if the room is not found.
        int index = RoomListingButtons.FindIndex(x => x.m_RoomName == room.Name);

        // Update the local list of room listings and the room listing UI if the room has not yet been received.
        if (index == -1)
        {
            if (room.IsVisible && room.PlayerCount < room.MaxPlayers)
            {
                GameObject roomListingObject = Instantiate(RoomListingPrefab);
                roomListingObject.transform.SetParent(transform, false);

                RoomListing roomListing = roomListingObject.GetComponent <RoomListing>();
                RoomListingButtons.Add(roomListing);

                index = (RoomListingButtons.Count - 1);
            }
        }

        // If the room is already in the local list of room listings, detect if the room has been removed. If the room
        // has been removed, set the updated flag to false, otherwise the room name has been updated so store the new
        // room name and set the updated flag to true.
        if (index != -1)
        {
            RoomListing roomListing = RoomListingButtons[index];
            if (room.RemovedFromList)
            {
                roomListing.m_Updated = false;
            }
            else
            {
                roomListing.SetRoomNameText(room.Name);
                roomListing.m_Updated = true;
            }
        }
    }
Esempio n. 2
0
        /// </summary>

        /// <summary>
        /// Makes RoomInfo comparable (by name).
        /// </summary>
        public override bool Equals(object other)
        {
            RoomInfo otherRoomInfo = other as RoomInfo;

            return(otherRoomInfo != null && this.Name.Equals(otherRoomInfo.name));
        }