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


C# BinaryReader.ReadArray方法代码示例

本文整理汇总了C#中System.IO.BinaryReader.ReadArray方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadArray方法的具体用法?C# BinaryReader.ReadArray怎么用?C# BinaryReader.ReadArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryReader的用法示例。


在下文中一共展示了BinaryReader.ReadArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        public void Load(string continent)
        {
            var wdlPath = string.Format(@"World\Maps\{0}\{0}.wdl", continent);
            using (var strm = FileManager.Instance.Provider.OpenFile(wdlPath))
            {
                if (strm == null)
                    return;

                var reader = new BinaryReader(strm);
                var signature = 0u;
                while (signature != 0x4D414F46)
                {
                    signature = reader.ReadUInt32();
                    var size = reader.ReadInt32();
                    if (signature == 0x4D414F46)
                        break;

                    reader.ReadBytes(size);
                }

                var tileOffsets = reader.ReadArray<int>(4096);
                for(var i = 0; i < 4096; ++i)
                {
                    if (tileOffsets[i] <= 0)
                        continue;

                    strm.Position = tileOffsets[i] + 8;
                    mEntries.Add(i, reader.Read<MareEntry>());
                }
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:31,代码来源:WdlFile.cs

示例2: ParseUncompressedLayer

        private static void ParseUncompressedLayer(int layer, ref uint[] palette, BinaryReader baseReader, ref BlpHeader header, TextureLoadInfo loadInfo)
        {
            if (header.Compression == 3)
                return;

            if (palette.Length == 0)
            {
                baseReader.BaseStream.Position = SizeCache<BlpHeader>.Size;
                palette = baseReader.ReadArray<uint>(256);
            }

            var w = Math.Max(header.Width >> layer, 1);
            var h = Math.Max(header.Height >> layer, 1);
            var indices = loadInfo.Layers[layer];
            var colors = new byte[w * h * 4];

            if (header.AlphaDepth == 8)
                DecompPaletteFastPath(ref palette, ref indices, ref colors);
            else
                DecompPaletteA8R8G8B8(header.AlphaDepth, ref palette, ref indices, ref colors);

            loadInfo.Layers[layer] = colors;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:23,代码来源:TextureLoader.cs

示例3: ReadParameterList

 private static ParameterMetadata ReadParameterList(BinaryReader reader)
 {
     return new ParameterMetadata(null, DataType.Object, reader.ReadArray(r =>
     {
         var type = (DataType) r.ReadByte();
         var name = r.ReadUtfString();
         return new ParameterMetadata(name, type);
     }));
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:9,代码来源:BinaryServiceBase.cs

示例4: Read

 /// <summary>
 /// Reads a <see cref="Portal"/>
 /// </summary>
 /// <param name="br">The <see cref="BinaryReader"/> used to read the <see cref="Portal"/></param>
 /// <returns>A <see cref="Portal"/></returns>
 public static Portal Read(BinaryReader br)
 {
     return new Portal(br.ReadUInt16(), Vertex.Read16(br), br.ReadArray(4, () => Vertex.Read16(br)));
 }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:9,代码来源:DataTypes.cs

示例5: LoadVertices

 private void LoadVertices(BinaryReader reader, int size)
 {
     var numVertices = size / SizeCache<Vector3>.Size;
     mPositions = reader.ReadArray<Vector3>(numVertices);
     for(var i = 0; i < mPositions.Length; ++i)
     {
         mPositions[i] = new Vector3(mPositions[i].X, -mPositions[i].Y, mPositions[i].Z);
     }
 }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:9,代码来源:WmoGroup.cs

示例6: LoadTexCoords

        private void LoadTexCoords(BinaryReader reader, int size)
        {
            if (mTexCoordsLoaded && mTexCoords.Length > 0)
                return;

            mTexCoordsLoaded = true;

            var numTexCoords = size / SizeCache<Vector2>.Size;
            mTexCoords = reader.ReadArray<Vector2>(numTexCoords);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:10,代码来源:WmoGroup.cs

示例7: LoadMcnr

        private void LoadMcnr(BinaryReader reader)
        {
            var normals = reader.ReadArray<sbyte>(145 * 3);
            mNormalExtra = reader.ReadBytes(13);

            for (var i = 0; i < 145; ++i)
            {
                var nx = -(normals[i * 3] / 127.0f);
                var ny = -(normals[i * 3 + 1] / 127.0f);
                var nz = normals[i * 3 + 2] / 127.0f;

                Vertices[i].Normal = new Vector3(nx, ny, nz);
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:14,代码来源:MapChunk.cs

示例8: LoadMcvt

        private void LoadMcvt(BinaryReader reader)
        {
            var heights = reader.ReadArray<float>(145);

            var posx = Metrics.MapMidPoint - mHeader.Position.Y;
            var posy = Metrics.MapMidPoint - mHeader.Position.X;
            var posz = mHeader.Position.Z;

            var counter = 0;

            var minPos = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            var maxPos = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            for (var i = 0; i < 17; ++i)
            {
                for (var j = 0; j < (((i % 2) != 0) ? 8 : 9); ++j)
                {
                    var height = posz + heights[counter];
                    var x = posx + j * Metrics.UnitSize;
                    if ((i % 2) != 0)
                        x += 0.5f * Metrics.UnitSize;
                    var y = posy + i * Metrics.UnitSize * 0.5f;

                    Vertices[counter].Position = new Vector3(x, y, height);

                    if (height < minPos.Z)
                        minPos.Z = height;
                    if (height > maxPos.Z)
                        maxPos.Z = height;

                    if (x < minPos.X)
                        minPos.X = x;
                    if (x > maxPos.X)
                        maxPos.X = x;
                    if (y < minPos.Y)
                        minPos.Y = y;
                    if (y > maxPos.Y)
                        maxPos.Y = y;

                    Vertices[counter].TexCoordAlpha = new Vector2(j / 8.0f + ((i % 2) != 0 ? (0.5f / 8.0f) : 0), i / 16.0f);
                    Vertices[counter].TexCoord = new Vector2(j + ((i % 2) != 0 ? 0.5f : 0.0f), i * 0.5f);
                    ++counter;
                }
            }

            mMinHeight = minPos.Z;
            mMaxHeight = maxPos.Z;

            BoundingBox = new BoundingBox(minPos, maxPos);
            mMidPoint = minPos + (maxPos - minPos) / 2.0f;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:51,代码来源:MapChunk.cs

示例9: LoadRootFile

        private void LoadRootFile()
        {
            var encKeyStr = mBuildConfig["root"].FirstOrDefault();
            if (encKeyStr == null) throw new InvalidOperationException("Build config is missing root key");
            var encodingKey = encKeyStr.HexToBytes().ToArray();

            EncodingEntry encEntry;
            if (mEncodingData.TryGetValue(new Binary(encodingKey), out encEntry) == false || encEntry.Keys.Length == 0)
                throw new InvalidOperationException("Unable to find encoding value for root file");

            IndexEntry entry;
            if (mIndexData.TryGetValue(new Binary(encEntry.Keys[0].ToArray().Take(9).ToArray()), out entry) == false)
                throw new InvalidOperationException("Unable to locate root file in index table");

            var strm = GetDataStream(entry.Index);
            using (var fileReader = new BinaryReader(strm.Stream, Encoding.UTF8, true))
            {
                fileReader.BaseStream.Position = entry.Offset + 30;
                using (var reader = new BinaryReader(BlteGetData(fileReader, entry.Size - 30)))
                {
                    try
                    {
                        while(true)
                        {
                            var count = reader.ReadInt32();
                            reader.ReadBytes(8 + count * 4);
                            var entries = reader.ReadArray<RootEntryFile>(count);
                            foreach (var e in entries)
                            {
                                var b = e.md5;
                                var rootEntry = new RootEntry
                                {
                                    Hash = e.hash,
                                    Md5 = new Binary(new[]
                                    {
                                        b.v1, b.v2, b.v3, b.v4, b.v5, b.v6, b.v7, b.v8, b.v9, b.v10, b.v11,
                                        b.v12, b.v13, b.v14, b.v15, b.v16
                                    })
                                };
                                if (mRootData.ContainsKey(e.hash))
                                    mRootData[e.hash].Add(rootEntry);
                                else
                                    mRootData.Add(e.hash, new List<RootEntry>(20) {rootEntry});
                            }
                        }
                    }
                    catch(EndOfStreamException)
                    {

                    }
                }
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:53,代码来源:FileManager.cs

示例10: LoadIndexFile

        private void LoadIndexFile(string file)
        {
            using (var strm = File.OpenRead(file))
            {
                using (var reader = new BinaryReader(strm))
                {
                    var h2Len = reader.ReadInt32();
                    reader.ReadInt32();
                    var padded = (8 + h2Len + 0x0F) & 0xFFFFFFF0;
                    strm.Position = padded;
                    var dataLen = reader.ReadInt32();
                    reader.ReadInt32();
                    var numBlocks = dataLen / 18;
                    var blocks = reader.ReadArray<IndexFileEntry>(numBlocks);
                    foreach(var block in blocks)
                    {
                        var key = new Binary(new[]
                        {
                            block.key.v1, block.key.v2, block.key.v3, block.key.v4, block.key.v5,
                            block.key.v6, block.key.v7, block.key.v8, block.key.v9
                        });

                        if (mIndexData.ContainsKey(key))
                            continue;

                        var idxLowBe = block.indexLowBE;
                        var idxHigh = block.indexHigh;
                        var idxLow = idxLowBe >> 24;
                        idxLow |= ((idxLowBe >> 16) & 0xFF) << 8;
                        idxLow |= ((idxLowBe >> 8) & 0xFF) << 16;
                        idxLow |= ((idxLowBe >> 0) & 0xFF) << 24;

                        mIndexData.Add(key, new IndexEntry()
                        {
                            Index = (((byte)(idxHigh << 2)) | ((idxLow & 0xC0000000) >> 30)),
                            Offset = (idxLow & 0x3FFFFFFF),
                            Size = block.size
                        });
                    }
                }
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:42,代码来源:FileManager.cs

示例11: InitWmoModels

        private void InitWmoModels(BinaryReader reader)
        {
            if (SeekChunk(reader, 0x4D574D4F) == false)
                return;

            var size = reader.ReadInt32();
            var bytes = reader.ReadBytes(size);
            var modelNameLookup = new Dictionary<int, string>();
            var curOffset = 0;
            var curBytes = new List<byte>();

            for (var i = 0; i < bytes.Length; ++i)
            {
                if (bytes[i] == 0)
                {
                    if (curBytes.Count > 0)
                        modelNameLookup.Add(curOffset, Encoding.ASCII.GetString(curBytes.ToArray()));

                    curOffset = i + 1;
                    curBytes.Clear();
                }
                else
                    curBytes.Add(bytes[i]);
            }

            if (SeekChunk(reader, 0x4D574944) == false)
                return;

            size = reader.ReadInt32();
            var modelNameIds = reader.ReadArray<int>(size / 4);

            if (SeekChunk(reader, 0x4D4F4446) == false)
                return;

            size = reader.ReadInt32();
            var modf = reader.ReadArray<Modf>(size / SizeCache<Modf>.Size);

            foreach (var entry in modf)
            {
                if (entry.Mwid >= modelNameIds.Length)
                    continue;

                var nameId = modelNameIds[entry.Mwid];
                string modelName;
                if (modelNameLookup.TryGetValue(nameId, out modelName) == false)
                    continue;


                var position = new Vector3(entry.Position.X, entry.Position.Z, entry.Position.Y);
                var rotation = new Vector3(entry.Rotation.Z, -entry.Rotation.X, 90 - entry.Rotation.Y);

                WorldFrame.Instance.WmoManager.AddInstance(modelName, entry.UniqueId, position, rotation);
                mWmoInstances.Add(new LoadedModel(modelName, entry.UniqueId));
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:55,代码来源:MapArea.cs

示例12: InitM2Models

        private void InitM2Models(BinaryReader reader)
        {
            if (SeekChunk(reader, 0x4D4D4458) == false)
                return;

            var size = reader.ReadInt32();
            var bytes = reader.ReadBytes(size);
            var fullString = Encoding.ASCII.GetString(bytes);
            var modelNames = fullString.Split('\0');
            var modelNameLookup = new Dictionary<int, string>();
            var curOffset = 0;
            foreach (var name in modelNames)
            {
                modelNameLookup.Add(curOffset, name);
                curOffset += name.Length + 1;
            }

            if (SeekChunk(reader, 0x4D4D4944) == false)
                return;

            size = reader.ReadInt32();
            var modelNameIds = reader.ReadArray<int>(size / 4);

            if (SeekChunk(reader, 0x4D444446) == false)
                return;

            size = reader.ReadInt32();
            mDoodadDefs = reader.ReadArray<Mddf>(size / SizeCache<Mddf>.Size);

            var index = -1;
            foreach (var entry in mDoodadDefs)
            {
                ++index;
                if (entry.Mmid >= modelNameIds.Length)
                    continue;

                var nameId = modelNameIds[entry.Mmid];
                string modelName;
                if (modelNameLookup.TryGetValue(nameId, out modelName) == false)
                    continue;

                var position = new Vector3(entry.Position.X, entry.Position.Z, entry.Position.Y);
                var rotation = new Vector3(-entry.Rotation.X, -entry.Rotation.Z, 90 - entry.Rotation.Y);
                var scale = entry.Scale / 1024.0f;

                var instance = WorldFrame.Instance.M2Manager.AddInstance(modelName, entry.UniqueId, position, rotation,
                    new Vector3(scale));

                DoodadInstances.Add(new M2Instance
                {
                    Hash = modelName.ToUpperInvariant().GetHashCode(),
                    Uuid = entry.UniqueId,
                    BoundingBox = (instance != null ? instance.BoundingBox : new BoundingBox(new Vector3(float.MaxValue), new Vector3(float.MinValue))),
                    RenderInstance = instance,
                    MddfIndex = index
                });
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:58,代码来源:MapArea.cs

示例13: InitChunkInfos

        private void InitChunkInfos(BinaryReader reader)
        {
            if(SeekChunk(reader, 0x4D43494E))
                mChunkOffsets = reader.ReadArray<Mcin>(256);

            reader.BaseStream.Position = 0;
            for (var i = 0; i < 256; ++i)
            {
                if (SeekNextMcnk(reader) == false)
                    throw new InvalidOperationException("Area is missing chunks");

                mChunkInfos.Add(new ChunkInfo
                {
                    Offset = (int)(reader.BaseStream.Position),
                    Size = reader.ReadInt32()
                });

                reader.ReadBytes(mChunkInfos.Last().Size);
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:20,代码来源:MapArea.cs

示例14: LoadIndices

 private void LoadIndices(BinaryReader reader, int size)
 {
     var numIndices = size / 2;
     mIndices = reader.ReadArray<ushort>(numIndices).ToList();
     Indices = mIndices.AsReadOnly();
 }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:6,代码来源:WmoGroup.cs

示例15: LoadColors

 private void LoadColors(BinaryReader reader, int size)
 {
     var numColors = size / 4;
     mColors = reader.ReadArray<uint>(numColors);
 }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:5,代码来源:WmoGroup.cs


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