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 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 Burst(Vector2 position, float direction, int count = 1, ParticleType particleType = null) { if (particleType == null) { particleType = ParticleTypes.Dust; } Vector2 vector = Util.AngleToVector(direction - 1.570796f, 4f); vector.x = Math.Abs((float)vector.x); vector.y = Math.Abs((float)vector.y); for (int index = 0; index < count; ++index) { //创建N个粒子,进行发射 ParticleController.instance.Particles.Emit(particleType, position + RandomUtil.Random.Range(-vector, vector), direction); } }
public void Emit(ParticleType type, Vector2 position, float direction) { type.Create(this.particles[this.nextSlot], position, direction); this.particles[this.nextSlot].Reload(); this.nextSlot = (this.nextSlot + 1) % this.particles.Length; }