Ejemplo n.º 1
0
        /// <summary>
        /// 接收到用户的RPC请求 获取一次在线玩家列表,并显示在线玩家的状态
        /// </summary>
        /// <param name="message"></param>
        public void OnUpdateOnlinePlayerRpc(UpdateOnlinePlayerMessage message)
        {
            S2C_UpdateOnlinePlayerList response = new S2C_UpdateOnlinePlayerList();

            foreach (var item in message.players)
            {
                S2C_UpdateOnlinePlayerList.Types.OnlinePlayerInfo info = new S2C_UpdateOnlinePlayerList.Types.OnlinePlayerInfo();
                info.PlayerId = item;
                //检查玩家所在地
                info.State = GetPlayerState(item);
                response.OnlinePlayers.Add(info);
            }
            //Log.Info(response.ToJson());
            message.reply(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 以下要处理收到的消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override Task OnMessage(ILocalMessage msg)
        {
            switch (msg.MessageId)
            {
            case GameServerConstDefine.MatchSystemCreateMatchTeam:
                CreateMatchTeamMessage createMatchTeamMessage = msg as CreateMatchTeamMessage;
                OnCreateMatchTeam(createMatchTeamMessage.playerId);
                break;

            case GameServerConstDefine.MatchSystemJoinMatchTeam:
                JoinMatchTeamMessage joinMatchTeamMessage = msg as JoinMatchTeamMessage;
                OnJoinMatchTeam(joinMatchTeamMessage.teamId, joinMatchTeamMessage.playerId);
                break;

            case GameServerConstDefine.MatchSystemExitMatchTeam:
                ExitMatchTeamMessage exitMatchTeamMessage = msg as ExitMatchTeamMessage;
                OnExitMatchTeam(exitMatchTeamMessage.teamId, exitMatchTeamMessage.playerId);
                break;

            case GameServerConstDefine.MatchSystemJoinMatchQueue:
                JoinMatchQueueMessage joinMatchQueueMessage = msg as JoinMatchQueueMessage;
                OnJoinMatchQueue(joinMatchQueueMessage.teamId, joinMatchQueueMessage.playerId, joinMatchQueueMessage.barrierId);
                break;

            case GameServerConstDefine.MatchSystemExitMatchQueue:
                ExitMatchQueueMessage exitMatchQueueMessage = msg as ExitMatchQueueMessage;
                OnExitMatchQueue(exitMatchQueueMessage.teamId, exitMatchQueueMessage.playerId);
                break;

            case GameServerConstDefine.MatchQueueCompleteSingle:    //来自 MatcingSystemQueue 的消息,通知system匹配完成
                MatchQueueCompleteSingleMessage matchQueueCompleteSingleMessage = msg as MatchQueueCompleteSingleMessage;
                OnCompleteMatching(matchQueueCompleteSingleMessage.teamIds, matchQueueCompleteSingleMessage.barrierId);
                break;

            case GameServerConstDefine.MatchSysteamMatchTeamUpdateInfo:
                MatchTeamUpdateInfoMessage matchTeamUpdateInfoMessage = msg as MatchTeamUpdateInfoMessage;
                OnUpdateMatchTeam(matchTeamUpdateInfoMessage.teamId);
                break;

            case GameServerConstDefine.MatchSystemPlayerShutdown:
                ToMatchPlayerShutdownMessage toMatchPlayerShutdownMessage = msg as ToMatchPlayerShutdownMessage;
                OnShutdownPlayer(toMatchPlayerShutdownMessage);
                break;

            case GameServerConstDefine.UpdateOnlinePlayerList:    //更新客户端在线玩家状态
                UpdateOnlinePlayerMessage updateOnlinePlayerMessage = msg as UpdateOnlinePlayerMessage;
                OnUpdateOnlinePlayerRpc(updateOnlinePlayerMessage);
                break;

            case GameServerConstDefine.ReleaseBattleToMatchTeam:
                ReleaseBattleToMatchTeamMessage releaseBattleToMatchTeamMessage = msg as ReleaseBattleToMatchTeamMessage;
                OnReleaseBattle(releaseBattleToMatchTeamMessage);
                break;

            default:
                break;
            }


            return(base.OnMessage(msg));
        }