protected override void TakeRemote() { PvpPlayer player1 = null; PvpPlayer player2 = null; if (m_RequestPacket.PlayerIds.Count < 2) { return; } for (int i = 0; i < m_RequestPacket.PlayerIds.Count; i++) { PvpPlayer p = CacheSet.PvpPlayerCache.FindKey(m_RequestPacket.PlayerIds[i], m_RequestPacket.ServerId[i]); if (p == null) { return; } if (i == 0) { player1 = p; } else if (i == 1) { player2 = p; } } int p1score = PVPLogic.GetDeltaScore(player1.Score, player2.Score, m_RequestPacket.Result[0]); int p2score = PVPLogic.GetDeltaScore(player2.Score, player1.Score, m_RequestPacket.Result[1]); WLPvpResult package = new WLPvpResult(); for (int i = 0; i < m_RequestPacket.PlayerIds.Count; i++) { package.PlayerId = m_RequestPacket.PlayerIds[i]; package.Result = m_RequestPacket.Result[i]; package.Score = i == 0 ? p1score : p2score; LobbyServerSender.Send(m_RequestPacket.ServerId[i], "WLPvpResultHandler", package, delegate(RemotePackage callback) { LWPvpResult res = RemoteCommunication.ParseRemotePackage <LWPvpResult>(callback.Message as byte[]); if (res.PlayerId == player1.Id) { player1.Score = res.Score; } else if (res.PlayerId == player2.Id) { player2.Score = res.Score; } RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking").Refresh(); }); } }
public static bool StartSingleMatch(PBRoomPlayerInfo player) { var p = CacheSet.PvpPlayerCache.FindKey(player.PlayerInfo.Id, player.LobbyServerId); if (p == null) { PvpPlayer pp = new PvpPlayer() { Id = player.PlayerInfo.Id, ServerId = player.LobbyServerId, Score = player.Score, Name = player.PlayerInfo.Name, }; CacheSet.PvpPlayerCache.Add(pp); } else { p.Name = player.PlayerInfo.Name; p.Score = player.Score; p.PortraitType = player.PlayerInfo.PortraitType; } int typeId = (int)PVPType.Single; PVPMatchQueue queue; if (!CacheSet.PVPMathcQueueCache.TryGet(typeId.ToString(), out queue)) { queue = new PVPMatchQueue(); queue.QueueType = typeId; queue.MatchedGroupCount = 0; CacheSet.PVPMathcQueueCache.AddOrUpdate(typeId.ToString(), queue); } if (queue.InQueueGroups.Find(g => g.Player.PlayerInfo.Id == player.PlayerInfo.Id) != null) { return(false); } PVPGroup group = new PVPGroup(); group.Player = player; queue.InQueueGroups.Add(group); return(true); }