Beispiel #1
0
    private void UpdateRoomInfo()
    {
        RoomInfoData roomInfo = NetworkRecord.RoomInfoData;

        SerialField.text = roomInfo.serial;

        for (int i = 0; i < roomInfo.actorList.Count; i++)
        {
            // Update room's info.
            views[i].actorID.text = roomInfo.actorList[i].memberID;
            if (roomInfo.actorList[i].isReady)
            {
                views[i].isReady.text = "Ready";
            }
            else
            {
                views[i].isReady.text = "";
            }

            // Check ready state, update button.
            if (roomInfo.actorList[i].memberID == NetworkRecord.Username)
            {
                button.SetButtonState(roomInfo.actorList[i].isReady);
            }
        }
    }
Beispiel #2
0
        public static void SendEvent(CellRoom room)
        {
            // Get actor list from room.
            List <CellRoom.ActorInfo> actorList = room.actorList;
            // conversion roomActorList
            List <RoomActorData> roomActorList = new List <RoomActorData>();

            for (int i = 0; i < actorList.Count; i++)
            {
                RoomActorData actorData = new RoomActorData();
                actorData.memberID = actorList[i].memberID;
                actorData.isReady  = actorList[i].isReady;
                roomActorList.Add(actorData);
            }

            // Create transfer data
            RoomInfoData roomData = new RoomInfoData();

            roomData.serial    = room.SerialNum;
            roomData.actorList = roomActorList;

            // Serialize roominfodata.
            byte[]       roomInfoDataByte = ProtoBufTool.Serialize(roomData);
            RoomInfoData testData         = ProtoBufTool.Deserialize <RoomInfoData>(roomInfoDataByte);

            ServerApp.Logger.Info(testData.serial);

            // push data to actors
            for (int i = 0; i < actorList.Count; i++)
            {
                // get peer
                Actor      actor = ServerApp.instance.actorManager.GetActorFromMemberID(actorList[i].memberID);
                ServerPeer peer  = ServerApp.instance.actorManager.TryGetPeer(actor.guid);

                // generate event data.
                var eventDict = new Dictionary <byte, object>();
                eventDict.Add((byte)ParameterCode.RoomInfoData, roomInfoDataByte);

                EventData eventData = new EventData((byte)EventCode.RoomUpdate);
                eventData.Parameters = eventDict;

                peer.SendEvent(eventData, new SendParameters());
            }
        }
Beispiel #3
0
    public void FromBytes(byte[] data, ref int offset)
    {
        int roomAmount = (int)data[offset++];

        Rooms = new GameRoom[roomAmount];
        for (int i = 0; i < roomAmount; i++)
        {
             Rooms[i] = new RoomInfoData(data, ref offset).Room;
        }
    }