private static RagnarokAnimation CreateAnimation( RoSprite spr, RoAction act ) { RagnarokAnimation ani = new RagnarokAnimation(); ani.Images = new List<RagnarokAnimationImage>(); for( int i = 0; i < spr.Images.Count; i++ ) { RagnarokAnimationImage img = new RagnarokAnimationImage(); byte[] data = spr.Images[ i ].Data; if( spr.Compressed == false ) data = InsaneRO.Cards.Library.Cryptic.RLE.Encode( data ); img.Width = spr.Images[ i ].Width; img.Height = spr.Images[ i ].Height; img.Size = data.Length; img.Data = data; ani.Images.Add( img ); } ani.Palette = new RagnarokAnimationPalette( spr.Palette.Count ); for( int i = 0; i < spr.Palette.Count; i++ ) ani.Palette.Add( new Microsoft.Xna.Framework.Graphics.Color( spr.Palette[ i ].R, spr.Palette[ i ].G, spr.Palette[ i ].B ) ); ani.Actions = new RagnarokAnimationActionList(); for( int i = 0; i < act.Actions.Count; i++ ) { RagnarokAnimationAction action = new RagnarokAnimationAction(); action.Frames = new RagnarokAnimationActionFrameList(); for( int f = 0; f < act.Actions[ i ].Frames.Count; f++ ) { RagnarokAnimationActionFrame frame = new RagnarokAnimationActionFrame(); frame.Images = new RagnarokAnimationActionFrameImageList(); frame.Palette1 = act.Actions[ i ].Frames[ f ].Palette1; frame.Palette2 = act.Actions[ i ].Frames[ f ].Palette2; frame.Audio = act.Actions[ i ].Frames[ f ].Audio; frame.Numxxx = act.Actions[ i ].Frames[ f ].Numxxx; if( frame.Numxxx == 1 ) { frame.Ext1 = act.Actions[ i ].Frames[ f ].Ext1; frame.ExtX = act.Actions[ i ].Frames[ f ].ExtX; frame.ExtY = act.Actions[ i ].Frames[ f ].ExtY; frame.Terminate = act.Actions[ i ].Frames[ f ].Terminate; } for( int s = 0; s < act.Actions[ i ].Frames[ f ].Sprites.Count; s++ ) { RagnarokAnimationActionFrameImage img = new RagnarokAnimationActionFrameImage() { X = (short)act.Actions[ i ].Frames[ f ].Sprites[ s ].X, Y = (short)act.Actions[ i ].Frames[ f ].Sprites[ s ].Y, Number = (ushort)act.Actions[ i ].Frames[ f ].Sprites[ s ].Number, Mirror = ( act.Actions[ i ].Frames[ f ].Sprites[ s ].Mirror > 0 ), Color = new Microsoft.Xna.Framework.Graphics.Color( act.Actions[ i ].Frames[ f ].Sprites[ s ].ColorR, act.Actions[ i ].Frames[ f ].Sprites[ s ].ColorG, act.Actions[ i ].Frames[ f ].Sprites[ s ].ColorB, 255 - act.Actions[ i ].Frames[ f ].Sprites[ s ].ColorA ), ScaleX = act.Actions[ i ].Frames[ f ].Sprites[ s ].ScaleX, ScaleY = act.Actions[ i ].Frames[ f ].Sprites[ s ].ScaleY, Rotation = (short)act.Actions[ i ].Frames[ f ].Sprites[ s ].Rotation, Type = (short)act.Actions[ i ].Frames[ f ].Sprites[ s ].Type, Width = (ushort)act.Actions[ i ].Frames[ f ].Sprites[ s ].Width, Height = (ushort)act.Actions[ i ].Frames[ f ].Sprites[ s ].Height, }; // fixxes if( act.Actions[ i ].Frames[ f ].Sprites[ s ].ScaleXY != 0 ) { img.ScaleX = act.Actions[ i ].Frames[ f ].Sprites[ s ].ScaleXY; img.ScaleY = act.Actions[ i ].Frames[ f ].Sprites[ s ].ScaleXY; } if( img.Width == 0 || img.Height == 0 ) { int num = (int)act.Actions[ i ].Frames[ f ].Sprites[ s ].Number; img.Width = ani.Images[ num ].Width; img.Height = ani.Images[ num ].Height; } frame.Images.Add( img ); } action.Frames.Add( frame ); } ani.Actions.Add( action ); } // sounds ani.ActionSounds = new List<string>(); for( int i = 0; i < act.Sounds.Count; i++ ) ani.ActionSounds.Add( act.Sounds[ i ].Trim() ); return ani; }
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); }