Esempio n. 1
0
        public void LeaveRoom()
        {
            var proto = new network.LeaveRoomRequest();

            GameManager.TCPInstance.Send(new Protobuf()
            {
                Proto = proto, ProtoID = ProtoNameIds.LEAVEROOMREQUEST
            });
            SelectRoom = null;
            BattleData.Instance.Reset();
        }
Esempio n. 2
0
        public void LeaveRoom()
        {
            var proto = new network.LeaveRoomRequest();

            GameManager.TCPInstance.Send(new Protobuf()
            {
                Proto = proto, ProtoID = ProtoNameIds.LEAVEROOMREQUEST
            });
            SelectRoom = null;
            if (PlayerPrefs.HasKey("lastGame"))
            {
                PlayerPrefs.DeleteKey("lastGame");
            }
            BattleData.Instance.Reset();
        }
Esempio n. 3
0
        public void JoinRoom(network.RoomListResponse.RoomInfo roomInfo, string password = null)
        {
            var proto = new network.EnterRoomRequest()
            {
                room_id = roomInfo.room_id
            };

            if (!string.IsNullOrEmpty(password))
            {
                proto.password = password;
            }
            GameManager.TCPInstance.Send(new Protobuf()
            {
                Proto = proto, ProtoID = ProtoNameIds.ENTERROOMREQUEST
            });
            BattleData.Instance.Reset();
            //其实这么写不太合适,但后端没有合适的协议
            SelectRoom = roomInfo;
        }
Esempio n. 4
0
 public void CreateRoom(network.CreateRoomRequest proto)
 {
     SelectRoom = new network.RoomListResponse.RoomInfo()
     {
         allow_guest      = proto.allow_guest,
         first_extension  = proto.first_extension,
         second_extension = proto.second_extension,
         now_player       = 1,
         max_player       = proto.max_player,
         role_strategy    = proto.role_strategy,
         has_password     = proto.passwordSpecified,
         room_name        = proto.room_name,
         seat_mode        = proto.seat_mode,
         playing          = false,
     };
     GameManager.TCPInstance.Send(new Protobuf()
     {
         Proto = proto, ProtoID = ProtoNameIds.CREATEROOMREQUEST
     });
 }
Esempio n. 5
0
        public void OnEventTrigger(MessageType eventType, params object[] parameters)
        {
            switch (eventType)
            {
            case MessageType.ROOMLISTRESPONSE:
                var roomListProto = parameters[0] as network.RoomListResponse;
                RoomInfo = roomListProto.rooms.OrderBy(t => t.playing).ThenBy(t => t.room_id).ToList();
                if (PlayerPrefs.HasKey("lastGame"))
                {
                    network.RoomListResponse.RoomInfo room = getRoomInfoByID(PlayerPrefs.GetInt("lastGame"));
                    if (room != null)
                    {
                        JoinRoom(room);
                    }
                }
                MessageSystem <MessageType> .Notify(MessageType.RoomList);

                break;
            }
        }