예제 #1
0
 internal void HandleRequestExpeditionInfo(ulong guid, int hp, int mp, int rage, int request_num, bool is_reset, bool allow_cost_gold, long timestamp)
 {
     long c_DeltaTime = 60 * 10;
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user != null && null != user.Expedition)
     {
         GeneralOperationResult result = GeneralOperationResult.LC_Failure_Unknown;
         long dif_time = Convert.ToInt64(TimeUtility.CurTimestamp) - timestamp;
         bool is_valid_timestamp = Math.Abs(dif_time) <= c_DeltaTime ? true : false;
         if (is_reset && !is_valid_timestamp)
         {
             result = GeneralOperationResult.LC_Failure_Time;
         }
         else
         {
             result = user.Expedition.RequestExpeditionInfo(guid, request_num, is_reset, m_UsableImages);
         }
         if (GeneralOperationResult.LC_Succeed == result)
         {
             user.Expedition.SyncExpeditionInfo(guid, hp, mp, rage, request_num, result);
         }
         else
         {
             JsonMessageWithGuid resetMsg = new JsonMessageWithGuid(JsonMessageID.ExpeditionResetResult);
             resetMsg.m_Guid = guid;
             ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult protoData = new ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult();
             protoData.m_Result = (int)result;
             resetMsg.m_ProtoData = protoData;
             JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resetMsg);
         }
     }
 }
예제 #2
0
 internal void HandleQueryArenaInfo(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query arena info msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaInfoResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaInfoResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaInfoResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     if (own_arena == null)
     {
         own_arena = m_ArenaSystem.CreateArenaInfo(user);
     }
     else if (own_arena.IsNeedUpdate(user))
     {
         own_arena.UpdateArenaInfo(user);
     }
     m_ArenaSystem.ResetArenaFightCount(own_arena);
     protoData.m_ArenaInfo = ArenaUtil.CreateArenaInfoMsg(own_arena, false);
     protoData.m_LeftBattleCount = own_arena.LeftFightCount;
     protoData.m_CurFightCountByTime = own_arena.FightCountBuyTime;
     long passed_time = (long)(DateTime.Now - own_arena.LastBattleTime).TotalMilliseconds;
     protoData.m_BattleLeftCDTime = m_ArenaSystem.BaseConfig.BattleCd - passed_time;
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send query arena info msg! id=" + guid);
 }
예제 #3
0
        internal void StartBattleRoom()
        {
            this.CurrentState = RoomState.Game;  //房间进入游戏状态
            RoomServerInfo svrInfo;

            if (m_LobbyInfo.RoomServerInfos.TryGetValue(m_RoomServerName, out svrInfo))
            {
                foreach (WeakReference userRef in m_Users.Values)
                {
                    UserInfo info = userRef.Target as UserInfo;
                    if (info != null)
                    {
                        JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                        startGameResultMsg.m_Guid = info.Guid;
                        ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                        protoData.server_ip   = svrInfo.ServerIp;
                        protoData.server_port = svrInfo.ServerPort;
                        protoData.key         = info.Key;
                        protoData.hero_id     = info.HeroId;
                        protoData.camp_id     = info.CampId;
                        protoData.scene_type  = SceneType;
                        protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                        startGameResultMsg.m_ProtoData = protoData;

                        JsonMessageDispatcher.SendDcoreMessage(info.NodeName, startGameResultMsg);
                        LogSys.Log(LOG_TYPE.DEBUG, "StartGameResult, guid:{0},key:{1},ip:{2},port:{3},hero:{4},camp:{5},scene:{6}", info.Guid, info.Key, svrInfo.ServerIp, svrInfo.ServerPort, info.HeroId, protoData.camp_id, SceneType);
                    }
                }
            }
        }
예제 #4
0
 internal void HandleArenaBuyFightCount(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena buy fight count!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaBuyFightCountResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
     protoData.CurBuyTime = 0;
     protoData.CurFightCount = 0;
     protoData.Result = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
     if (own_arena != null && user != null && scheduler != null)
     {
         ArenaBuyFightCountConfig buy_config = ArenaConfigProvider.Instance.BuyFightCountConfig.GetDataById(own_arena.FightCountBuyTime + 1);
         if (user.Vip >= buy_config.RequireVipLevel && user.Gold >= buy_config.Cost)
         {
             if (own_arena.LeftFightCount < own_arena.MaxFightCount)
             {
                 own_arena.FightCountBuyTime += 1;
                 own_arena.LeftFightCount = own_arena.MaxFightCount;
                 protoData.Result = (int)GeneralOperationResult.LC_Succeed;
             }
             else
             {
                 protoData.Result = (int)GeneralOperationResult.LC_Failure_Full;
             }
             protoData.CurBuyTime = own_arena.FightCountBuyTime;
             protoData.CurFightCount = own_arena.LeftFightCount;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena buy fight count result!");
 }
예제 #5
0
        internal void NotifyRequestDare(ulong userGuid, string targetNickname)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);

            if (null == user)
            {
                return;
            }
            ulong    targetGuid = LobbyServer.Instance.DataProcessScheduler.GetGuidByNickname(targetNickname);
            UserInfo target     = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(targetGuid);

            if (null == target)
            {
                return;
            }
            long cur_time = TimeUtility.GetServerMilliseconds();

            if (cur_time - user.LastRequestDareTime > CHALLENGE_CD_MS)
            {
                user.LastRequestDareTime = TimeUtility.GetServerMilliseconds();
                JsonMessageWithGuid rdMsg = new JsonMessageWithGuid(JsonMessageID.RequestDare);
                rdMsg.m_Guid = targetGuid;
                ArkCrossEngineMessage.Msg_LC_RequestDare protoData = new ArkCrossEngineMessage.Msg_LC_RequestDare();
                protoData.m_ChallengerNickname = user.Nickname;
                rdMsg.m_ProtoData = protoData;
                JsonMessageDispatcher.SendDcoreMessage(target.NodeName, rdMsg);
            }
            else
            {
                NotifyRequestDareResult(userGuid, user.Nickname, GeneralOperationResult.LC_Failure_InCd);
            }
        }
예제 #6
0
        internal void AllocLobbyRoom(ulong[] users, int type)
        {
            int  roomId = m_LobbyInfo.CreateAutoRoom(users, type);
            long time   = TimeUtility.GetServerMilliseconds();

            DataProcessScheduler dataProcess    = LobbyServer.Instance.DataProcessScheduler;
            JsonMessageWithGuid  matchResultMsg = new JsonMessageWithGuid(JsonMessageID.MatchResult);

            foreach (ulong user in users)
            {
                UserInfo info = dataProcess.GetUserInfo(user);
                if (info != null)
                {
                    info.LastNotifyMatchTime = time;
                    matchResultMsg.m_Guid    = user;
                    ArkCrossEngineMessage.Msg_LC_MatchResult protoData = new ArkCrossEngineMessage.Msg_LC_MatchResult();
                    protoData.m_Result         = (int)TeamOperateResult.OR_Succeed;
                    matchResultMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(info.NodeName, matchResultMsg);
                    ///
                    dataProcess.RecordCampaignAction(user, type);
                }
            }

            LogSys.Log(LOG_TYPE.DEBUG, "Alloc lobby room for {0} users, roomid {1} scene {2}", users.Length, roomId, type);
        }
예제 #7
0
        internal bool LeaveGroup(GroupInfo group, GroupMemberInfo member)
        {
            if (null == group || null == member)
            {
                return(false);
            }
            if (member.Guid == group.CreatorGuid && group.Members.Count > 1)
            {
                m_Groups.Remove(group.CreatorGuid);
                group.CreatorGuid = group.Members[1].Guid;
                if (!m_Groups.ContainsKey(group.CreatorGuid))
                {
                    m_Groups.Add(group.CreatorGuid, group);
                }
                ///
                UserInfo leader = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(group.CreatorGuid);
                if (null != leader)
                {
                    JsonMessageWithGuid slgMsg = new JsonMessageWithGuid(JsonMessageID.ChangeCaptain);
                    slgMsg.m_Guid = group.CreatorGuid;
                    ArkCrossEngineMessage.Msg_LC_ChangeCaptain protoData = new ArkCrossEngineMessage.Msg_LC_ChangeCaptain();
                    protoData.m_CreatorGuid = group.CreatorGuid;
                    slgMsg.m_ProtoData      = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(leader.NodeName, slgMsg);
                }
            }
            bool result = group.Members.Remove(member);

            if (group.Members.Count == 0)
            {
                recycles.Enqueue(group);
            }
            return(result);
        }
예제 #8
0
 internal void HandleQueryArenaMatchGroup(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query match group msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaMatchGroupResult);
     resultMsg.m_Guid = guid;
     int cur_user_rank = ArenaSystem.UNKNOWN_RANK;
     ArenaInfo arena_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (arena_info != null)
     {
         cur_user_rank = arena_info.GetRank();
     };
     List<MatchGroup> match_groups = m_ArenaSystem.QueryMatchArena(cur_user_rank, 3);
     ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult();
     foreach (MatchGroup group in match_groups)
     {
         ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData group_msg = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData();
         group_msg.One = ArenaUtil.CreateArenaInfoMsg(group.One);
         group_msg.Two = ArenaUtil.CreateArenaInfoMsg(group.Two);
         group_msg.Three = ArenaUtil.CreateArenaInfoMsg(group.Three);
         if (group_msg.One == null || group_msg.Two == null || group_msg.Three == null)
         {
             continue;
         }
         protoData.m_MatchGroups.Add(group_msg);
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send match group msg! id=" + guid);
 }
예제 #9
0
        internal void DismissGroup(GroupInfo group)
        {
            if (null == group)
            {
                return;
            }
            UserInfo          leader = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(group.CreatorGuid);
            TeamOperateResult result = TeamOperateResult.OR_Dismiss;

            foreach (GroupMemberInfo m in group.Members)
            {
                UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(m.Guid);
                if (null != user)
                {
                    JsonMessageWithGuid msg = new JsonMessageWithGuid(JsonMessageID.SyncLeaveGroup);
                    msg.m_Guid = m.Guid;
                    ArkCrossEngineMessage.Msg_LC_SyncLeaveGroup protoData = new ArkCrossEngineMessage.Msg_LC_SyncLeaveGroup();
                    if (null != leader)
                    {
                        protoData.m_GroupNick = leader.Nickname;
                    }
                    protoData.m_Result = (int)result;
                    msg.m_ProtoData    = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(leader.NodeName, msg);
                    user.Group = null;
                }
            }
            m_Groups.Remove(group.CreatorGuid);
            if (null != group.Members)
            {
                group.Members.Clear();
            }
            recycles.Enqueue(group);
        }
예제 #10
0
        internal void HandleBuyLife(ulong guid)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;

            if (null == scheduler)
            {
                return;
            }
            // 响应玩家要求复活
            UserInfo user   = scheduler.GetUserInfo(guid);
            bool     result = false;

            if (null != user)
            {
                int reliveStoneId = ItemConfigProvider.Instance.GetReliveStoneId();
                if (user.ItemBag.GetItemCount(reliveStoneId, 0) >= 1)
                {
                    scheduler.ConsumeItem(guid, user.ItemBag.GetItemData(reliveStoneId, 0), 1, GainItemType.Props, ConsumeItemWay.BuyLife, false, "BuyLife");
                    result = true;
                }
                else if (user.Gold >= 50)
                {
                    int consume = 50;
                    scheduler.ConsumeAsset(guid, consume, ConsumeAssetType.BuyLife, AssetType.Glod, "BuyLife");
                    result = true;
                }
                if (result)
                {
                    user.CurrentBattleInfo.DeadCount += 1;
                    if (null != user.Room)
                    {
                        Msg_LR_UserReLive.Builder resultBuilder = Msg_LR_UserReLive.CreateBuilder();
                        RoomInfo room = m_LobbyInfo.GetRoomByID(user.CurrentRoomID);
                        resultBuilder.SetUserGuid(guid);
                        resultBuilder.SetRoomID(user.CurrentRoomID);
                        LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, resultBuilder.Build());
                    }
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
                else
                {
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
            }
            //JsonMessageDispatcher.SendDcoreMessage(user.NodeName, );
        }
예제 #11
0
        private void SendResultMsg(ChallengeInfo info, UserInfo user)
        {
            if (user == null)
            {
                return;
            }
            JsonMessageWithGuid retMsg = new JsonMessageWithGuid(ArkCrossEngine.JsonMessageID.ArenaChallengeResult);

            retMsg.m_Guid = user.Guid;
            ArkCrossEngineMessage.Msg_LC_ArenaChallengeResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaChallengeResult();
            protoData.m_ChallengeInfo = ArenaUtil.CreateChallengeInfoData(info);
            retMsg.m_ProtoData        = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, retMsg);
        }
예제 #12
0
        internal void GetStarList(ulong guid, int start, int count)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user      = scheduler.GetUserInfo(guid);

            if (null != user)
            {
                if (start < 0)
                {
                    start = 0;
                }
                int ct  = m_GowStars.Count;
                int end = start + count;
                if (end > ct)
                {
                    end = ct;
                }
                JsonMessageWithGuid aaMsg = new JsonMessageWithGuid(JsonMessageID.SyncGowStarList);
                aaMsg.m_Guid = guid;
                ArkCrossEngineMessage.Msg_LC_SyncGowStarList protoData = new ArkCrossEngineMessage.Msg_LC_SyncGowStarList();
                for (int i = start; i < end; ++i)
                {
                    UserInfo member = scheduler.GetUserInfo(m_GowStars[i].m_Guid);
                    if (null != member)
                    {
                        m_GowStars[i].m_Level         = member.Level;
                        m_GowStars[i].m_FightingScore = member.FightingScore;
                    }
                    ArkCrossEngineMessage.Msg_LC_SyncGowStarList.GowStarInfoForMessage info = new ArkCrossEngineMessage.Msg_LC_SyncGowStarList.GowStarInfoForMessage();
                    info.m_Guid                     = m_GowStars[i].m_Guid;
                    info.m_GowElo                   = m_GowStars[i].m_GowElo;
                    info.m_Nick                     = m_GowStars[i].m_Nick;
                    info.m_HeroId                   = m_GowStars[i].m_HeroId;
                    info.m_Level                    = m_GowStars[i].m_Level;
                    info.m_FightingScore            = m_GowStars[i].m_FightingScore;
                    info.m_RankId                   = m_GowStars[i].m_RankId;
                    info.m_Point                    = m_GowStars[i].m_Point;
                    info.m_CriticalTotalMatches     = m_GowStars[i].m_CriticalTotalMatches;
                    info.m_CriticalAmassWinMatches  = m_GowStars[i].m_CriticalAmassWinMatches;
                    info.m_CriticalAmassLossMatches = m_GowStars[i].m_CriticalAmassLossMatches;
                    protoData.m_Stars.Add(info);
                }
                if (protoData.m_Stars.Count > 0)
                {
                    aaMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, aaMsg);
                }
            }
        }
예제 #13
0
        internal void NotifyRequestDareResult(ulong guid, string nickname, GeneralOperationResult result)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);

            if (null == user)
            {
                return;
            }
            JsonMessageWithGuid rdMsg = new JsonMessageWithGuid(JsonMessageID.RequestDareResult);

            rdMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_RequestDareResult protoData = new ArkCrossEngineMessage.Msg_LC_RequestDareResult();
            protoData.m_Nickname = nickname;
            protoData.m_Result   = (int)result;
            rdMsg.m_ProtoData    = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, rdMsg);
        }
예제 #14
0
        //响应RoomServer玩家重新连接进入房间的反馈消息
        internal void OnReplyReconnectUser(ulong userGuid, int roomID, bool isSuccess)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);

            if (user == null)
            {
                return;
            }
            if (isSuccess)
            {
                user.CurrentState = UserState.Room;
                RoomInfo room = m_LobbyInfo.GetRoomByID(roomID);
                if (null != room)
                {
                    RoomServerInfo svrInfo;
                    if (m_LobbyInfo.RoomServerInfos.TryGetValue(room.RoomServerName, out svrInfo))
                    {
                        if (null != svrInfo)
                        {
                            JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                            startGameResultMsg.m_Guid = user.Guid;
                            ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                            protoData.server_ip   = svrInfo.ServerIp;
                            protoData.server_port = svrInfo.ServerPort;
                            protoData.key         = user.Key;
                            protoData.hero_id     = user.HeroId;
                            protoData.camp_id     = user.CampId;
                            protoData.scene_type  = room.SceneType;
                            protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                            protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                            startGameResultMsg.m_ProtoData = protoData;
                            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                            //重新进入房间成功
                            LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Success ! , guid:{0}", userGuid);
                        }
                    }
                }
            }
            else
            {
                user.CurrentState = UserState.Online;

                LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Failed ! , guid:{0}", userGuid);
            }
        }
예제 #15
0
 internal void HandleExchangeGift(ulong userGuid, string giftcode)
 {
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);
     if (user == null)
     {
         return;
     }
     int giftId = 0;
     GeneralOperationResult ret = m_GiftCodeSystem.ExchangeGift(userGuid, giftcode, out giftId);
     JsonMessageWithGuid jsonMsg = new JsonMessageWithGuid(JsonMessageID.ExchangeGiftResult);
     jsonMsg.m_Guid = userGuid;
     ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult protoData = new ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult();
     protoData.m_GiftId = giftId;
     protoData.m_Result = (int)ret;
     jsonMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, jsonMsg);
 }
예제 #16
0
        private void ProvideGowPrize(ulong guid, GowPrizeConfig cfg)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user      = scheduler.GetUserInfo(guid);

            if (null == user)
            {
                return;
            }
            JsonMessageWithGuid pgpMsg = new JsonMessageWithGuid(JsonMessageID.RequestGowPrize);

            pgpMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult protoData = new ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult();
            if (user.GowInfo.IsAcquirePrize)
            {
                protoData.m_Result = (int)GeneralOperationResult.LC_Failure_Unknown;
            }
            else
            {
                int money_incr = cfg.Money;
                int gold_incr  = cfg.Gold;
                protoData.m_Money = money_incr;
                protoData.m_Gold  = gold_incr;
                scheduler.DispatchAction(scheduler.DoAddAssets, guid, money_incr, gold_incr, 0, 0, GainConsumePos.Gow.ToString());
                if (null != cfg.Items && cfg.Items.Count > 0)
                {
                    for (int i = 0; i < cfg.Items.Count; ++i)
                    {
                        GowPrizeItem item = cfg.Items[i];
                        if (null != item)
                        {
                            scheduler.DispatchAction(scheduler.DoAddItem, guid, item.ItemId, item.ItemNum, GainConsumePos.Gow.ToString());
                            ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult.AwardItemInfo itemDataMsg =
                                new ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult.AwardItemInfo();
                            itemDataMsg.m_Id  = item.ItemId;
                            itemDataMsg.m_Num = item.ItemNum;
                            protoData.m_Items.Add(itemDataMsg);
                        }
                    }
                }
                protoData.m_Result          = (int)GeneralOperationResult.LC_Succeed;
                user.GowInfo.IsAcquirePrize = true;
            }
            pgpMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, pgpMsg);
        }
예제 #17
0
        internal void HandleArenaStartChallenge(ulong guid, ulong target_guid)
        {
            LogSys.Log(LOG_TYPE.DEBUG, "---got start challenge result msg! id=" + guid);
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
            if (user == null)
            {
                return;
            }
            ArenaInfo target_arena_info = m_ArenaSystem.GetArenaInfoById(target_guid);

            JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaStartChallengeResult);
            resultMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult();
            protoData.m_TargetGuid = target_guid;
            protoData.m_Sign = new Random().Next();
            if (target_arena_info != null && target_arena_info.IsNeedUpdate(user))
            {
                target_arena_info.UpdateArenaInfo(user);
            }
            bool start_ret = m_ArenaSystem.StartChallenge(guid, target_guid, protoData.m_Sign);
            if (target_arena_info == null)
            {
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
            }
            else if (!start_ret)
            {
                protoData.m_ResultCode = (int)m_ArenaSystem.ErrorCode;
            }
            else
            {
                user.UpdateGuideFlag((int)MatchSceneEnum.Arena);
                user.CurrentState = UserState.Pve;
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Succeed;
                ChallengeInfo challenge = m_ArenaSystem.GetDoingChallengeInfo(guid);
                if (challenge != null && challenge.Target != null)
                {
                    float coefficent = ChallengeChecker.CalcPvpCoefficient(user.Level, target_arena_info.Level);
                    int total_hp = ChallengeChecker.CalcPlayerHp(target_arena_info, coefficent);
                    challenge.Target.TotalHp = total_hp;
                    //LogSys.Log(LOG_TYPE.DEBUG, "challenge target totalhp={0}", total_hp);
                }
            }
            resultMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
            LogSys.Log(LOG_TYPE.DEBUG, "---send start challenge result msg! id=" + guid);
        }
예제 #18
0
 internal void HandleArenaQueryRank(ulong guid, int handle)
 {
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryRankResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult();
     ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (cur_info != null)
     {
         List<ArenaInfo> result = m_ArenaSystem.QueryRankList(cur_info.GetRank());
         for (int i = 0; i < result.Count; i++)
         {
             protoData.RankMsg.Add(ArenaUtil.CreateArenaInfoMsg(result[i]));
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "send query rank list!");
 }
예제 #19
0
        internal void CheckAndSyncMissions(UserInfo user, StageClearInfo info = null)
        {
            List <int> completedMissions = new List <int>();

            OnStageClear(user, info, ref completedMissions);
            foreach (int missionId in completedMissions)
            {
                JsonMessageWithGuid missionCompletedMsg = new JsonMessageWithGuid(JsonMessageID.MissionCompleted);
                missionCompletedMsg.m_Guid = user.Guid;
                ArkCrossEngineMessage.Msg_LC_MissionCompleted missionProtoData = new ArkCrossEngineMessage.Msg_LC_MissionCompleted();
                if (null != missionProtoData)
                {
                    missionProtoData.m_MissionId    = missionId;
                    missionProtoData.m_Progress     = MissionSystem.Instance.GetMissionProgress(user, missionId, true);
                    missionCompletedMsg.m_ProtoData = missionProtoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, missionCompletedMsg);
                }
            }
        }
예제 #20
0
 internal void HandleArenaQueryHistory(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena query history!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryHistoryResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaQueryHistoryResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryHistoryResult();
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     List<ChallengeInfo> history = m_ArenaSystem.QueryHistory(guid);
     if (history != null)
     {
         foreach (ChallengeInfo info in history)
         {
             ArkCrossEngineMessage.ChallengeInfoData info_data = ArenaUtil.CreateChallengeInfoData(info);
             protoData.ChallengeHistory.Add(info_data);
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena query history result!");
 }
예제 #21
0
 ///=====================================================================================================
 /// 这里定义供其它线程通过QueueAction调用的函数,实际执行线程是GmServerThread。
 ///=====================================================================================================
 internal void GMPQueryUser(ulong userGuid, ulong targetGuid, int handle)
 {
     if (true == m_GmSeverAvailable)
     {
         GMPQueryUser(targetGuid, (GMPLoadUserCB)((ret, data) =>
         {
             JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.GmQueryInfoByGuidOrNickname);
             resultMsg.m_Guid = userGuid;
             ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname protoData = new ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname();
             protoData.m_Result = 1;
             if (ret == DSLoadResult.Success)
             {
                 DS_UserInfo dataUser = data.UserBasic;
                 protoData.m_Info = UserInfoBuilder(dataUser);
                 protoData.m_Result = (int)ret;
                 resultMsg.m_ProtoData = protoData;
             }
             JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
         }));
     }
 }
예제 #22
0
 internal void HandleArenaChangePartners(ulong guid, int handle, List<int> partners)
 {
     //TODO: refresh user info to arenainfo
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaChangePartnersResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaChangePartnerResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaChangePartnerResult();
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         protoData.Result = (int)GeneralOperationResult.LC_Failure_NotFinduser;
     }
     else
     {
         ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid);
         int count = m_ArenaSystem.GetMaxPartnerCount(user.Level);
         if (partners.Count > count)
         {
             protoData.Result = (int)GeneralOperationResult.LC_Failure_LevelError;
         }
         else
         {
             cur_info.FightPartners.Clear();
             for (int i = 0; i < partners.Count; i++)
             {
                 int partnerid = partners[i];
                 PartnerInfo partner = user.PartnerStateInfo.GetPartnerInfoById(partnerid);
                 cur_info.FightPartners.Add(partner);
                 protoData.Partners.Add(partnerid);
             }
             protoData.Result = (int)GeneralOperationResult.LC_Succeed;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "send change partners result!");
 }
예제 #23
0
        private void SyncCombatData(UserInfo ui)
        {
            JsonMessageWithGuid syncCombatDataMsg = new JsonMessageWithGuid(JsonMessageID.SyncCombatData);

            syncCombatDataMsg.m_Guid = ui.Guid;
            ArkCrossEngineMessage.Msg_LC_SyncCombatData protoData = new ArkCrossEngineMessage.Msg_LC_SyncCombatData();
            int legacyCount = ui.Legacy.SevenArcs.Length;

            if (legacyCount > 0)
            {
                for (int i = 0; i < legacyCount; ++i)
                {
                    ArkCrossEngineMessage.LegacyDataMsg legacy_data = new ArkCrossEngineMessage.LegacyDataMsg();
                    legacy_data.ItemId         = ui.Legacy.SevenArcs[i].ItemId;
                    legacy_data.Level          = ui.Legacy.SevenArcs[i].Level;
                    legacy_data.AppendProperty = ui.Legacy.SevenArcs[i].AppendProperty;
                    legacy_data.IsUnlock       = ui.Legacy.SevenArcs[i].IsUnlock;
                    protoData.m_Legacys.Add(legacy_data);
                }
            }
            foreach (ItemInfo item in ui.XSoul.GetAllXSoulPartData().Values)
            {
                ArkCrossEngineMessage.XSoulDataMsg item_msg = new ArkCrossEngineMessage.XSoulDataMsg();
                item_msg.ItemId     = item.ItemId;
                item_msg.Level      = item.Level;
                item_msg.Experience = item.Experience;
                item_msg.ModelLevel = item.ShowModelLevel;
                protoData.m_XSouls.Add(item_msg);
            }
            for (int i = 0; i < ui.Skill.Skills.Count; ++i)
            {
                if (ui.Skill.Skills[i].Postions.Presets[0] != SlotPosition.SP_None)
                {
                    ArkCrossEngineMessage.SkillDataInfo skill_data = new ArkCrossEngineMessage.SkillDataInfo();
                    skill_data.ID       = ui.Skill.Skills[i].ID;
                    skill_data.Level    = ui.Skill.Skills[i].Level;
                    skill_data.Postions = (int)ui.Skill.Skills[i].Postions.Presets[0];
                    protoData.m_Skills.Add(skill_data);
                }
            }
            for (int i = 0; i < ui.Equip.Armor.Length; ++i)
            {
                if (null != ui.Equip.Armor[i])
                {
                    ArkCrossEngineMessage.ItemDataMsg equip = new ArkCrossEngineMessage.ItemDataMsg();
                    equip.ItemId         = ui.Equip.Armor[i].ItemId;
                    equip.Level          = ui.Equip.Armor[i].Level;
                    equip.AppendProperty = ui.Equip.Armor[i].AppendProperty;
                    protoData.m_Equipments.Add(equip);
                }
            }
            ArkCrossEngineMessage.SelectedPartnerDataMsg partnerData = new ArkCrossEngineMessage.SelectedPartnerDataMsg();
            PartnerInfo partnerInfo = ui.PartnerStateInfo.GetActivePartner();

            if (null != partnerInfo)
            {
                partnerData.m_Id            = partnerInfo.Id;
                partnerData.m_SkillStage    = partnerInfo.CurSkillStage;
                partnerData.m_AdditionLevel = partnerInfo.CurAdditionLevel;
            }
            else
            {
                partnerData.m_Id            = 0;
                partnerData.m_SkillStage    = 0;
                partnerData.m_AdditionLevel = 0;
            }
            protoData.m_PartnerData       = partnerData;
            syncCombatDataMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(ui.NodeName, syncCombatDataMsg);
        }
예제 #24
0
        internal void ProcessBattleResult(List <UserInfo> users)
        {
            //gow旧积分缓存
            int ct = users.Count;

            int[] oldElos = null;
            if (m_SceneType == (int)MatchSceneEnum.Gow || (int)MatchSceneEnum.Dare == m_SceneType)
            {
                oldElos = new int[ct];
                int ix = 0;
                foreach (UserInfo user in users)
                {
                    if (user != null)
                    {
                        if (ix < ct)
                        {
                            oldElos[ix] = user.GowInfo.GowElo;
                            ++ix;
                        }
                    }
                }
            }

            //计算战斗结果
            UserInfo win = null, lost = null;

            foreach (UserInfo user in users)
            {
                if (user != null)
                {
                    //当前战斗数据
                    user.CurrentBattleInfo.SceneID = this.SceneType;
                    user.CurrentBattleInfo.EndTime = TimeUtility.GetServerMilliseconds();
                    if (user.CurrentBattleInfo.BattleResult == BattleResultEnum.Win)
                    {
                        win = user;
                    }
                    else if (user.CurrentBattleInfo.BattleResult == BattleResultEnum.Lost)
                    {
                        lost = user;
                    }
                }
            }
            if (m_SceneType == (int)MatchSceneEnum.Gow && null != win && null != lost)
            {
                CalcGowElo(win, lost);
                ++win.GowInfo.GowMatches;
                ++lost.GowInfo.GowMatches;
                ++win.GowInfo.GowWinMatches;
                GlobalDataProcessThread globalDataThread = LobbyServer.Instance.GlobalDataProcessThread;
                globalDataThread.QueueAction(globalDataThread.UpdateGowElo, win, lost);
            }

            //发送战斗结果数据
            if ((int)MatchSceneEnum.Gow == m_SceneType || (int)MatchSceneEnum.Dare == m_SceneType)
            {
                //todo:进一步根据场景ID区分是何种类型的pvp
                JsonMessageWithGuid gowResultMsg = new JsonMessageWithGuid(JsonMessageID.SyncGowBattleResult);
                ArkCrossEngineMessage.Msg_LC_SyncGowBattleResult protoData = new ArkCrossEngineMessage.Msg_LC_SyncGowBattleResult();
                string[] nicks     = new string[ct];
                int[]    heros     = new int[ct];
                int[]    elos      = new int[ct];
                int[]    hitcounts = new int[ct];
                int[]    damages   = new int[ct];
                int      ix        = 0;
                foreach (UserInfo user in users)
                {
                    if (user != null)
                    {
                        if (ix < ct)
                        {
                            nicks[ix]     = user.Nickname;
                            heros[ix]     = user.HeroId;
                            elos[ix]      = user.GowInfo.GowElo;
                            hitcounts[ix] = user.CurrentBattleInfo.MaxMultiHitCount;
                            damages[ix]   = user.CurrentBattleInfo.TotalDamageFromMyself;
                            ++ix;
                        }
                    }
                }
                ix = 0;
                foreach (UserInfo user in users)
                {
                    if (user != null)
                    {
                        gowResultMsg.m_Guid = user.Guid;
                        protoData.m_Result  = (int)user.CurrentBattleInfo.BattleResult;
                        if (ix < ct)
                        {
                            protoData.m_OldGowElo             = oldElos[ix];
                            protoData.m_GowElo                = elos[ix];
                            protoData.m_MaxMultiHitCount      = hitcounts[ix];
                            protoData.m_TotalDamage           = damages[ix];
                            protoData.m_EnemyNick             = nicks[ct - ix - 1];
                            protoData.m_EnemyHeroId           = heros[ct - ix - 1];
                            protoData.m_EnemyOldGowElo        = oldElos[ct - ix - 1];
                            protoData.m_EnemyGowElo           = elos[ct - ix - 1];
                            protoData.m_EnemyMaxMultiHitCount = hitcounts[ct - ix - 1];
                            protoData.m_EnemyTotalDamage      = damages[ct - ix - 1];
                            ++ix;
                        }
                        gowResultMsg.m_ProtoData = protoData;
                        JsonMessageDispatcher.SendDcoreMessage(user.NodeName, gowResultMsg);
                        if ((int)MatchSceneEnum.Gow == m_SceneType)
                        {
                            LogSys.Log(LOG_TYPE.INFO, "Send Pvp Battle Result to User:{0}, User data Count: {1}", user.Guid, m_Users.Count);
                        }
                        else
                        {
                            LogSys.Log(LOG_TYPE.INFO, "Send Dare Battle Result to User:{0}, User data Count: {1}", user.Guid, m_Users.Count);
                        }
                    }
                }
                ///
                if ((int)MatchSceneEnum.Gow == m_SceneType)
                {
                    RecordPvpAction(win, lost);
                }
            }
            else
            {
                //发送多人pve结束消息
                JsonMessageWithGuid mpveResultMsg = new JsonMessageWithGuid(JsonMessageID.SyncMpveBattleResult);
                ArkCrossEngineMessage.Msg_LC_SyncMpveBattleResult protoData = new ArkCrossEngineMessage.Msg_LC_SyncMpveBattleResult();
                foreach (UserInfo user in users)
                {
                    if (user != null)
                    {
                        mpveResultMsg.m_Guid      = user.Guid;
                        protoData.m_Result        = (int)user.CurrentBattleInfo.BattleResult;
                        protoData.m_KillNpcCount  = user.CurrentBattleInfo.KillNpcCount;
                        mpveResultMsg.m_ProtoData = protoData;
                        JsonMessageDispatcher.SendDcoreMessage(user.NodeName, mpveResultMsg);
                        LogSys.Log(LOG_TYPE.INFO, "Send Pve Battle Result to User:{0}, User data Count: {1}", user.Guid, m_Users.Count);
                    }
                }
            }
        }
예제 #25
0
        internal void Tick()
        {
            if (this.CurrentState == RoomState.End)
            {
                //游戏结束状态:检测数据存储是否完成
                //等待每个玩家游戏数据存储完成后,将房间状态改为Close关闭状态
                int count = 0;
                foreach (bool flag in m_UserDSFlags.Values)
                {
                    if (flag == true)
                    {
                        count++;
                    }
                }
                if (count == m_UserDSFlags.Count)
                {
                    m_UserDSFlags.Clear();
                    this.CloseRoom();
                }
            }
            //清除不在游戏中的玩家数据
            if (UserCount > 0)
            {
                m_RecycledGuids.Clear();
                foreach (KeyValuePair <ulong, WeakReference> pair in m_Users)
                {
                    ulong    guid = pair.Key;
                    UserInfo info = pair.Value.Target as UserInfo;
                    if (info == null || info.IsRecycled || info.CurrentState == UserState.DropOrOffline || info.Guid != guid)
                    {
                        m_RecycledGuids.Add(guid);
                        LogSys.Log(LOG_TYPE.DEBUG, "Room {0} has a exception user {1} !!!", m_RoomId, guid);
                    }
                }
                if (m_RecycledGuids.Count > 0)
                {
                    foreach (ulong guid in m_RecycledGuids)
                    {
                        m_Users.Remove(guid);
                    }
                    UpdateUserCount();
                }
            }
            //准备过程处理
            if (!m_IsPrepared)
            {
                if (UserCount > 0)
                {
                    long curTime = TimeUtility.GetServerMilliseconds();
                    bool canLog  = false;
                    if (m_LastLogTime + 1000 < curTime)
                    {
                        m_LastLogTime = curTime;
                        canLog        = true;
                    }
                    if (canLog)
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "Room {0} will on {1}", m_RoomId, m_RoomServerName);
                    }
                    foreach (KeyValuePair <ulong, WeakReference> pair in m_Users)
                    {
                        ulong    guid = pair.Key;
                        UserInfo info = pair.Value.Target as UserInfo;
                        if (info != null)
                        {
                            if (info.LastNotifyMatchTime + 5000 < curTime)
                            {
                                info.LastNotifyMatchTime = curTime;

                                JsonMessageWithGuid mrMsg = new JsonMessageWithGuid(JsonMessageID.MatchResult);
                                mrMsg.m_Guid = guid;
                                ArkCrossEngineMessage.Msg_LC_MatchResult protoData = new ArkCrossEngineMessage.Msg_LC_MatchResult();
                                protoData.m_Result = (int)TeamOperateResult.OR_Succeed;
                                mrMsg.m_ProtoData  = protoData;
                                JsonMessageDispatcher.SendDcoreMessage(info.NodeName, mrMsg);
                            }

                            if (canLog)
                            {
                                LogSys.Log(LOG_TYPE.DEBUG, "==>User(guid:{0} acc:{1} key:{2}) State {3} key guid:{4}", info.Guid, info.AccountId, info.Key, info.IsPrepared, guid);
                            }
                        }
                        else
                        {
                            if (canLog)
                            {
                                LogSys.Log(LOG_TYPE.DEBUG, "==>Oops, a null user, ignore him !!!");
                            }
                        }
                    }
                    //检查成员状态,如果都准备好则通知RoomServer创建副本
                    bool isOk = true;
                    foreach (KeyValuePair <ulong, WeakReference> pair in m_Users)
                    {
                        ulong    guid = pair.Key;
                        UserInfo info = pair.Value.Target as UserInfo;
                        if (info != null && !info.IsPrepared && guid == info.Guid)
                        {
                            isOk = false;
                            break;
                        }
                    }
                    if (isOk)
                    {
                        m_IsPrepared = true;
                        Msg_LR_CreateBattleRoom.Builder cbrBuilder = Msg_LR_CreateBattleRoom.CreateBuilder();
                        cbrBuilder.SetRoomId(RoomId);
                        cbrBuilder.SetSceneType(SceneType);
                        foreach (KeyValuePair <ulong, WeakReference> pair in m_Users)
                        {
                            ulong    guid = pair.Key;
                            UserInfo info = pair.Value.Target as UserInfo;
                            if (info != null && guid == info.Guid)
                            {
                                Msg_LR_RoomUserInfo.Builder ruiBuilder = Msg_LR_RoomUserInfo.CreateBuilder();
                                ruiBuilder.SetGuid(info.Guid);
                                ruiBuilder.SetNick(info.Nickname);
                                ruiBuilder.SetKey(info.Key);
                                ruiBuilder.SetHero(info.HeroId);
                                ruiBuilder.SetCamp(info.CampId);
                                ruiBuilder.SetIsMachine(info.IsMachine);
                                ruiBuilder.SetLevel(info.Level);
                                int arg_score = info.FightingScore;
                                if (null != info.Group && null != info.Group.Members)
                                {
                                    foreach (GroupMemberInfo m in info.Group.Members)
                                    {
                                        UserInfo member = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(m.Guid);
                                        if (null != member && member.Guid != guid)
                                        {
                                            if (member.FightingScore > arg_score)
                                            {
                                                arg_score = member.FightingScore;
                                            }
                                        }
                                    }
                                }
                                arg_score = (int)(arg_score * 0.8);
                                ruiBuilder.SetArgScore(arg_score);
                                ///
                                Msg_LR_RoomUserInfo.Types.SkillInfo.Builder[] skill_assit = new Msg_LR_RoomUserInfo.Types.SkillInfo.Builder[4];
                                for (int i = 0; i < skill_assit.Length; i++)
                                {
                                    skill_assit[i] = Msg_LR_RoomUserInfo.Types.SkillInfo.CreateBuilder();
                                    skill_assit[i].SetSkillId(0);
                                    skill_assit[i].SetSkillLevel(0);
                                }
                                if (null != info.Skill && null != info.Skill.Skills)
                                {
                                    int cur_preset_index = info.Skill.CurPresetIndex;
                                    if (cur_preset_index >= 0)
                                    {
                                        for (int i = 0; i < skill_assit.Length; i++)
                                        {
                                            for (int j = 0; j < info.Skill.Skills.Count; j++)
                                            {
                                                if (info.Skill.Skills[j].Postions.Presets[cur_preset_index] == (SlotPosition)(i + 1))
                                                {
                                                    skill_assit[i].SetSkillId(info.Skill.Skills[j].ID);
                                                    skill_assit[i].SetSkillLevel(info.Skill.Skills[j].Level);
                                                    break;
                                                }
                                            }
                                        }
                                        for (int i = 0; i < skill_assit.Length; i++)
                                        {
                                            ruiBuilder.SkillsList.Add(skill_assit[i].Build());
                                        }
                                        ruiBuilder.SetPresetIndex(cur_preset_index);
                                    }
                                }
                                ///
                                if (null != info.Equip && null != info.Equip.Armor)
                                {
                                    for (int i = 0; i < info.Equip.Armor.Length; i++)
                                    {
                                        Msg_LR_RoomUserInfo.Types.EquipInfo.Builder equip_assit = Msg_LR_RoomUserInfo.Types.EquipInfo.CreateBuilder();
                                        equip_assit.SetEquipId(info.Equip.Armor[i].ItemId);
                                        equip_assit.SetEquipLevel(info.Equip.Armor[i].Level);
                                        equip_assit.SetEquipRandomProperty(info.Equip.Armor[i].AppendProperty);
                                        ruiBuilder.EquipsList.Add(equip_assit.Build());
                                    }
                                }
                                ///
                                if (null != info.Legacy && null != info.Legacy.SevenArcs)
                                {
                                    for (int i = 0; i < info.Legacy.SevenArcs.Length; i++)
                                    {
                                        Msg_LR_RoomUserInfo.Types.LegacyInfo.Builder legacy_assit = Msg_LR_RoomUserInfo.Types.LegacyInfo.CreateBuilder();
                                        legacy_assit.SetLegacyId(info.Legacy.SevenArcs[i].ItemId);
                                        legacy_assit.SetLegacyLevel(info.Legacy.SevenArcs[i].Level);
                                        legacy_assit.SetLegacyRandomProperty(info.Legacy.SevenArcs[i].AppendProperty);
                                        legacy_assit.SetLegacyIsUnlock(info.Legacy.SevenArcs[i].IsUnlock);
                                        ruiBuilder.LegacysList.Add(legacy_assit.Build());
                                    }
                                }
                                ///
                                if (null != info.XSoul)
                                {
                                    foreach (ItemInfo item in info.XSoul.GetAllXSoulPartData().Values)
                                    {
                                        Msg_LR_RoomUserInfo.Types.XSoulDataInfo.Builder xsoul_msg = Msg_LR_RoomUserInfo.Types.XSoulDataInfo.CreateBuilder();
                                        xsoul_msg.ItemId     = item.ItemId;
                                        xsoul_msg.Level      = item.Level;
                                        xsoul_msg.ModelLevel = item.ShowModelLevel;
                                        xsoul_msg.Experience = item.Experience;
                                        ruiBuilder.XSoulsList.Add(xsoul_msg.Build());
                                    }
                                }
                                // partner
                                PartnerInfo partnerInfo = info.PartnerStateInfo.GetActivePartner();
                                if (null != partnerInfo)
                                {
                                    Msg_LR_RoomUserInfo.Types.PartnerInfo.Builder partner = Msg_LR_RoomUserInfo.Types.PartnerInfo.CreateBuilder();
                                    partner.SetPartnerId(partnerInfo.Id);
                                    partner.SetPartnerLevel(partnerInfo.CurAdditionLevel);
                                    partner.SetPartnerStage(partnerInfo.CurSkillStage);
                                    ruiBuilder.SetPartner(partner);
                                }
                                cbrBuilder.AddUsers(ruiBuilder.Build());
                            }
                        }
                        //sirius TODO:在此处确定要连接的RoomServer
                        LobbyServer.Instance.RoomSvrChannel.Send(m_RoomServerName, cbrBuilder.Build());
                        this.CurrentState = RoomState.Start;  //房间启动状态
                        this.StartTime    = DateTime.Now;
                        LogSys.Log(LOG_TYPE.INFO, "Multi Play Room will run on Roomserver {0} roomid {1} scene {2} for {3} users ...", m_RoomServerName, RoomId, SceneType, UserCount);
                    }
                }
            }
        }
예제 #26
0
        internal void RequestSinglePVE(ulong guid, int sceneId)
        {
            Data_SceneConfig cfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);

            if (null == cfg || cfg.m_Type == (int)SceneTypeEnum.TYPE_PVE)
            {
                //单人pve不建立房间,直接开始游戏(todo:奖励记到人身上[多人的奖励也是这样])
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                UserInfo             user        = dataProcess.GetUserInfo(guid);
                if (user != null)
                {
                    user.CurrentBattleInfo.init(sceneId, user.HeroId);
                    SyncCombatData(user);
                    JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                    startGameResultMsg.m_Guid = user.Guid;
                    ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                    GeneralOperationResult result = GeneralOperationResult.LC_Succeed;
                    if (user.CurStamina >= cfg.m_CostStamina)
                    {
                        if (!GlobalVariables.Instance.IsDebug)
                        {
                            int preSceneId = SceneConfigProvider.Instance.GetPreSceneId(sceneId);
                            if (-1 != preSceneId)
                            {
                                if (!user.SceneData.ContainsKey(preSceneId))
                                {
                                    LogSystem.Error("player {0} try to enter an Illegal scene {1}", user.Guid, sceneId);
                                    return;
                                }
                            }
                            if (cfg.m_SubType == (int)SceneSubTypeEnum.TYPE_ELITE && user.GetCompletedSceneCount(sceneId) >= user.MaxEliteSceneCompletedCount)
                            {
                                LogSystem.Error("player {0} enter an Elite scene {1} too many times {2}", user.Guid, sceneId, user.GetCompletedSceneCount(sceneId));
                                return;
                            }
                        }
                        protoData.server_ip   = "127.0.0.1";
                        protoData.server_port = 9001;
                        protoData.key         = user.Key;
                        protoData.hero_id     = user.HeroId;
                        protoData.camp_id     = (int)CampIdEnum.Blue;
                        protoData.scene_type  = sceneId;
                        protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                        result            = GeneralOperationResult.LC_Succeed;
                        user.CurrentState = UserState.Pve;
                    }
                    else
                    {
                        result = GeneralOperationResult.LC_Failure_CostError;
                    }
                    protoData.result = (int)result;
                    startGameResultMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                    LogSys.Log(LOG_TYPE.INFO, "Single Player Room will run on Lobby without room and roomserver, user {0} scene {1}", guid, sceneId);
                    /// norm log
                    AccountInfo accountInfo = dataProcess.FindAccountInfoById(user.AccountId);
                    if (null != accountInfo)
                    {
                        /// pvefight
                        LogSys.NormLog("PVEfight", LobbyConfig.AppKeyStr, accountInfo.ClientGameVersion, Module.pvefight, LobbyConfig.LogNormVersionStr,
                                       "B4110", accountInfo.LogicServerId, accountInfo.AccountId, user.Guid, user.Level, sceneId, (int)FightingType.General, "null",
                                       (int)PvefightResult.Failure, "null", "null");
                    }
                }
            }
        }