Esempio n. 1
0
        protected override void TakeRemote()
        {
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            psp.SetUser(m_RequestPacket.PlayerId);
            psp.DealPvpResult(m_RequestPacket.Result, m_RequestPacket.Score);
            m_ResponsePacket.Score    = psp.MyPvp.SinglePvpScore;
            m_ResponsePacket.PlayerId = m_RequestPacket.PlayerId;
            PlayerSinglePvpLogic.RefreshRank();
        }
Esempio n. 2
0
        protected override void TakeRemote()
        {
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            for (int i = 0; i < m_RequestPacket.PlayerIds.Count; i++)
            {
                psp.SetUser(m_RequestPacket.PlayerIds[i]);
                //psp.DealPvpResult(m_RequestPacket.HasWon[i]);
            }
            PlayerSinglePvpLogic.RefreshRank();
        }
Esempio n. 3
0
        public override bool TakeAction()
        {
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            psp.SetUser(m_UserId);
            var rank = RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking").Find(u => u.UserId == m_UserId);

            if (rank == null)
            {
                m_ResponsePacket.Score = 0;
                m_ResponsePacket.Rank  = -1;
            }
            else
            {
                m_ResponsePacket.Score = rank.Score;
                m_ResponsePacket.Rank  = rank.RankId;
            }
            m_ResponsePacket.ChallengeCount = psp.MyPvp.RemainingCount;
            m_ResponsePacket.Season         = PVPLogic.GetSeasonId();
            return(true);
        }
Esempio n. 4
0
        public static void ExecuteMatch(object state)
        {
            var queues = CacheSet.PVPMathcQueueCache.FindAll();
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            foreach (var queue in queues)
            {
                if (queue.InQueueGroups.Count <= 1)
                {
                    continue;
                }
                if (queue.MatchedGroupCount > 0)
                {
                    ClearMatchedGroups(queue);
                }
                var groups = new List <PVPGroup>();
                groups.AddRange(queue.InQueueGroups);
                groups.Sort();
                for (int i = 0; i < groups.Count; i++)
                {
                    if (i + 1 >= groups.Count)
                    {
                        break;
                    }
                    bool            success  = true;
                    LRCreateNewRoom userData = new LRCreateNewRoom();
                    foreach (int playerId in groups[i].Players)
                    {
                        if (!GameSession.Get(playerId).Connected)
                        {
                            queue.InQueueGroups.RemoveAt(i);
                            success = false;
                            break;
                        }
                        PBRoomPlayerInfo playerRoomData = GetPlayerRoomData(playerId);
                        userData.RoomPlayerInfo.Add(playerRoomData);
                    }
                    if (!success)
                    {
                        continue;
                    }
                    foreach (int playerId in groups[++i].Players)
                    {
                        if (!GameSession.Get(playerId).Connected)
                        {
                            queue.InQueueGroups.RemoveAt(i);
                            success = false;
                            break;
                        }
                        PBRoomPlayerInfo playerRoomData = GetPlayerRoomData(playerId);
                        userData.RoomPlayerInfo.Add(playerRoomData);
                    }
                    if (!success)
                    {
                        continue;
                    }

                    userData.Token = GetToken();

                    var room = RoomServerManager.GetLowestLoadedRoomServer();
                    TraceLog.Write("room" + room.Id.ToString() + "::" + room.IP);
                    RoomServerSender.Send(room.Id, "LRCreateNewRoomHandler", userData, delegate(RemotePackage callback)
                    {
                        var res = RemoteCommunication.ParseRemotePackage <RLCreateNewRoom>(callback.Message as byte[]);
                        LCPushPvpMatchSuccess package = new LCPushPvpMatchSuccess()
                        {
                            RoomId = res.RoomId, RoomServerHost = room.Host, RoomServerPort = room.Port, Token = userData.Token, InstanceId = res.InstanceId
                        };
                        var rank = RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking");

                        foreach (int playerId in groups[queue.MatchedGroupCount].Players)
                        {
                            foreach (var rp in userData.RoomPlayerInfo)
                            {
                                if (rp.PlayerInfo.Id != playerId)
                                {
                                    package.EnemyInfo = rp;
                                }
                            }
                            byte[] buffer = CustomActionDispatcher.GeneratePackageStream(package.PacketActionId, ProtoBufUtils.Serialize(package));

                            try
                            {
                                GameSession.Get(playerId).SendAsync(buffer, 0, buffer.Length);
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        foreach (int playerId in groups[queue.MatchedGroupCount + 1].Players)
                        {
                            foreach (var rp in userData.RoomPlayerInfo)
                            {
                                if (rp.PlayerInfo.Id != playerId)
                                {
                                    package.EnemyInfo = rp;
                                }
                            }
                            byte[] buffer = CustomActionDispatcher.GeneratePackageStream(package.PacketActionId, ProtoBufUtils.Serialize(package));
                            try
                            {
                                GameSession.Get(playerId).SendAsync(buffer, 0, buffer.Length);
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        queue.MatchedGroupCount += 2;
                    });
                }
                ClearMatchedGroups(queue);
            }
        }
Esempio n. 5
0
        private static PBRoomPlayerInfo GetPlayerRoomData(int playerId)
        {
            PBRoomPlayerInfo retData = new PBRoomPlayerInfo();
            PlayerLogic      p       = new PlayerLogic();

            p.SetUser(playerId);
            retData.PlayerInfo = new PBPlayerInfo()
            {
                Id           = playerId,
                Name         = p.MyPlayer.Name,
                Level        = p.MyPlayer.Level,
                VipLevel     = p.MyPlayer.VIPLevel,
                PortraitType = p.MyPlayer.PortraitType,
                Might        = p.MyPlayer.Might,
            };
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(playerId);
            CacheList <int> team = heroTeam.GetTeam();
            PlayerHeroLogic ph   = new PlayerHeroLogic().SetUser(playerId);

            foreach (int heroType in team)
            {
                if (heroType == 0)
                {
                    continue;
                }
                ph.SetHero(heroType);
                var             heroInfo      = ph.GetHeroInfo();
                PBLobbyHeroInfo lobbyHeroInfo = new PBLobbyHeroInfo();
                lobbyHeroInfo.Type               = heroInfo.HeroType;
                lobbyHeroInfo.Level              = heroInfo.HeroLv;
                lobbyHeroInfo.Exp                = heroInfo.HeroExp;
                lobbyHeroInfo.StarLevel          = heroInfo.HeroStarLevel;
                lobbyHeroInfo.ConsciousnessLevel = heroInfo.ConsciousnessLevel;
                lobbyHeroInfo.ElevationLevel     = heroInfo.ElevationLevel;
                lobbyHeroInfo.SkillLevels.AddRange(heroInfo.SkillLevels);
                foreach (var gear in heroInfo.Gears)
                {
                    if (gear.Value == 0)
                    {
                        continue;
                    }
                    PBGearInfo gearInfo = new PBGearInfo();
                    gearInfo.Id = gear.Value;
                    Gears gearData = CacheSet.GearCache.FindKey(gear.Value);
                    gearInfo.Level           = gearData.Level;
                    gearInfo.Type            = gearData.TypeId;
                    gearInfo.StrengthenLevel = gearData.StrengthenLevel;
                    lobbyHeroInfo.GearInfo.Add(gearInfo);
                }
                foreach (var soul in heroInfo.Souls)
                {
                    if (soul.Value == 0)
                    {
                        continue;
                    }
                    PBSoulInfo soulInfo = new PBSoulInfo();
                    soulInfo.Id = soul.Value;
                    Souls soulData = CacheSet.SoulCache.FindKey(soul.Value);
                    soulInfo.Type = soulData.TypeId;
                    lobbyHeroInfo.SoulInfo.Add(soulInfo);
                }
                PBRoomHeroInfo roomHeroInfo = new PBRoomHeroInfo()
                {
                    LobbyHeroInfo = lobbyHeroInfo,
                };
                retData.RoomHeroInfo.Add(roomHeroInfo);
            }
            retData.LobbyServerId = int.Parse(ConfigUtils.GetSetting("Server.Id"));
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            psp.SetUser(playerId);
            retData.Score = psp.MyPvp.SinglePvpScore;
            return(retData);
        }