public Element Copy() { Element e = new Element(); e.seed = seed; e.seednow = seednow; e.color = color; e.coloradd = coloradd; e.pos = pos; e.scale = scale; e.rotate = rotate; e.sound = sound; e.tag = tag; e.seedasdummy = seedasdummy; return e; }
public void Read(System.IO.Stream s) { elems.Clear(); byte[] bb = new byte[255]; s.Read(bb,0,2); int length = BitConverter.ToInt16(bb, 0); for (int i = 0; i < length; i++) { Element e = new Element(); e.Read(s); elems.Add(e); } s.Read(bb, 0, 2); length = BitConverter.ToInt16(bb, 0); for (int i = 0; i < length; i++) { var len = s.ReadByte(); s.Read(bb, 0, len); var tag = System.Text.Encoding.UTF8.GetString(bb, 0, len); frametags.Add(tag); } }
public Anim FillAni() { Anim anim = new Anim(cursprite); if (this.datadom.listTimeLine.Count == 0) { logger.Log(LogLevel.Error, "this.datadom.listTimeLine.Count == 0"); return null; } anim.size.X = datadom.width; anim.size.Y = datadom.height; int maxframe = 0; //Dictionary<string, string> part2bone = new Dictionary<string, string>(); //foreach (var p in data.Parts) //{ // part2bone[p.type] = p.bone; //} foreach (var l in this.datadom.listTimeLine[0].layers)//不使用层名称 { int frameid = 0; // List<aniconv.xfl.data_domdoc.DOMTimeline.DOMLayer.DOMFrame> framesneedcopy = new List<data_domdoc.DOMTimeline.DOMLayer.DOMFrame>(); foreach (var f in l.frames) { if (f.duration > 1) { frameid = f.index + f.duration - 1; //framesneedcopy.Add(f); } frameid = Math.Max(f.index, frameid); } maxframe = Math.Max(frameid, maxframe); } anim.frames.Clear(); while (anim.frames.Count <= maxframe) { anim.frames.Add(new Frame()); } // anim.ResetFrameCount(maxframe); foreach (var l in this.datadom.listTimeLine[0].layers) { foreach (var f in l.frames) { if (f.element.listbelements.Count > 0) { Element elem = new Element(); anim.frames[f.index].elems.Add(elem); Matrix mat; if (f.__elements[0].matrix.Count > 0) mat = f.__elements[0].matrix[0]; else mat = new Matrix(); elem.pos.X = mat.tx;// +f.elements[0].transformationPoint.;// -data.SizeX / 2; elem.pos.Y = mat.ty;// +data.SizeY; var s = mat.GetScale(); elem.scale.X = s.X; elem.scale.Y = s.Y; if (s.Y < 0) { } elem.rotate = -mat.GetRotate();// / (float)Math.PI * -180.0f; //f.elements[0].libraryItemName 类型 string seedoname = System.IO.Path.GetFileNameWithoutExtension(f.__elements[0].libraryItemName); string seedname = seedoname + "_b"; GenSeed_R(f.__elements[0].libraryItemName, mainpath); if (cursprite.seeds.ContainsKey(seedname)==false) { Seed seed = new Seed(); seed.size = cursprite.seeds[seedoname].size; seed.orient = new Microsoft.Xna.Framework.Vector2(); seed.texname = cursprite.seeds[seedoname].texname; cursprite.seeds[seedname] = seed; } elem.seed = seedname; elem.seednow = elem.seed; elem.sound = f.soundName; elem.tag = f.name; //if (f._elements[0].color.Count > 0) //{ // elem.color.A = (byte)(f.__elements[0].color[0].alphaMultiplier * 255); // elem.color.R = (byte)(f.__elements[0].color[0].redMultiplier * 255); // elem.color.G = (byte)(f.__elements[0].color[0].greenMultiplier * 255); // elem.color.B = (byte)(f.__elements[0].color[0].blueMultiplier * 255); // int i = f._elements[0].color[0].redOffset; // if (i > 255) i = 255; // elem.coloradd.R = (byte)i; // i = f._elements[0].color[0].greenOffset; // if (i > 255) i = 255; // elem.coloradd.G = (byte)i; // i = f._elements[0].color[0].blueOffset; // if (i > 255) i = 255; // elem.coloradd.B = (byte)i; //} if (f.duration > 0) { for (int i = 1; i < f.duration; i++) { anim.frames[f.index + i].elems.Add(elem.Copy()); } } } else if (f._elements.Count > 0) { Element elem = new Element(); anim.frames[f.index].elems.Add(elem); Matrix mat; if (f._elements[0].matrix.Count > 0) mat = f._elements[0].matrix[0]; else mat = new Matrix(); elem.pos.X = mat.tx;// +f.elements[0].transformationPoint.;// -data.SizeX / 2; elem.pos.Y = mat.ty;// +data.SizeY; var s = mat.GetScale(); elem.scale.X = s.X; elem.scale.Y = s.Y; if (s.Y < 0) { } elem.rotate = -mat.GetRotate();// / (float)Math.PI * -180.0f; //f.elements[0].libraryItemName 类型 elem.seed = seedchange[f._elements[0].libraryItemName];// cursprite.seeds[f.elements[0].libraryItemName]; elem.seednow = elem.seed; elem.sound = f.soundName; elem.tag = f.name; if (f._elements[0].color.Count > 0) { elem.color.A = (byte)(f._elements[0].color[0].alphaMultiplier * 255); elem.color.R = (byte)(f._elements[0].color[0].redMultiplier * 255); elem.color.G = (byte)(f._elements[0].color[0].greenMultiplier * 255); elem.color.B = (byte)(f._elements[0].color[0].blueMultiplier * 255); int i = f._elements[0].color[0].redOffset; if (i > 255) i = 255; elem.coloradd.R = (byte)i; i = f._elements[0].color[0].greenOffset; if (i > 255) i = 255; elem.coloradd.G = (byte)i; i = f._elements[0].color[0].blueOffset; if (i > 255) i = 255; elem.coloradd.B = (byte)i; } if (f.duration > 0) { for (int i = 1; i < f.duration; i++) { anim.frames[f.index + i].elems.Add(elem.Copy()); } } } if(string.IsNullOrEmpty( f.name)==false) { anim.frames[f.index].AddTag(f.name); for (int i = 1; i < f.duration; i++) { anim.frames[f.index+i].AddTag(f.name); } } } } return anim; }