Пример #1
0
        //TODO: BATTLE END Remove Room
        public void CreateRoom(string battleSessionID, List <long> users, Action <RoomData> createdCallback)
        {
            RoomData            data = new RoomData();
            BMCreateRoomRequest req  = new BMCreateRoomRequest();

            foreach (var uid in users)
            {
                var        user   = GetProxy <UserProxy>().GetData(uid);
                PlayerInfo player = new PlayerInfo();
                player.Uid   = user.uid;
                player.Exp   = user.exp;
                player.Gold  = user.gold;
                player.Level = user.level;
                player.Name  = user.name;
                req.Users.Add(player);
            }

            SendMessage <BMCreateRoomRequest, BMCreateRoomReply>(battleSessionID, req,
                                                                 (sessionID, rep) =>
            {
                data.SetData(sessionID, rep.RoomID, rep.PlayerTokens, rep.RoomName);
                data.SetUsers(users);
                GetData(sessionID).AddRoom(data);
                createdCallback.Invoke(data);
            });
        }
Пример #2
0
        void OnCreateRoom(BMCreateRoomRequest req)
        {
            var room = GetProxy <BattleServerProxy>().MainServerRequsetCreateRoom(req.Users);
            BMCreateRoomReply rep = new BMCreateRoomReply();

            rep.RoomName = room.name;
            rep.RoomID   = room.id;
            foreach (var user in room.users)
            {
                var ptoken = new PlayerTokenInfo();
                ptoken.Uid   = user.uid;
                ptoken.Token = user.token;
                rep.PlayerTokens.Add(ptoken);
            }
            SendMessage(rep);
        }