//void OnPhotonRandomJoinFailed()  //加入随机房间失败
    //{
    //    print("随机房间加入失败");
    //    UISureText.text = "加入房间失败!";
    //    PanelChange(message);
    //    PanelChange(Information);
    //    OnReceivedRoomListUpdate();
    //}



    void OnRoomListUpdate(BLOKUSRoomList roomInfos)   //房间列表更新
    {
        //print("改变");

        foreach (GameObject gameObject in roomList)
        {
            Destroy(gameObject);
        }
        roomList.Clear();
        foreach (BLOKUSRoomInfo roomInfo in roomInfos.roomItems)
        {
            GameObject room = Instantiate(roomItem, roomContent.transform, false);
            roomList.Add(room);
            // room.transform.SetParent(roomContent.transform);

            RoomItemData roomItemData = room.GetComponent <RoomItemData>();
            roomItemData.roomName      = roomInfo.roomName;
            roomItemData.connectPlayer = roomInfo.currentPlayers;
            roomItemData.roomStatus    = roomInfo.RoomStatus;
            if (roomInfo.gameType == GameType.BLOKUS_FOUR)
            {
                roomItemData.maxPlayer = 4;
            }
            else
            {
                roomItemData.maxPlayer = 2;
            }

            roomItemData.ShowRoomInfo();

            room.GetComponent <Button>().onClick.AddListener(delegate {
                NetManager.Instance.TransferMessage(MessageFormater.formatJoinRoomMessage(roomInfo.roomName));
            });
        }
    }
Exemple #2
0
 private void RoomList(MessageBean message)
 {
     if (message.statusCode == StatusCode.SUCCESS)
     {
         BLOKUSRoomList bLOKUSRoomList = ProtobufHelper.DederializerFromBytes <BLOKUSRoomList>(message.data);
         GameObject.Find("UIController").SendMessage("OnRoomListUpdate", bLOKUSRoomList);
     }
 }