当前位置: 首页>>代码示例>>C#>>正文


C# BitReader.ReadBitsLittleEndian方法代码示例

本文整理汇总了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))
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:OmegaBot,代码行数:101,代码来源:D2gsHandler.cs


注:本文中的BitReader.ReadBitsLittleEndian方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。