public override void Update(BaseScene scene, FrameTick elapsedTime) { CurrentBurstTime += elapsedTime; while (CurrentBurstTime >= Math.Max(1, BurstTime)) { CurrentBurstTime -= Math.Max(1, BurstTime); for (int ii = 0; ii < ParticlesPerBurst; ii++) { List <int> openDirs = getOpenDirs(); int openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)]; Coverages[openIndex] = true; double angle = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4; Loc startDelta = new Loc((int)Math.Round(Math.Cos(angle) * Range), (int)Math.Round(Math.Sin(angle) * Range) / 3); if (Anims.Count > 0) { Loc randDiff = new Loc((int)((MathUtils.Rand.NextDouble() * 2 - 1) * SpeedDiff), 0); int heightDiff = (int)((MathUtils.Rand.NextDouble() * 2 - 1) * HeightDiff); IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)DrawLayer.Normal].Add(chosenAnim.CreateParticle(Origin + startDelta, randDiff, Loc.Zero, StartHeight + heightDiff, HeightSpeed, 0, AnimDir)); } } CurrentBursts++; if (CurrentBursts >= Bursts) { break; } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { ActionTime += elapsedTime; CurrentBurstTime += elapsedTime; while (CurrentBurstTime >= Math.Max(1, BurstTime)) { CurrentBurstTime -= Math.Max(1, BurstTime); for (int ii = 0; ii < ParticlesPerBurst; ii++) { List <int> openDirs = getOpenDirs(); int openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)]; Coverages[openIndex] = true; double angle = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4; int dist = MathUtils.Rand.Next(Range + 1); if (dist >= 0 && dist <= Range) { Loc startDelta = new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); Loc randDiff = new Loc((int)((MathUtils.Rand.NextDouble() * 2 - 1) * SpeedDiff), 0); if (Anims.Count > 0) { IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(Origin + startDelta, randDiff, Loc.Zero, StartHeight + LocHeight, HeightSpeed, 0, Dir)); } } } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { CurrentBurstTime += elapsedTime; while (CurrentBurstTime >= Math.Max(1, BurstTime)) { CurrentBurstTime -= Math.Max(1, BurstTime); for (int ii = 0; ii < ParticlesPerBurst; ii++) { int particleSpeed = Speed + MathUtils.Rand.Next(SpeedDiff); int startDist = MathUtils.Rand.Next(StartDistance); Loc startDelta = new Loc(startDist + GraphicsManager.ScreenWidth / 2, MathUtils.Rand.Next(GraphicsManager.ScreenHeight) - GraphicsManager.ScreenHeight / 2) + Origin; if (Anims.Count > 0) { int totalTime = GraphicsManager.ScreenWidth + startDist + GraphicsManager.TileSize * 2; if (particleSpeed != 0) { totalTime *= GraphicsManager.MAX_FPS; totalTime = (totalTime - 1) / -particleSpeed + 1; } IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(totalTime, startDelta, new Loc(particleSpeed, 0), Loc.Zero, 0, 0, 0, Dir8.Left)); } } CurrentBursts++; if (CurrentBursts >= Math.Max(1, Bursts)) { break; } } }
protected override void ReleaseAnim(BaseScene scene, int dist, Loc startLoc, Loc speed) { int totalTime = Range - dist; if (Speed > 0) { totalTime *= GraphicsManager.MAX_FPS; totalTime /= Speed; } IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(totalTime, startLoc, speed, Loc.Zero, LocHeight, 0, 0, speed.ApproximateDir8())); }
public override void Update(BaseScene scene, FrameTick elapsedTime) { CurrentShotTime += elapsedTime; while (CurrentShotTime >= BurstTime) { CurrentShotTime -= BurstTime; int range = Range; Vector2 totalDistance = (Dir.GetLoc() * (range - StartDistance)).ToVector2(); double angle = MathUtils.Rand.NextDouble() * Math.PI * 2; int dist = MathUtils.Rand.Next(EndDiff + 1); Vector2 endDelta = new Vector2((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); totalDistance += endDelta; //pixels float totalTime = range - StartDistance; //seconds if (Speed > 0) { totalTime /= Speed; } //pixels Vector2 particleSpeed = totalDistance; //pixels per second if (totalTime > 0) { particleSpeed /= totalTime; } Loc startDelta = Dir.GetLoc() * StartDistance; if (Anims.Count > 0) { IParticleEmittable chosenAnim = Anims[CurrentShots % Anims.Count]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle((int)Math.Round(totalTime * GraphicsManager.MAX_FPS), Origin + startDelta, particleSpeed.ToLoc(), Loc.Zero, LocHeight, 0, 0, Dir)); } CurrentShots++; if (CurrentShots >= Shots) { break; } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { ActionTime += elapsedTime; int prevRadius = CurrentRadius; CurrentRadius = (int)ActionTime.FractionOf(Speed, GraphicsManager.MAX_FPS); if (CurrentRadius > Range) { CurrentRadius = Range; } int prevParticles = 0; int currentParticles = TotalParticles; if (Range > 0) { prevParticles = TotalParticles * prevRadius * prevRadius / Range / Range; currentParticles = TotalParticles * CurrentRadius * CurrentRadius / Range / Range; } for (int ii = prevParticles; ii < currentParticles; ii++) { List <int> openDirs = getOpenDirs(); int openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)]; Coverages[openIndex] = true; double angle = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4; int dist = CurrentRadius; if (dist >= 0 && dist <= Range) { Loc startDelta = new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); Loc randDiff = new Loc((int)((MathUtils.Rand.NextDouble() * 2 - 1) * SpeedDiff), 0); if (Anims.Count > 0) { IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(Origin + startDelta, randDiff, Loc.Zero, StartHeight, HeightSpeed, 0, Dir)); } } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { CurrentShotTime += elapsedTime; while (CurrentShotTime >= BurstTime) { CurrentShotTime -= BurstTime; Loc particleSpeed = Dir.GetLoc() * Speed; Loc startDelta = Dir.GetLoc() * StartDistance; int range = Range; if (Dir.IsDiagonal()) { range = (int)(range * 1.4142136); } int totalTime = range - StartDistance; if (Speed > 0) { totalTime *= GraphicsManager.MAX_FPS; totalTime /= Speed; } if (Anims.Count > 0) { IParticleEmittable chosenAnim = Anims[CurrentShots % Anims.Count]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(totalTime, Origin + startDelta, particleSpeed, Loc.Zero, LocHeight, 0, 0, Dir)); } CurrentShots++; if (CurrentShots >= Shots) { break; } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { CurrentBurstTime += elapsedTime; while (CurrentBurstTime >= Math.Max(1, BurstTime)) { CurrentBurstTime -= Math.Max(1, BurstTime); for (int ii = 0; ii < ParticlesPerBurst; ii++) { List <int> openDirs = getOpenDirs(); int openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)]; Coverages[openIndex] = true; double angle = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4; int dist = Math.Min(Range, MathUtils.Rand.Next(StartDistance + 1)); Loc startDelta = new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); if (AreaLimit == Dungeon.Hitbox.AreaLimit.Cone) { angle = (45 * (int)Dir + 45) * Math.PI / 180 + angle / 4; } else if (AreaLimit == Dungeon.Hitbox.AreaLimit.Sides) { if (Dir.IsDiagonal()) { //either +135 or -135 from the direction if (MathUtils.Rand.Next(2) == 0) { angle = (45 * (int)Dir + 90 + 135) * Math.PI / 180; } else { angle = (45 * (int)Dir + 90 - 135) * Math.PI / 180; } } else { //either +90 or -90 from the direction if (MathUtils.Rand.Next(2) == 0) { angle = (45 * (int)Dir + 90 + 90) * Math.PI / 180; } else { angle = (45 * (int)Dir + 90 - 90) * Math.PI / 180; } } } Loc particleSpeed = new Loc((int)(Math.Cos(angle) * Speed), (int)(Math.Sin(angle) * Speed)); if (Anims.Count > 0) { //pixels int resultRange = MathUtils.Rand.Next(dist, Range + RangeDiff) + 1; int totalTime = resultRange - dist; if (Speed > 0) { totalTime *= GraphicsManager.MAX_FPS; totalTime /= Speed; } float maxHeight = HeightRatio * resultRange; float velocity = 4 * maxHeight * GraphicsManager.MAX_FPS / totalTime; float acceleration = -8 * maxHeight * GraphicsManager.MAX_FPS * GraphicsManager.MAX_FPS / totalTime / totalTime; IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(totalTime, Origin + startDelta, particleSpeed, Loc.Zero, 0, (int)Math.Round(velocity), (int)Math.Round(acceleration), particleSpeed.ApproximateDir8())); } } CurrentBursts++; if (CurrentBursts >= Bursts) { break; } } }
protected virtual void ReleaseAnim(BaseScene scene, int dist, Loc startLoc, Loc speed) { IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(startLoc, speed, Loc.Zero, LocHeight, 0, 0, speed.ApproximateDir8())); }
public override void Update(BaseScene scene, FrameTick elapsedTime) { ActionTime += elapsedTime; int prevRadius = CurrentRadius; CurrentRadius = (int)ActionTime.FractionOf(Speed, GraphicsManager.MAX_FPS); if (CurrentRadius > Range) { CurrentRadius = Range; } int totalParticles = (int)Math.Round(ParticlesPerTile * (Math.PI * Range * Range) / GraphicsManager.TileSize / GraphicsManager.TileSize); int prevParticles = 0; int currentParticles = totalParticles; if (Range > 0) { prevParticles = totalParticles * prevRadius * prevRadius / Range / Range; currentParticles = totalParticles * CurrentRadius * CurrentRadius / Range / Range; } for (int ii = prevParticles; ii < currentParticles; ii++) { List <int> openDirs = getOpenDirs(); int openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)]; Coverages[openIndex] = true; double angle = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4; Loc startDelta = new Loc(); int dist = CurrentRadius; if (AreaLimit == Dungeon.Hitbox.AreaLimit.Cone) { angle = (45 * (int)Dir + 45) * Math.PI / 180 + angle / 4; } else if (AreaLimit == Dungeon.Hitbox.AreaLimit.Sides) { dist -= GraphicsManager.TileSize / 2; int diffDist = MathUtils.Rand.Next(GraphicsManager.TileSize / 2 + 1); startDelta += new Loc((int)Math.Round(Math.Cos(angle) * diffDist), (int)Math.Round(Math.Sin(angle) * diffDist)); if (Dir.IsDiagonal()) { //either +135 or -135 from the direction if (MathUtils.Rand.Next(2) == 0) { angle = (45 * (int)Dir + 90 + 135) * Math.PI / 180; } else { angle = (45 * (int)Dir + 90 - 135) * Math.PI / 180; } } else { //either +90 or -90 from the direction if (MathUtils.Rand.Next(2) == 0) { angle = (45 * (int)Dir + 90 + 90) * Math.PI / 180; } else { angle = (45 * (int)Dir + 90 - 90) * Math.PI / 180; } } } if (dist >= 0 && dist <= Range) { startDelta += new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); Loc randDiff = new Loc((int)((MathUtils.Rand.NextDouble() * 2 - 1) * SpeedDiff), 0); if (Anims.Count > 0) { IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateParticle(Origin + startDelta, randDiff, Loc.Zero, StartHeight, HeightSpeed, 0, Dir)); } } } }