本文整理汇总了C#中BitReader.ReadBitsLittleEndian方法的典型用法代码示例。如果您正苦于以下问题:C# BitReader.ReadBitsLittleEndian方法的具体用法?C# BitReader.ReadBitsLittleEndian怎么用?C# BitReader.ReadBitsLittleEndian使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitReader
的用法示例。
在下文中一共展示了BitReader.ReadBitsLittleEndian方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NpcAssignment
protected void NpcAssignment(byte type, List<byte> data)
{
byte[] packet = data.ToArray();
NpcEntity output;
//try
//{
BitReader br = new BitReader(data.ToArray());
br.ReadBitsLittleEndian(8);
UInt32 id = (uint)br.Read(32);
UInt16 npctype = (ushort)br.Read(16);
UInt16 x = (ushort)br.Read(16);
UInt16 y = (ushort)br.Read(16);
byte life = (byte)br.Read(8);
byte size = (byte)br.Read(8);
output = new NpcEntity(id, npctype, life, x, y);
int informationLength = 16;
String[] entries;
if (!DataManager.Instance.m_monsterFields.Get(npctype, out entries))
Logger.Write("Failed to read monstats data for NPC of type {0}", type);
if (entries.Length != informationLength)
Logger.Write("Invalid monstats entry for NPC of type {0}", type);
bool lookupName = false;
if (data.Count > 0x10)
{
br.Read(4);
if (br.ReadBit())
{
for (int i = 0; i < informationLength; i++)
{
int temp;
int value = Int32.Parse(entries[i]);
if (!BitScanReverse(out temp, (uint)value - 1))
temp = 0;
if (temp == 31)
temp = 0;
//Console.WriteLine("BSR: {0} Bitcount: {1}", temp+1, bitCount);
int bits = br.Read(temp + 1);
}
}
output.SuperUnique = false;
output.HasFlags = br.ReadBit();
if (output.HasFlags)
{
output.Champion = br.ReadBit();
output.Unique = br.ReadBit();
output.SuperUnique = br.ReadBit();
output.IsMinion = br.ReadBit();
output.Ghostly = br.ReadBit();
//Console.WriteLine("{0} {1} {2} {3} {4}", output.Champion, output.Unique, output.SuperUnique, output.IsMinion, output.Ghostly);
}
if (output.SuperUnique)
{
output.SuperUniqueId = br.ReadBitsLittleEndian(16);
String name;
if (!DataManager.Instance.m_superUniques.Get(output.SuperUniqueId, out name))
{
Logger.Write("Failed to lookup super unique monster name for {0}", output.SuperUniqueId);
output.Name = "invalid";
}
else
{
output.Name = name;
//Console.WriteLine("NPC: {0}", name);
}
}
else
lookupName = true;
if (data.Count > 17 && lookupName != true && output.Name != "invalid")
{
output.IsLightning = false;
while (true)
{
byte mod = (byte)br.ReadBitsLittleEndian(8);
if (mod == 0)
break;
if (mod == 0x11)
output.IsLightning = true;
}
}
}
else
lookupName = true;
if (lookupName)
{
String name;
if (!DataManager.Instance.m_monsterNames.Get((int)output.Type, out name))
//.........这里部分代码省略.........