本文整理汇总了C#中SortedDictionary.GetOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.GetOrDefault方法的具体用法?C# SortedDictionary.GetOrDefault怎么用?C# SortedDictionary.GetOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.GetOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WritePlayer
private static void WritePlayer(Packet pPacket, DatabaseQuery pQuery)
{
pPacket.WriteInt((int)pQuery["identifier"]);
pPacket.WritePaddedString((string)pQuery["name"], 13);
pPacket.WriteByte((byte)pQuery["gender"]);
pPacket.WriteByte((byte)pQuery["skin"]);
pPacket.WriteInt((int)pQuery["eyes_identifier"]);
pPacket.WriteInt((int)pQuery["hair_identifier"]);
pPacket.WriteSkip(24);
pPacket.WriteByte((byte)pQuery["level"]);
pPacket.WriteUShort((ushort)pQuery["job"]);
pPacket.WriteUShort((ushort)pQuery["strength"]);
pPacket.WriteUShort((ushort)pQuery["dexterity"]);
pPacket.WriteUShort((ushort)pQuery["intellect"]);
pPacket.WriteUShort((ushort)pQuery["luck"]);
pPacket.WriteUShort((ushort)pQuery["health"]);
pPacket.WriteUShort((ushort)pQuery["max_health"]);
pPacket.WriteUShort((ushort)pQuery["mana"]);
pPacket.WriteUShort((ushort)pQuery["max_mana"]);
pPacket.WriteUShort((ushort)pQuery["ability_points"]);
pPacket.WriteUShort((ushort)pQuery["skill_points"]);
pPacket.WriteInt((int)pQuery["experience"]);
pPacket.WriteUShort((ushort)pQuery["fame"]);
pPacket.WriteSkip(4);
pPacket.WriteInt((int)pQuery["map_identifier"]);
pPacket.WriteByte((byte)pQuery["map_spawn"]);
pPacket.WriteSkip(4);
pPacket.WriteByte((byte)pQuery["gender"]);
pPacket.WriteByte((byte)pQuery["skin"]);
pPacket.WriteInt((int)pQuery["eyes_identifier"]);
pPacket.WriteBool(true);
pPacket.WriteInt((int)pQuery["hair_identifier"]);
SortedDictionary<byte, Doublet<int, int>> equipment = new SortedDictionary<byte, Doublet<int, int>>();
using (DatabaseQuery queryEquipment = Database.Query("SELECT inventory_slot,item_identifier FROM player_item WHERE [email protected]_identifier AND inventory_type=0 AND inventory_slot<0", new MySqlParameter("@player_identifier", (int)pQuery["identifier"])))
{
while (queryEquipment.NextRow())
{
short slot = (short)(-((short)queryEquipment["inventory_slot"]));
if (slot > 100) slot -= 100;
Doublet<int, int> pair = equipment.GetOrDefault((byte)slot, null);
if (pair == null)
{
pair = new Doublet<int, int>((int)queryEquipment["item_identifier"], 0);
equipment.Add((byte)slot, pair);
}
else if ((short)queryEquipment["inventory_slot"] < -100)
{
pair.Second = pair.First;
pair.First = (int)queryEquipment["item_identifier"];
}
else pair.Second = (int)queryEquipment["item_identifier"];
}
}
foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment)
{
pPacket.WriteByte(pair.Key);
if (pair.Key == 11 && pair.Value.Second > 0) pPacket.WriteInt(pair.Value.Second);
else pPacket.WriteInt(pair.Value.First);
}
pPacket.WriteByte(0xFF);
foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment)
{
if (pair.Key != 11 && pair.Value.Second > 0)
{
pPacket.WriteByte(pair.Key);
pPacket.WriteInt(pair.Value.Second);
}
}
pPacket.WriteByte(0xFF);
Doublet<int, int> cashWeapon = equipment.GetOrDefault((byte)11, null);
pPacket.WriteInt(cashWeapon == null ? 0 : cashWeapon.First);
pPacket.WriteSkip(12);
pPacket.WriteBool(false);
}