Esempio n. 1
0
        public LBPlayer GetPlayerByConnectionId(int playerId)
        {
            LBPlayer ret = null;

            mPlayerConnectionDic.TryGetValue(playerId, out ret);
            return(ret);
        }
Esempio n. 2
0
        public LBPlayer GetPlayerByPlayerId(int playerId)
        {
            LBPlayer ret = null;

            mPlayerDic.TryGetValue(playerId, out ret);
            return(ret);
        }
Esempio n. 3
0
        public void PlayerLogin(int playerId, string playerName, int connectionId)
        {
            LBPlayer curPlayer = GetPlayerByPlayerId(playerId);

            if (null != curPlayer)
            {
                LBLogger.Error(LogTag, "当前玩家已经登录,不能再次登录 " + playerId + " " + playerName);
                return;
            }
            curPlayer = mCacheManager.GetObject();
            curPlayer.Login(playerId, playerName, connectionId);
            mPlayerDic[playerId] = curPlayer;
            mPlayerConnectionDic[connectionId] = curPlayer;

            LBPeerManager.Instance.SendMessage(connectionId, RpId.PlayerLogin, RpPlayerLogin.Serialization(playerId, playerName));
        }
Esempio n. 4
0
        public void PlayerDisconnect(int peerConnectionId)
        {
            LBPlayer curPlayer = GetPlayerByConnectionId(peerConnectionId);

            if (null == curPlayer)
            {
                return;
            }
            mPlayerConnectionDic.Remove(curPlayer.ConnectionId);
            mPlayerDic.Remove(curPlayer.PlayerId);
            int playerId = curPlayer.PlayerId;

            curPlayer.Logout();
            mCacheManager.ReturnObject(curPlayer);
            LBRoomManager.Instance.PlayerLeaveRoom(playerId);
            LBSceneManager.Instance.PlayerLeaveScene(playerId);
        }