public static AMK_File Read(byte[] bytes) { AMK_File amkFile = new AMK_File(); //Header amkFile.I_06 = BitConverter.ToUInt16(bytes, 6); amkFile.I_08 = BitConverter.ToInt32(bytes, 8); amkFile.I_12 = BitConverter.ToInt32(bytes, 12); amkFile.I_16 = BitConverter.ToInt32(bytes, 16); int entryCount = BitConverter.ToInt32(bytes, 20); int entryOffset = BitConverter.ToInt32(bytes, 24); int nameOffset = BitConverter.ToInt32(bytes, 28); if (entryCount > 0) { amkFile.Animations = new List <AMK_Animation>(); for (int i = 0; i < entryCount; i++) { var anim = AMK_Animation.Read(bytes, i, entryOffset, nameOffset); if (anim != null) { amkFile.Animations.Add(anim); } entryOffset += 16; nameOffset += 32; } } return(amkFile); }
public static void SaveXml(string xmlPath) { string path = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath)); YAXSerializer serializer = new YAXSerializer(typeof(AMK_File), YAXSerializationOptions.DontSerializeNullObjects); AMK_File amkFile = (AMK_File)serializer.DeserializeFromFile(xmlPath); amkFile.Save(path); }