public void AddFrame(Frame value) { m_frameList.Add(value); }
public bool LoadAnimation(string filePath) { if (!File.Exists(filePath)) { return false; } var fs = new FileStream(filePath, FileMode.Open); var br = new BinaryReader(fs); var xmlNameLength = br.ReadChar(); var xmlName = br.ReadBytes(xmlNameLength); var strXmlName = Encoding.Default.GetString(xmlName); var picBlockIndex = br.ReadInt32(); var offIndex = br.ReadInt32(); var totalNumber = br.ReadInt32(); var animation = new Animation(); for (var actionIndex = 0; br.PeekChar() != -1 && actionIndex < totalNumber; ++actionIndex) { var actionNameLength = br.ReadChar(); var actionName = br.ReadBytes(actionNameLength); var strActionName = Encoding.Default.GetString(actionName); var hitFrameIndex = br.ReadInt32(); var angle = br.ReadInt32(); var scaleX = br.ReadSingle(); var scaleY = br.ReadSingle(); var flipX = br.ReadInt32(); var flipY = br.ReadInt32(); var dispBorder = br.ReadInt32(); var width = br.ReadInt32(); var height = br.ReadInt32(); var interval = br.ReadInt32(); var frameNumber = br.ReadInt32(); var action = new Action(); action.Index = actionIndex; action.Width = width; action.Height = height; action.Interval = interval; for (int frameIndex = 0; frameIndex < frameNumber; ++frameIndex) { var frameNameLength = br.ReadChar(); var frameName = br.ReadBytes(frameNameLength); var strFrameName = Encoding.Default.GetString(frameName); var hitLayerIndex = br.ReadInt32(); var offLayerIndex = br.ReadInt32(); var frameAngle = br.ReadInt32(); var frameScaleX = br.ReadSingle(); var frameScaleY = br.ReadSingle(); var frameFlipX = br.ReadInt32(); var frameFlipY = br.ReadInt32(); var frameDispBorder = br.ReadInt32(); var frameLock = br.ReadInt32(); var layerNumber = br.ReadInt32(); var frame = new Frame(); frame.Index = frameIndex; frame.Angle = frameAngle; frame.ScaleX = frameScaleX; frame.ScaleY = frameScaleY; frame.FlipX = frameFlipX == 1; frame.FlipY = frameFlipY == 1; for (int layerIndex = 0; layerIndex < layerNumber; ++layerIndex) { var layerRes = br.ReadInt32(); var layerX = br.ReadInt32(); var layerY = br.ReadInt32(); var layerVisible = br.ReadInt32(); var layerAngle = br.ReadInt32(); var layerOrientation = br.ReadInt32(); var layerScaleX = br.ReadSingle(); var layerScaleY = br.ReadSingle(); var layerFlipX = br.ReadInt32(); var layerFlipY = br.ReadInt32(); var layerDispBorder = br.ReadInt32(); var layerLock = br.ReadInt32(); var layer = new Layer(); layer.Index = layerIndex; layer.Res = layerRes; layer.X = layerX; layer.Y = layerY; layer.Visible = layerVisible == 1; layer.Angle = layerAngle; layer.ScaleX = layerScaleX; layer.ScaleY = layerScaleY; layer.FlipX = layerFlipX == 1; layer.FlipY = layerFlipY == 1; frame.AddLayer(layer); } action.AddFrame(frame); } animation.AddAction(action); } m_animationList.Add(animation); return true; }