コード例 #1
0
ファイル: RoomBiz.cs プロジェクト: niuniuzhu/Lockstep
        public PResult Join(string userId, Room room)
        {
            PResult result = this.CanEnter(userId, room);

            if (result != PResult.SUCCESS)
            {
                return(result);
            }

            result = BizFactory.HALL_BIZ.Leave(userId);
            if (result != PResult.SUCCESS)
            {
                return(result);
            }

            User user = BizFactory.USER_BIZ.GetUser(userId);

            Room.Player player = new Room.Player();
            player.id   = userId;
            player.name = user.name;
            player.hero = "h0";
            //if ( userId == room.hostId )
            //	player.ready = true;
            result = CacheFactory.ROOM_CACHE.Join(player, room);

            return(result);
        }
コード例 #2
0
        public static _DTO_player_info[] GetPlayerInfoInRoom(Room room)
        {
            int count  = room.teamOne.Count;
            int count2 = room.teamTwo.Count;
            var dtos   = new _DTO_player_info[count + count2];

            for (int i = 0; i < count; i++)
            {
                Room.Player player = room.teamOne[i];
                dtos[i] = ProtocolManager.DTO_player_info(player.hero, player.name, player.ready, ( byte )(player.model << 4 | player.skin), 0, player.id);
            }
            for (int i = 0; i < count2; i++)
            {
                Room.Player player = room.teamTwo[i];
                dtos[count + i] = ProtocolManager.DTO_player_info(player.hero, player.name, player.ready, ( byte )(player.model << 4 | player.skin), 1, player.id);
            }
            return(dtos);
        }
コード例 #3
0
        public static _DTO_room_info_detail GetRoomInfoDTO(Room room)
        {
            int count  = room.teamOne.Count;
            int count2 = room.teamTwo.Count;

            _DTO_player_info[] players = new _DTO_player_info[count + count2];
            for (int i = 0; i < count; i++)
            {
                Room.Player player = room.teamOne[i];
                players[i] = ProtocolManager.DTO_player_info(player.hero, player.name, player.ready, ( byte )(player.model << 4 | player.skin), 0, player.id);
            }
            for (int i = 0; i < count2; i++)
            {
                Room.Player player = room.teamTwo[i];
                players[count + i] = ProtocolManager.DTO_player_info(player.hero, player.name, player.ready, ( byte )(player.model << 4 | player.skin), 1, player.id);
            }
            return(ProtocolManager.DTO_room_info_detail(room.hostId, room.map, room.name, players, room.id));
        }
コード例 #4
0
ファイル: RoomCache.cs プロジェクト: niuniuzhu/AnimalRunning
        public PResult Join(Room.Player player, Room room)
        {
            lock (this.lockObj2)
            {
                if (room.teamOne.Count <= room.teamTwo.Count)
                {
                    room.teamOne.Add(player);
                }
                else
                {
                    room.teamTwo.Add(player);
                }
            }

            this._uidToRoom.TryAdd(player.id, room);

            Logger.Log($"玩家{player.id}进入房间");

            return(PResult.SUCCESS);
        }