本文整理匯總了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))
//.........這裏部分代碼省略.........