Exemplo n.º 1
0
        public void LoadData()
        {
            this.DatoImages = new List <FDImage[]>();

            using (FileStream streamData = new FileStream(fileFullName, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader reader = new BinaryReader(streamData, Encoding.UTF8))
                {
                    reader.Skip(6);

                    int address0 = reader.ReadInt32();

                    List <int> creatureAddresses = new List <int>();
                    creatureAddresses.Add(address0);
                    while (reader.BaseStream.Position < address0)
                    {
                        creatureAddresses.Add(reader.ReadInt32());
                    }

                    for (int creature = 0; creature < creatureAddresses.Count - 1; creature++)
                    {
                        int baseAddress = creatureAddresses[creature];
                        reader.Seek(baseAddress, SeekOrigin.Begin);

                        List <int> biases = new List <int>();
                        for (int bias = 0; bias < 4; bias++)
                        {
                            biases.Add(reader.ReadInt32());
                        }

                        FDImage[] images = new FDImage[4];
                        for (int bias = 0; bias < 4; bias++)
                        {
                            reader.Seek(baseAddress + biases[bias], SeekOrigin.Begin);

                            int width  = reader.ReadInt16();
                            int height = reader.ReadInt16();

                            images[bias] = FDImage.ReadFromBinary(reader, width, height);
                        }

                        this.DatoImages.Add(images);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void LoadData()
        {
            this.Animations = new List <FigAnimation>();
            using (FileStream streamData = new FileStream(fileFullName, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader reader = new BinaryReader(streamData, Encoding.UTF8))
                {
                    reader.Skip(6);

                    int        aniCount     = 1;
                    int        address0     = reader.ReadInt32();
                    List <int> aniAddresses = new List <int>();
                    aniAddresses.Add(address0);
                    while (reader.BaseStream.Position < address0)
                    {
                        aniAddresses.Add(reader.ReadInt32());
                        aniCount++;
                    }

                    for (int aniIndex = 0; aniIndex < aniCount - 1; aniIndex++)
                    {
                        if (aniAddresses[aniIndex] >= reader.BaseStream.Length)
                        {
                            break;
                        }

                        reader.Seek(aniAddresses[aniIndex], SeekOrigin.Begin);

                        // Read Animation
                        FigAnimation animation  = new FigAnimation();
                        int          frameCount = reader.ReadByte();

                        bool hasRemoteFrame = reader.ReadBoolean();
                        if (hasRemoteFrame)
                        {
                            animation.RemoteFrameIndex = reader.ReadByte();
                        }
                        else
                        {
                            animation.RemoteFrameIndex = -1;
                            reader.ReadByte();
                        }

                        if (reader.BaseStream.Position >= reader.BaseStream.Length)
                        {
                            break;
                        }

                        reader.ReadByte();
                        reader.ReadInt32();
                        List <int> frameAddresses = new List <int>(frameCount);
                        for (int f = 0; f < frameCount; f++)
                        {
                            frameAddresses.Add(reader.ReadInt32());
                        }

                        for (int f = 0; f < frameCount; f++)
                        {
                            reader.Seek(aniAddresses[aniIndex] + frameAddresses[f]);

                            FigFrame frame = new FigFrame();

                            frame.PositionX = reader.ReadInt16();
                            frame.PositionY = reader.ReadInt16();

                            frame.IsHit         = reader.ReadBoolean();
                            frame.EffectAudioId = reader.ReadByte();
                            frame.Latency       = reader.ReadByte();

                            reader.ReadInt16();

                            frame.Image = FDImage.ReadFromBinary(reader);

                            string characterId = (aniIndex / 3).ToString("X2");
                            int    type        = aniIndex % 3;

                            animation.Frames.Add(frame);
                        }

                        this.Animations.Add(animation);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void LoadData()
        {
            using (FileStream streamData = new FileStream(fileFullName, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader reader = new BinaryReader(streamData, Encoding.UTF8))
                {
                    reader.Skip(6);

                    int        panelCount            = 1;
                    int        address0              = reader.ReadInt32();
                    int        address1              = reader.ReadInt32();
                    List <int> panelAddresses        = new List <int>();
                    List <int> panelControlAddresses = new List <int>();

                    panelAddresses.Add(address0);
                    panelControlAddresses.Add(address1);
                    while (reader.BaseStream.Position < address0)
                    {
                        panelAddresses.Add(reader.ReadInt32());
                        panelControlAddresses.Add(reader.ReadInt32());
                        panelCount++;
                    }

                    this.ShapePanels = new List <ShapePanel>();
                    for (int panelIndex = 0; panelIndex < panelCount - 1; panelIndex++)
                    {
                        if (panelAddresses[panelIndex] >= reader.BaseStream.Length)
                        {
                            break;
                        }

                        reader.Seek(panelAddresses[panelIndex], SeekOrigin.Begin);

                        // Read the Shape Panel
                        ShapePanel panel = new ShapePanel();
                        panel.Index       = panelIndex;
                        panel.ShapeWidth  = reader.ReadInt16();
                        panel.ShapeHeight = reader.ReadInt16();

                        int        shapeCount     = reader.ReadInt16();
                        List <int> shapeAddresses = new List <int>();
                        for (int c = 0; c < shapeCount; c++)
                        {
                            shapeAddresses.Add(reader.ReadInt32());
                        }

                        // Image Info
                        for (int c = 0; c < shapeCount; c++)
                        {
                            reader.Seek(panelAddresses[panelIndex] + shapeAddresses[c]);

                            ShapeInfo shape = new ShapeInfo();
                            shape.Image = FDImage.ReadFromBinary(reader, panel.ShapeWidth, panel.ShapeHeight);
                            panel.Shapes.Add(shape);
                        }

                        // Control Info
                        reader.Seek(panelControlAddresses[panelIndex]);
                        for (int c = 0; c < shapeCount; c++)
                        {
                            ShapeInfo shape = panel.Shapes[c];
                            shape.Index          = c;
                            shape.EventId        = reader.ReadByte();
                            shape.Type           = (ShapeInfo.ShapeType)reader.ReadByte();
                            shape.BattleGroundId = reader.ReadInt16();
                        }

                        this.ShapePanels.Add(panel);
                    }
                }
            }
        }