public override void Update(BaseScene scene, FrameTick elapsedTime) { base.Update(scene, elapsedTime); if (ActionTime < LingerStart) { locHeight = StartHeight; mapLoc = StartLoc; } else if (ActionTime >= MovingTime + LingerStart) { locHeight = EndHeight; mapLoc = EndLoc; } else { FrameTick midTime = ActionTime - LingerStart; locHeight = StartHeight + (int)midTime.FractionOf((EndHeight - StartHeight), MovingTime); mapLoc = StartLoc + (EndLoc - StartLoc) * midTime.ToFrames() / MovingTime; } if (Finished) { scene.Anims[(int)Layer].Add(ResultAnim.CreateStatic(MapLoc, LocHeight, Direction)); } }
public void Update(FrameTick elapsedTime, ref Loc offsetLoc) { ShakeTime += elapsedTime; if (ShakeTime < MaxShakeTime) { int divShake = MinShake + (int)ShakeTime.FractionOf(MaxShake, MaxShakeTime); offsetLoc += new Loc(MathUtils.Rand.Next(divShake), MathUtils.Rand.Next(divShake)); } //else // offsetLoc = new Loc(); }
public override void Update(BaseScene scene, FrameTick elapsedTime) { Time += elapsedTime; if (Time >= ITEM_ACTION_TIME) { finished = true; locHeight = 0; mapLoc = EndLoc * GraphicsManager.TileSize; } else { locHeight = (int)Time.FractionOf(MAX_TILE_HEIGHT * GraphicsManager.TileSize, ITEM_ACTION_TIME); mapLoc = EndLoc * GraphicsManager.TileSize; } }
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) { ActionTime += elapsedTime; if (ActionTime >= TOTAL_ANIM_TIME) { finished = true; } else { locHeight = (int)ActionTime.FractionOf(GraphicsManager.TileSize / 3, TOTAL_ANIM_TIME) + GraphicsManager.TileSize / 2; if (ActionTime >= TOTAL_SOLID_TIME) { Opacity = (float)(255 - (int)(ActionTime - TOTAL_SOLID_TIME).FractionOf(255, TOTAL_ANIM_TIME - TOTAL_SOLID_TIME)) / 255; } else { Opacity = 1f; } } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { base.Update(scene, elapsedTime); if (ActionTime < LingerStart) { locHeight = StartHeight; mapLoc = StartLoc; } else if (ActionTime >= MovingTime + LingerStart) { locHeight = EndHeight; mapLoc = EndLoc; } else { FrameTick midTime = ActionTime - LingerStart; locHeight = StartHeight + (int)midTime.FractionOf((EndHeight - StartHeight), MovingTime); mapLoc = StartLoc + (EndLoc - StartLoc) * midTime.ToFrames() / MovingTime; } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { Time += elapsedTime; if (Time >= ITEM_ACTION_TIME) { if (Time >= ITEM_ACTION_TIME + WaitTime) { finished = true; } locHeight = 0; mapLoc = EndLoc * GraphicsManager.TileSize; } else { locHeight = AnimMath.GetArc(MaxHeight, FrameTick.FrameToTick(ITEM_ACTION_TIME), Time.Ticks); Loc mapDiff = (EndLoc - StartLoc) * GraphicsManager.TileSize; mapDiff = new Loc((int)(mapDiff.X * Time.FractionOf(ITEM_ACTION_TIME)), (int)(mapDiff.Y * Time.FractionOf(ITEM_ACTION_TIME))); mapLoc = mapDiff + StartLoc * GraphicsManager.TileSize; } }
public override void Update(BaseScene scene, FrameTick elapsedTime) { ActionTime += elapsedTime; int prevRadius = CurrentRadius; CurrentRadius = (int)ActionTime.FractionOf(Speed, GraphicsManager.MAX_FPS); int endRange = Range + RangeDiff; if (CurrentRadius > endRange) { CurrentRadius = endRange; } int totalParticles = (int)Math.Round(ParticlesPerTile * (Math.PI * endRange * endRange) / GraphicsManager.TileSize / GraphicsManager.TileSize); int prevParticles = 0; int currentParticles = totalParticles; if (Range > 0) { prevParticles = totalParticles * prevRadius * prevRadius / endRange / endRange; currentParticles = totalParticles * CurrentRadius * CurrentRadius / endRange / endRange; } 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; } } } startDelta += new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); if (Anims.Count > 0) { IEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)]; scene.Anims[(int)Layer].Add(chosenAnim.CreateStatic(Origin + startDelta, LocHeight, Dir)); } } }