public override void Draw(SpriteBatch spriteBatch, Loc offset) { if (Finished) { return; } DirSheet sheet = GraphicsManager.GetBackground(Anim.AnimIndex); int frame = Time.ToFrames(); Loc diff = Movement * frame / 60 - offset; float fade = 1f;// (float)Math.Min(Math.Min(FadeTime, frame), (TotalTime > 0) ? Math.Min(FadeTime, TotalTime - frame) : FadeTime) / FadeTime; if (sheet.Width == 1 && sheet.Height == 1) { sheet.DrawTile(spriteBatch, new Rectangle(0, 0, GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight), 0, 0, Color * ((float)Anim.Alpha * fade / 255f)); } else { for (int x = diff.X % sheet.TileWidth - sheet.TileWidth; x < GraphicsManager.ScreenWidth; x += sheet.TileWidth) { for (int y = diff.Y % sheet.TileHeight - sheet.TileHeight; y < GraphicsManager.ScreenHeight; y += sheet.TileHeight) { sheet.DrawDir(spriteBatch, new Vector2(x, y), Anim.GetCurrentFrame(Time, sheet.TotalFrames), Anim.AnimDir, Color * ((float)Anim.Alpha * fade / 255f)); } } } }
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 int GetCurrentFrame(FrameTick time, int totalFrames) { int frameStart = (StartFrame > -1) ? StartFrame : 0; int frameEnd = (EndFrame > -1) ? EndFrame + 1 : totalFrames; int actualTotal = frameEnd - frameStart; if (actualTotal <= 1) { return(frameStart); } return((int)(time.ToFrames() / FrameTime % actualTotal) + frameStart); }
private int getCurrentFrame(FrameTick time) { int countingFrameTicks = 0; int curFrames = time.ToFrames() % TotalFrameTime; for (int ii = 0; ii < Frames.Count; ii++) { countingFrameTicks += Frames[ii].TotalTime; if (curFrames < countingFrameTicks) { return(ii); } } return(0); }
public override void Draw(SpriteBatch spriteBatch, Loc offset) { if (Finished) { return; } DirSheet sheet = GraphicsManager.GetBackground(Anim.AnimIndex); int frame = Time.ToFrames(); Color color = StartColor; if (frame < FadeInTime) { color = interpolateColor(StartColor, EndColor, frame, FadeInTime); } else if (frame < FadeInTime + HoldTime) { color = EndColor; } else if (frame < FadeInTime + HoldTime + FadeOutTime) { int endTime = FadeInTime + HoldTime + FadeOutTime; color = interpolateColor(StartColor, EndColor, endTime - frame, FadeOutTime); } Loc diff = -offset; if (sheet.Width == 1 && sheet.Height == 1) { sheet.DrawTile(spriteBatch, new Rectangle(0, 0, GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight), 0, 0, color); } else { for (int x = diff.X % sheet.TileWidth - sheet.TileWidth; x < GraphicsManager.ScreenWidth; x += sheet.TileWidth) { for (int y = diff.Y % sheet.TileHeight - sheet.TileHeight; y < GraphicsManager.ScreenHeight; y += sheet.TileHeight) { sheet.DrawDir(spriteBatch, new Vector2(x, y), Anim.GetCurrentFrame(Time, sheet.TotalFrames), Anim.GetDrawDir(Dir8.None), color); } } } }
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; } }