public ParticleType(ParticleType copyFrom) { this.Source = copyFrom.Source; this.SourceChooser = copyFrom.SourceChooser; this.Color = copyFrom.Color; this.Color2 = copyFrom.Color2; this.ColorMode = copyFrom.ColorMode; this.FadeMode = copyFrom.FadeMode; this.SpeedMin = copyFrom.SpeedMin; this.SpeedMax = copyFrom.SpeedMax; this.SpeedMultiplier = copyFrom.SpeedMultiplier; this.Acceleration = copyFrom.Acceleration; this.Friction = copyFrom.Friction; this.Direction = copyFrom.Direction; this.DirectionRange = copyFrom.DirectionRange; this.LifeMin = copyFrom.LifeMin; this.LifeMax = copyFrom.LifeMax; this.Size = copyFrom.Size; this.SizeRange = copyFrom.SizeRange; this.RotationMode = copyFrom.RotationMode; this.SpinMin = copyFrom.SpinMin; this.SpinMax = copyFrom.SpinMax; this.SpinFlippedChance = copyFrom.SpinFlippedChance; this.ScaleOut = copyFrom.ScaleOut; this.UseActualDeltaTime = copyFrom.UseActualDeltaTime; ParticleType.AllTypes.Add(this); }
public static void Load() { Chooser <MTexture> chooser1 = new Chooser <MTexture>(new MTexture[4] { Gfx.Game["particles/smoke0"], Gfx.Game["particles/smoke1"], Gfx.Game["particles/smoke2"], Gfx.Game["particles/smoke3"] }); ParticleTypes.Dust = new ParticleType() { SourceChooser = chooser1, Color = Color.white, Acceleration = new Vector2(0.0f, 4f), LifeMin = 0.3f, LifeMax = 0.5f, Size = 0.7f, SizeRange = 0.2f, Direction = 1.570796f, DirectionRange = 0.5f, SpeedMin = 5f, SpeedMax = 15f, RotationMode = ParticleType.RotationModes.Random, ScaleOut = true, UseActualDeltaTime = true }; }
public static Chooser <TT> FromString <TT>(string data) where TT : IConvertible { Chooser <TT> chooser = new Chooser <TT>(); string[] strArray1 = data.Split(','); if (strArray1.Length == 1 && strArray1[0].IndexOf(':') == -1) { chooser.Add((TT)Convert.ChangeType((object)strArray1[0], typeof(TT)), 1f); return(chooser); } foreach (string str1 in strArray1) { if (str1.IndexOf(':') == -1) { chooser.Add((TT)Convert.ChangeType((object)str1, typeof(TT)), 1f); } else { string[] strArray2 = str1.Split(':'); string str2 = strArray2[0].Trim(); string str3 = strArray2[1].Trim(); chooser.Add((TT)Convert.ChangeType((object)str2, typeof(TT)), Convert.ToSingle(str3, (IFormatProvider)CultureInfo.InvariantCulture)); } } return(chooser); }
public void Add(string id, float delay, string into, params MTexture[] frames) { this.animations[id] = new Animation() { Delay = delay, Frames = frames, Goto = Chooser <string> .FromString <string>(into) }; }
public void Add(string id, string path, float delay, string into, params int[] frames) { this.animations[id] = new Animation() { Delay = delay, Frames = this.GetFrames(path, frames), Goto = Chooser <string> .FromString <string>(into) }; }
public void Add(string id, string path, float delay, Chooser <string> into) { this.animations[id] = new Animation() { Delay = delay, Frames = this.GetFrames(path, (int[])null), Goto = into }; }
//public UnitSprite Create() //{ // return this.Sprite.CreateClone(); //} //public UnitSprite CreateOn(UnitSprite sprite) //{ // return this.Sprite.CloneInto(sprite); //} //包装sprite数据 public void WrapUnitSprite(UnitSprite sprite) { foreach (var spriteDataSource in Sources) { HashSet <string> ids = new HashSet <string>(); foreach (XmlElement xml1 in spriteDataSource.XML.GetElementsByTagName("Anim")) { this.CheckAnimXML(xml1, spriteDataSource.prefix, ids); } foreach (XmlElement xml1 in spriteDataSource.XML.GetElementsByTagName("Loop")) { this.CheckAnimXML(xml1, spriteDataSource.prefix, ids); } if (spriteDataSource.XML.HasAttr("start") && !ids.Contains(spriteDataSource.XML.Attr("start"))) { throw new Exception(spriteDataSource.prefix + "starting animation '" + spriteDataSource.XML.Attr("start") + "' is missing!"); } if (spriteDataSource.XML.HasChild("Justify") && spriteDataSource.XML.HasChild("Origin")) { throw new Exception(spriteDataSource.prefix + "has both Origin and Justify tags!"); } string str1 = spriteDataSource.XML.Attr("path", ""); float defaultValue = spriteDataSource.XML.AttrFloat("delay", 0.0f); foreach (XmlElement xml1 in spriteDataSource.XML.GetElementsByTagName("Anim")) { Chooser <string> into = !xml1.HasAttr("goto") ? (Chooser <string>)null : Chooser <string> .FromString <string>(xml1.Attr("goto")); string id = xml1.Attr("id"); string str2 = xml1.Attr("path", ""); int[] frames = Util.ReadCSVIntWithTricks(xml1.Attr("frames", "")); string path = string.IsNullOrEmpty(spriteDataSource.OverridePath) || !this.HasFrames(this.Atlas, spriteDataSource.OverridePath + str2, frames) ? str1 + str2 : spriteDataSource.OverridePath + str2; sprite.Add(id, path, xml1.AttrFloat("delay", defaultValue), into, frames); } foreach (XmlElement xml1 in spriteDataSource.XML.GetElementsByTagName("Loop")) { string id = xml1.Attr("id"); string str2 = xml1.Attr("path", ""); int[] frames = Util.ReadCSVIntWithTricks(xml1.Attr("frames", "")); string path = string.IsNullOrEmpty(spriteDataSource.OverridePath) || !this.HasFrames(this.Atlas, spriteDataSource.OverridePath + str2, frames) ? str1 + str2 : spriteDataSource.OverridePath + str2; sprite.AddLoop(id, path, xml1.AttrFloat("delay", defaultValue), frames); } if (spriteDataSource.XML.HasChild("Center")) { sprite.CenterOrigin(); sprite.Justify = new Vector2?(new Vector2(0.5f, 0.5f)); } else if (spriteDataSource.XML.HasChild("Justify")) { sprite.JustifyOrigin(spriteDataSource.XML.ChildPosition("Justify")); sprite.Justify = new Vector2?(spriteDataSource.XML.ChildPosition("Justify")); } else if (spriteDataSource.XML.HasChild("Origin")) { sprite.Origin = spriteDataSource.XML.ChildPosition("Origin"); } if (spriteDataSource.XML.HasChild("Position")) { sprite.Position = spriteDataSource.XML.ChildPosition("Position"); } if (spriteDataSource.XML.HasAttr("start")) { sprite.Play(spriteDataSource.XML.Attr("start"), false, false); } } }