Пример #1
0
        /// <summary>
        /// 플레이어를 삭제합니다.
        /// </summary>
        /// <param name="serial"></param>
        /// <returns></returns>
        public bool DeletePlayer(int serial)
        {
            if (playerContainer.ContainsKey(serial) == false)
            {
                return(false);
            }

            MNetworkPlayer player = FindPlayer(serial);

            if (player == null)
            {
                return(false);
            }

            playerContainer.Remove(player.Serial);

            MNetworkRoom room = FindRoom(player.RoomKey);

            if (room != null)
            {
                room.LeavePlayer(player);
            }

            if (room.PlayerCount == 0)
            {
                DeleteRoom(room.roomKey);
            }

            if (player.PlayerState == MNetworkPlayer.MPlayerState.LoginSuccess)
            {
                playerNameContainer.Remove(player.UserName);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// 플레이어를 이름으로 찾는 컨테이너인 playerNameContainer에 추가시킵니다.<br></br>
        /// 로그인이 완료된 플레이어를 이름으로 빠르게 찾기 위한 컨테이너 입니다.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool AddPlayerToNameList(MNetworkPlayer player)
        {
            // 이미 존재한다면 실패
            if (playerNameContainer.ContainsKey(player.UserName) == true)
            {
                return(false);
            }

            playerNameContainer.Add(player.UserName, player);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 플레이어를 추가합니다.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool AddPlayer(MNetworkPlayer player)
        {
            // 이미 존재한다면 실패
            if (playerContainer.ContainsKey(player.Serial) == true)
            {
                return(false);
            }

            playerContainer.Add(player.Serial, player);
            player.RoomKey = string.Empty;
            return(true);
        }
Пример #4
0
        /// <summary>
        /// 방에서 플레이어를 퇴장시킵니다.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool ExitFromRoom(string roomKey, MNetworkPlayer player)
        {
            MNetworkRoom room = FindRoom(roomKey);

            if (room == null)
            {
                return(false);
            }

            room.LeavePlayer(player.Serial);

            return(true);
        }
Пример #5
0
        /// <summary>
        /// 방에서 플레이어를 퇴장시킵니다.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool ExitFromRoom(MNetworkRoom room, MNetworkPlayer player)
        {
            if (room == null)
            {
                return(false);
            }

            if (player == null)
            {
                return(false);
            }

            room.LeavePlayer(player.Serial);

            return(true);
        }
Пример #6
0
        /// <summary>
        /// 방에 플레이어를 입장시킵니다.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool JoinRoom(string roomKey, MNetworkPlayer player)
        {
            MNetworkRoom room = FindRoom(roomKey);

            if (room == null)
            {
                return(false);
            }

            if (player.RoomKey != string.Empty)
            {
                FindRoom(player.RoomKey).LeavePlayer(player.Serial);
            }

            room.JoinPlayer(player);

            return(true);
        }
Пример #7
0
        /// <summary>
        /// 방에 플레이어를 입장시킵니다.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool JoinRoom(string roomKey, string playerKey, out MNetworkRoom room)
        {
            MNetworkPlayer player = FindPlayer(playerKey);
            MNetworkRoom   r      = FindRoom(roomKey);

            room = r;

            if (r == null || player == null)
            {
                return(false);
            }

            if (player.RoomKey != string.Empty)
            {
                FindRoom(player.RoomKey).LeavePlayer(player.Serial);
            }

            r.JoinPlayer(player);

            return(true);
        }