本文整理汇总了C#中Packets.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Packets.Clone方法的具体用法?C# Packets.Clone怎么用?C# Packets.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packets
的用法示例。
在下文中一共展示了Packets.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGameEvents
public static List<Interfaces.IGameEvent> GetGameEvents(Packets.GameInfoPacket newPacket, Packets.GameInfoPacket oldPacket, ushort? PlayerId)
{
Dictionary<ushort, string> teamNameDictionary = new Dictionary<ushort, string>();
List<Interfaces.IGameEvent> gameEvents = new List<UDPClientServerCommons.Interfaces.IGameEvent>();
if (newPacket != null && oldPacket != null)// && PlayerId.HasValue)
{
try
{
for (int i = 0; i < newPacket.TeamScoreList.Count; i++)
{
teamNameDictionary.Add(newPacket.TeamScoreList[i].TeamId, newPacket.TeamScoreList[i].TeamName);
for (int j = 0; j < oldPacket.TeamScoreList.Count; j++)
{
if (newPacket.TeamScoreList[i].TeamId == oldPacket.TeamScoreList[j].TeamId)
{
if (newPacket.TeamScoreList[i].TeamScore != oldPacket.TeamScoreList[j].TeamScore)
{
// team score
gameEvents.Add(new GameEvents.TeamScoredEvent(newPacket.TeamScoreList[i].TeamId, newPacket.TeamScoreList[i].TeamName, newPacket.TeamScoreList[i].TeamScore, oldPacket.TeamScoreList[i].TeamScore));
}
break;
}
}
}
if (newPacket.RoundNumber == 0)
{
// game over
gameEvents.Add(new GameEvents.GameEndEvent());
}
if (newPacket.RoundNumber > oldPacket.RoundNumber)
{
//new round
gameEvents.Add(new GameEvents.NewRoundEvent((Packets.GameInfoPacket) newPacket.Clone()));
}
if (newPacket.PlayerStatusList.Count < oldPacket.PlayerStatusList.Count)
{
// player quitted
for (int i = 0; i < oldPacket.PlayerStatusList.Count; i++)
{
bool found = false;
ushort id = oldPacket.PlayerStatusList[i].PlayerId;
for (int j = 0; j < newPacket.PlayerStatusList.Count; j++)
{
if (newPacket.PlayerStatusList[j].PlayerId == id)
found = true;
}
if (!found)
{
gameEvents.Add(new GameEvents.PlayerQuitEvent(id, oldPacket.PlayerStatusList[i].PlayerName));
}
found = false;
}
}
if (newPacket.PlayerStatusList.Count > oldPacket.PlayerStatusList.Count)
{
// player joined
for (int i = 0; i < newPacket.PlayerStatusList.Count; i++)
{
bool found = false;
ushort id = newPacket.PlayerStatusList[i].PlayerId;
for (int j = 0; j < oldPacket.PlayerStatusList.Count; j++)
{
if (oldPacket.PlayerStatusList[j].PlayerId == id)
found = true;
}
if (!found)
{
gameEvents.Add(new GameEvents.PlayerJoinedEvent(id, newPacket.PlayerStatusList[i].PlayerName,newPacket.PlayerStatusList[i].PlayerTeam));
}
found = false;
}
}
for (int i = 0; i < newPacket.PlayerStatusList.Count; i++)
for (int j = 0; j < oldPacket.PlayerStatusList.Count; j++)
{
if (newPacket.PlayerStatusList[i].PlayerId == oldPacket.PlayerStatusList[j].PlayerId)
{
if (newPacket.PlayerStatusList[i].PlayerTeam != oldPacket.PlayerStatusList[j].PlayerTeam)
{
// player changed team
gameEvents.Add(new GameEvents.PlayerChangedTeamEvent(newPacket.PlayerStatusList[i].PlayerId, newPacket.PlayerStatusList[i].PlayerName, newPacket.PlayerStatusList[i].PlayerTeam, teamNameDictionary[newPacket.PlayerStatusList[i].PlayerTeam]));
}
if (newPacket.PlayerStatusList[i].PlayerScore != oldPacket.PlayerStatusList[j].PlayerScore)
{
// player scored
gameEvents.Add(new GameEvents.PlayerScoredEvent(newPacket.PlayerStatusList[i].PlayerId, newPacket.PlayerStatusList[i].PlayerName, newPacket.PlayerStatusList[i].PlayerScore, oldPacket.PlayerStatusList[i].PlayerScore));
}
if (newPacket.PlayerStatusList[i].PlayerName != oldPacket.PlayerStatusList[j].PlayerName)
{
// player nick changed
gameEvents.Add(new GameEvents.PlayerNickChangedEvent(newPacket.PlayerStatusList[i].PlayerId, oldPacket.PlayerStatusList[i].PlayerName, newPacket.PlayerStatusList[i].PlayerName));
}
}
}
}
//.........这里部分代码省略.........