public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        _console.AddText("FIRED ROOM LIST" + X);
        X++;
        foreach (RoomInfo info in roomList)
        {
            if (info.RemovedFromList)
            {
                int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
                Debug.Log("Removed room name " + info.Name);

                if (index != -1)
                {
                    //Destroy(listings[index]);
                    listings[index].gameObject.SetActive(false);
                    //Clean up the inactive rooms.
                    Destroy(listings[index].gameObject);
                    listings.RemoveAt(index);
                }
            }
            else
            {
                RoomListing listing = Instantiate(_roomListingBtn, _content);
                if (listing != null)
                {
                    listing.SetRoomInfo(info);
                }
                listings.Add(listing);
            }
        }
    }
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        //for(int i = 0; i < roomList.Count;i++)
        //{
        //    if(roomList[i] == roomList[i+1])
        //    {
        //        roomList.RemoveAt(i + 1);
        //    }
        //}

        foreach (RoomInfo info in roomList)
        {
            //remove from room list


            int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
            if (index != -1)
            {
                Destroy(listings[index].gameObject);
                listings.RemoveAt(index);
            }

            if (!info.RemovedFromList)
            {
                RoomListing listing = Instantiate(roomListing, content);
                if (listing != null)
                {
                    //Debug.Log(info.ToStringFull());
                    listing.SetRoomInfo(info);
                    listings.Add(listing);
                }
            }
        }
    }
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         //removed from list
         if (info.RemovedFromList)
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(_listings[index].gameObject);
                 _listings.RemoveAt(index);
             }
         }
         //added to rooms list
         else
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = Instantiate(_roomListing, _content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     _listings.Add(listing);
                 }
             }
             else
             {
                 //modify listing here.
                 //_listing[index].dowhatever.
             }
         }
     }
 }
Beispiel #4
0
 // when new listing is added, add it to the List of listings and set its info
 // when listing is removed, destroy it and remove it from the List
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         if (info.RemovedFromList)
         {
             // finds listing to remove and removes it from list of rooms and fromt he UI
             int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(listings[index].gameObject);
                 listings.RemoveAt(index);
             }
         }
         else
         {
             int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 // creates listing and adds to list of rooms
                 RoomListing listing = Instantiate(roomListing, content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     listings.Add(listing);
                 }
             }
         }
     }
 }
Beispiel #5
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         if (info.RemovedFromList)
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(_listings[index].gameObject);
                 _listings.RemoveAt(index);
             }
         }
         else
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = Instantiate(_roomListing, _content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     _listings.Add(listing);
                 }
             }
             else
             {
             }
         }
     }
 }
Beispiel #6
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         //Removed from room list
         if (info.RemovedFromList)
         {
             int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(listings[index].gameObject);
                 listings.RemoveAt(index);
             }
         }
         //Added to room list
         else
         {
             int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = Instantiate(roomListing, content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     listings.Add(listing);
                 }
             }
             else
             {
                 //modify listing here
                 //ex.. listings[index].doWhatever
             }
         }
     }
 }
Beispiel #7
0
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        foreach (RoomInfo info in roomList)
        {
            // removed from room list
            if (info.RemovedFromList)
            {
                int index = _listings.FindIndex(i => i.RoomInfo.Name == info.Name);
                if (index != -1)
                {
                    Destroy(_listings[index].gameObject);
                    _listings.RemoveAt(index);
                }
            }
            else // added in the list
            {
                RoomListing listing = Instantiate(roomListing, container) as RoomListing;

                if (listing != null)
                {
                    listing.SetRoomInfo(info);
                    _listings.Add(listing);
                }
            }
        }
    }
Beispiel #8
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         //Removed from rooms list.
         if (info.RemovedFromList)
         {
             int index = _listing.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(_listing[index].gameObject);
                 _listing.RemoveAt(index);
             }
         }
         //Added to rooms list.
         else
         {
             int index = _listing.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = (RoomListing)Instantiate(_roomListPrefab, _content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     _listing.Add(listing);
                 }
             }
             else
             {
             }
         }
     }
 }
Beispiel #9
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         if (info.RemovedFromList || info.MaxPlayers == info.PlayerCount)
         {
             DestroyRoomListing(info);
         }
         else
         {
             int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = Instantiate(roomListing, content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     listings.Add(listing);
                 }
             }
             else
             {
                 listings[index].SetRoomInfo(info);
             }
         }
     }
 }
Beispiel #10
0
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        foreach (RoomInfo roomInfo in roomList)
        {
            int index = listings.FindIndex(x => x.RoomInfo.Name == roomInfo.Name);

            if (roomInfo.RemovedFromList)
            {
                if (index != -1)
                {
                    Destroy(listings[index].gameObject);
                    listings.RemoveAt(index);
                }
            }
            else
            {
                if (index == -1 && NetworkManager.GetRoomType(roomInfo) == '%')
                {
                    RoomListing listing = Instantiate(roomListing, content);
                    if (listing != null)
                    {
                        listing.SetRoomInfo(roomInfo);
                        listings.Add(listing);
                    }
                }
            }
        }
    }
Beispiel #11
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         // Removed from rooms list
         if (info.RemovedFromList || !info.IsOpen)
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(_listings[index].gameObject);
                 _listings.RemoveAt(index);
             }
         }
         //  Added to roooms list
         else
         {
             int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index == -1)
             {
                 RoomListing listing = Instantiate(_roomListing, _content);
                 if (listing != null)
                 {
                     listing.SetRoomInfo(info);
                     _listings.Add(listing);
                 }
             }
             else
             {
                 // we can modify a listing here (a listed room)
                 // _listings[index].whatever so .modify or whatever
             }
         }
     }
 }
Beispiel #12
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     for (int i = 0; i < roomList.Count; i++)
     {
         RoomInfo    info    = roomList[i];
         RoomListing listing = Instantiate(_roomListing, _content);
         if (listing)
         {
             listing.SetRoomInfo(info);
         }
     }
 }
    private void AddRoomListing(RoomInfo info)
    {
        int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);//x is some element in the _listings list.

        if (index == -1)
        {
            RoomListing listing = Instantiate(_roomListing, _content);
            if (listing != null)
            {
                listing.SetRoomInfo(info);//Update the text on the Room Listing
                _listings.Add(listing);
            }
        }
    }
Beispiel #14
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     Debug.Log("Rooms List Updated!");
     foreach (RoomInfo info in roomList)
     {
         int index = listings.FindIndex(x => x.roomInfo.Name == info.Name);
         if (index != -1)
         {
             // Removed from rooms list
             if (info.RemovedFromList)
             {
                 availableRoomNames.Remove(info.Name);
                 Destroy(listings[index].gameObject);
                 listings.RemoveAt(index);
             }
             // Update Room List if full
             else if (info.PlayerCount == info.MaxPlayers)
             {
                 listings[index].joinButton.SetActive(false);
             }
             else
             {
                 listings[index].joinButton.SetActive(true);
             }
         }
         // Added to rooms list
         else
         {
             RoomListing listing = Instantiate(roomListing, roomListingContent);
             if (listing != null)
             {
                 listing.SetRoomInfo(info);
                 listings.Add(listing);
                 availableRoomNames.Add(info.Name);
             }
         }
     }
 }
Beispiel #15
0
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     Debug.Log("Room list updated");
     foreach (RoomInfo info in roomList)
     {
         int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
         if (info.RemovedFromList)
         {
             Debug.Log("Room to be removed from List: " + info.Name);
             if (index != -1)
             {
                 Destroy(_listings[index].gameObject);
                 _listings.RemoveAt(index);
             }
         }
         else
         {
             Debug.Log("Room added: " + info.Name);
             if (index != -1)
             {
                 Debug.Log("Updating existing room");
                 _listings[index].SetRoomInfo(info);
             }
             else
             {
                 Debug.Log("Adding new room!");
                 RoomListing listing = Instantiate(_roomListing, _content);
                 if (listing != null)
                 {
                     Debug.Log("Added new room!");
                 }
                 listing.SetRoomInfo(info);
                 _listings.Add(listing);
             }
         }
     }
 }
Beispiel #16
0
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        base.OnRoomListUpdate(roomList);

        foreach (RoomInfo info in roomList)
        {
            // Consider updating the _listings to hashmap to save time here...
            int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);

            // If the room has been flagged for removal and is _listings, remove
            if (info.RemovedFromList)
            {
                if (index != -1)
                {
                    Destroy(_listings[index].gameObject);
                    _listings.RemoveAt(index);
                }
            }
            // Otherwise, if the room doesn't exist yet, create it
            else if (index == -1)
            {
                RoomListing listing = Instantiate(_roomListing, _content);

                if (listing != null)
                {
                    listing.SetRoomInfo(info);
                    _listings.Add(listing);
                }
            }
            // Otherwise, the room already exists, so it's being updated
            else
            {
                // Update room listing here...
                _listings[index].SetRoomInfo(info);
            }
        }
    }
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        foreach (RoomInfo info in roomList)
        {
            //Removed from rooms list.
            if (info.RemovedFromList)
            {
                int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
                if (index != -1 && _listings[index] != null)
                {
                    // PhotonManager.instance.DestroyChild(_content.gameObject);

                    //print(_listings[index]);
                    Destroy(_listings[index].gameObject);
                    _listings.RemoveAt(index);
                }
                else if (_listings[index] == null)
                {
                    PhotonManager.instance.DestroyChild(PhotonManager.instance._contentRoomListing.gameObject);
                    PhotonNetwork.Disconnect();
                    PhotonNetwork.ConnectUsingSettings();
                }
            }
            //Added to rooms list
            else
            {
                // PhotonManager.instance.DestroyChild(_content.gameObject);
                RoomListing listing = Instantiate(_roomListing, _content);
                if (listing != null)
                {
                    listing.SetRoomInfo(info);
                    _listings.Add(listing);
                }
            }
        }
    }