public bool Read( Stream stream ) { mReader = new BinaryReader( stream ); int imgCount = Reader.ReadUInt16(); // Image Data \\ mImages = new List<RagnarokAnimationImage>(); for( int i = 0; i < imgCount; i++ ) { mImages.Add( new RagnarokAnimationImage() ); mImages[ i ].Width = Reader.ReadUInt16(); mImages[ i ].Height = Reader.ReadUInt16(); int size = Reader.ReadInt32(); mImages[ i ].Data = Reader.ReadBytes( size ); } // Palette \\ mPalette = new RagnarokAnimationPalette( 256 ); for( int i = 0; i < 256; i++ ) mPalette.ReadColor( Reader ); // Actions \\ mActions = new RagnarokAnimationActionList(); int actCount = mReader.ReadUInt16(); for( int i = 0; i < actCount; i++ ) { RagnarokAnimationAction action = new RagnarokAnimationAction(); action.Frames = new RagnarokAnimationActionFrameList(); int frameCount = mReader.ReadUInt16(); for( int f = 0; f < frameCount; f++ ) { RagnarokAnimationActionFrame frame = new RagnarokAnimationActionFrame(); frame.Images = new RagnarokAnimationActionFrameImageList(); frame.Palette1 = mReader.ReadUInt32(); frame.Palette2 = mReader.ReadUInt32(); frame.Audio = mReader.ReadInt32(); frame.Numxxx = mReader.ReadInt32(); if( frame.Numxxx == 1 ) { frame.Ext1 = mReader.ReadInt32(); frame.ExtX = mReader.ReadInt32(); frame.ExtY = mReader.ReadInt32(); frame.Terminate = mReader.ReadInt32(); } int imageCount = mReader.ReadUInt16(); for( int s = 0; s < imageCount; s++ ) { RagnarokAnimationActionFrameImage img = new RagnarokAnimationActionFrameImage() { X = mReader.ReadInt16(), Y = mReader.ReadInt16(), Number = mReader.ReadUInt16(), Mirror = mReader.ReadBoolean(), Color = new Color( mReader.ReadByte(), mReader.ReadByte(), mReader.ReadByte(), mReader.ReadByte() ), ScaleX = mReader.ReadSingle(), ScaleY = mReader.ReadSingle(), Rotation = mReader.ReadInt16(), Type = mReader.ReadInt16(), Width = mReader.ReadUInt16(), Height = mReader.ReadUInt16(), }; frame.Images.Add( img ); } action.Frames.Add( frame ); } mActions.Add( action ); } // Sounds \\ mActionSounds = new List<string>(); int soundCount = Reader.ReadUInt16(); for( int i = 0; i < soundCount; i++ ) mActionSounds.Add( Reader.ReadString() ); return true; }
public bool Read(Stream stream) { mReader = new BinaryReader(stream); int imgCount = Reader.ReadUInt16(); // Image Data \\ mImages = new List <RagnarokAnimationImage>(); for (int i = 0; i < imgCount; i++) { mImages.Add(new RagnarokAnimationImage()); mImages[i].Width = Reader.ReadUInt16(); mImages[i].Height = Reader.ReadUInt16(); int size = Reader.ReadInt32(); mImages[i].Data = Reader.ReadBytes(size); } // Palette \\ mPalette = new RagnarokAnimationPalette(256); for (int i = 0; i < 256; i++) { mPalette.ReadColor(Reader); } // Actions \\ mActions = new RagnarokAnimationActionList(); int actCount = mReader.ReadUInt16(); for (int i = 0; i < actCount; i++) { RagnarokAnimationAction action = new RagnarokAnimationAction(); action.Frames = new RagnarokAnimationActionFrameList(); int frameCount = mReader.ReadUInt16(); for (int f = 0; f < frameCount; f++) { RagnarokAnimationActionFrame frame = new RagnarokAnimationActionFrame(); frame.Images = new RagnarokAnimationActionFrameImageList(); frame.Palette1 = mReader.ReadUInt32(); frame.Palette2 = mReader.ReadUInt32(); frame.Audio = mReader.ReadInt32(); frame.Numxxx = mReader.ReadInt32(); if (frame.Numxxx == 1) { frame.Ext1 = mReader.ReadInt32(); frame.ExtX = mReader.ReadInt32(); frame.ExtY = mReader.ReadInt32(); frame.Terminate = mReader.ReadInt32(); } int imageCount = mReader.ReadUInt16(); for (int s = 0; s < imageCount; s++) { RagnarokAnimationActionFrameImage img = new RagnarokAnimationActionFrameImage() { X = mReader.ReadInt16(), Y = mReader.ReadInt16(), Number = mReader.ReadUInt16(), Mirror = mReader.ReadBoolean(), Color = new Color(mReader.ReadByte(), mReader.ReadByte(), mReader.ReadByte(), mReader.ReadByte()), ScaleX = mReader.ReadSingle(), ScaleY = mReader.ReadSingle(), Rotation = mReader.ReadInt16(), Type = mReader.ReadInt16(), Width = mReader.ReadUInt16(), Height = mReader.ReadUInt16(), }; frame.Images.Add(img); } action.Frames.Add(frame); } mActions.Add(action); } // Sounds \\ mActionSounds = new List <string>(); int soundCount = Reader.ReadUInt16(); for (int i = 0; i < soundCount; i++) { mActionSounds.Add(Reader.ReadString()); } return(true); }