Ejemplo n.º 1
0
 private void OnGalaxyIncommingMessage(byte code, byte[] data)
 {
     if (code == (byte)CommandType.roomGetList)
     {
         MessageRoomInfo messageRoomInfo = MessageRoomInfo.Deserialize <MessageRoomInfo>(data);
         foreach (var item in items)
         {
             Destroy(item);
         }
         items.Clear();
         contentSize.y     = 100;
         content.sizeDelta = contentSize;
         foreach (var item in messageRoomInfo.rooms)
         {
             RoomManagerItem newItem = Instantiate(prefItem, content);
             newItem.SetInfo(item.id, item.name, item.clients, item.maxClients);
             items.Add(newItem.gameObject);
             contentSize.y    += 100;
             content.sizeDelta = contentSize;
         }
         count.text = messageRoomInfo.rooms.Count.ToString();
         return;
     }
     if (code == (byte)CommandType.roomEnter)
     {
         UICreate.SetActive(false);
         UI.SetActive(false);
         Active(false);
         SceneManager.LoadScene("TestLevel");
     }
 }
Ejemplo n.º 2
0
        internal void GetAllRoomsInfo(ClientConnection clientConnection)
        {
            if (instances.Count == 0)
            {
                //А смысл что то возвращять, если никаких инстансов сейчас не создано
                return;
            }
            RoomInfo        info;
            MessageRoomInfo messageRoomInfo = new MessageRoomInfo();

            messageRoomInfo.rooms = new List <RoomInfo>();
            foreach (var item in instances.Keys)
            {
                info            = new RoomInfo();
                info.clients    = (uint)item.clients.Count;
                info.id         = item.id;
                info.maxClients = (uint)item.maxClients;
                info.name       = item.name;
                messageRoomInfo.rooms.Add(info);
            }
            clientConnection.SendMessage((byte)CommandType.roomGetList, messageRoomInfo, GalaxyCoreCommon.GalaxyDeliveryType.reliable);
        }