public FramePosition ReadPosition(int positionOffset, FramePosition.PositionType positionType) { FramePosition Position; if (positions.TryGetValue(positionOffset, out Position)) { return(Position); } reader.Seek(positionOffset); var position = new FramePosition(); position.CellIndex = reader.ReadUInt16(); switch (positionType) { case FramePosition.PositionType.Index: break; case FramePosition.PositionType.IndexRotationScaleTranslation: throw new NotImplementedException(); case FramePosition.PositionType.IndexTranslation: reader.Skip(2); var tx = reader.ReadInt16(); var ty = reader.ReadInt16(); break; } positions.Add(positionOffset, position); return(position); }
private List <AnimationFrame> ReadFrames(ushort totalFrames, FramePosition.PositionType positionType, BinaryReader frameReader, PositionReader positionReader) { List <AnimationFrame> Frames = new List <AnimationFrame>(); for (int frameIndex = 0; frameIndex < totalFrames; ++frameIndex) { var frame = new AnimationFrame(); int positionOffset = frameReader.ReadInt32(); frame.FrameTime = frameReader.ReadUInt16(); frameReader.Skip(2); frame.Position = positionReader.ReadPosition(positionOffset, positionType); Frames.Add(frame); } return(Frames); }