public void Draw(SpriteBatch spriteBatch, Loc parentLoc, Dir8 dir, int locHeight, float sizeRatio) { foreach (MultiAnimSprite sprite in Sprites) { DirSheet sheet = GraphicsManager.GetAttackSheet(sprite.AnimIndex); sheet.DrawDir(spriteBatch, new Vector2(parentLoc.X, parentLoc.Y - locHeight) + sprite.Position.ToVector2() * sizeRatio, sprite.Frame, DirExt.AddAngles(dir, sprite.AnimDir), Color.White * ((float)sprite.Alpha / 255)); } }
public Rect GetFrameRect() { Rect rect = new Rect(); foreach (MultiAnimSprite sprite in Sprites) { rect = Rect.Union(rect, new Rect(sprite.Position, new Loc(GraphicsManager.GetAttackSheet(sprite.AnimIndex).Width, GraphicsManager.GetAttackSheet(sprite.AnimIndex).Height))); } return(rect); }
public override void Update(BaseScene scene, FrameTick elapsedTime) { base.Update(scene, elapsedTime); if (Finished && ResultAnim.AnimIndex != "") { int totalTime = ResultAnim.FrameTime * ResultAnim.GetTotalFrames(GraphicsManager.GetAttackSheet(ResultAnim.AnimIndex).TotalFrames); WrappedRainAnim anim = new WrappedRainAnim(ResultAnim, totalTime); anim.SetupEmitted(MapLoc, 0, Dir8.None); scene.Anims[(int)Layer].Add(anim); } }
public override void Draw(SpriteBatch spriteBatch, Loc offset) { if (Finished) { return; } Loc drawLoc = GetDrawLoc(offset); DirSheet sheet = GraphicsManager.GetAttackSheet(Anim.AnimIndex); sheet.DrawDir(spriteBatch, new Vector2(drawLoc.X, drawLoc.Y - LocHeight), Anim.GetCurrentFrame(ActionTime + FrameOffset, GraphicsManager.GetAttackSheet(Anim.AnimIndex).TotalFrames), Anim.GetDrawDir(Direction), Color.White * ((float)Anim.Alpha / 255)); }
public override void Draw(SpriteBatch spriteBatch, Loc offset) { if (Finished) return; Loc drawLoc = GetDrawLoc(offset); Loc modOffset = new Loc(GraphicsManager.ScreenWidth - offset.X % GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight - offset.Y % GraphicsManager.ScreenHeight); drawLoc = drawLoc + modOffset; Vector2 drawDest = new Vector2(drawLoc.X % GraphicsManager.ScreenWidth, (drawLoc.Y - LocHeight) % GraphicsManager.ScreenHeight); DirSheet sheet = GraphicsManager.GetAttackSheet(Anim.AnimIndex); sheet.DrawDir(spriteBatch, drawDest, Anim.GetCurrentFrame(ActionTime, GraphicsManager.GetAttackSheet(Anim.AnimIndex).TotalFrames), DirExt.AddAngles(Direction, Anim.AnimDir), Color.White * ((float)Anim.Alpha / 255)); }
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++) { if (Anims.Count > 0) { 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 = StartDistance + MathUtils.Rand.Next(StartVariance + 1); Loc startDelta = new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist)); double endAngle = MathUtils.Rand.NextDouble() * Math.PI * 2; int endDist = MathUtils.Rand.Next(EndDistance + 1); Loc endDelta = new Loc((int)Math.Round(Math.Cos(endAngle) * endDist), (int)Math.Round(Math.Sin(endAngle) * endDist)); Loc particleSpeed = ((UseDest ? Destination : Origin) + endDelta - (Origin + startDelta)) * GraphicsManager.MAX_FPS / TravelTime; Loc startLoc = Origin + startDelta; { AnimData animData = Anims[MathUtils.Rand.Next(Anims.Count)]; AnimData scaledAnim = new AnimData(animData); DirSheet fxSheet = GraphicsManager.GetAttackSheet(animData.AnimIndex); scaledAnim.FrameTime = (int)Math.Round((float)TravelTime / scaledAnim.GetTotalFrames(fxSheet.TotalFrames) / Math.Max(1, Cycles)); scaledAnim.FrameTime = Math.Max(1, scaledAnim.FrameTime); ParticleAnim anim = new ParticleAnim(scaledAnim, 0, TravelTime); anim.SetupEmitted(startLoc, particleSpeed, Loc.Zero, 0, 0, 0, particleSpeed.ApproximateDir8()); scene.Anims[(int)Layer].Add(anim); } } } CurrentBursts++; if (CurrentBursts >= Math.Max(1, Bursts)) { break; } } }
public void SetUp() { TotalTime = Cycles > 0 ? Anim.FrameTime * Anim.GetTotalFrames(GraphicsManager.GetAttackSheet(Anim.AnimIndex).TotalFrames) * Math.Max(1, Cycles) : TotalTime; }
public override Loc GetDrawSize() { return(new Loc(GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileWidth, GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileHeight)); }
public override Loc GetDrawLoc(Loc offset)//TODO: transfer this offset out of the draw call and into the call of whatever emitter created it (or the creator of that emitter) { return(new Loc(MapLoc.X + GraphicsManager.TileSize / 2 - GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileWidth / 2, MapLoc.Y + GraphicsManager.TileSize / 2 - GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileHeight / 2) - offset); }
public override Loc GetDrawLoc(Loc offset) { return(new Loc(MapLoc.X - GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileWidth / 2, MapLoc.Y)); }
public override Loc GetDrawLoc(Loc offset) { return(new Loc(MapLoc.X + GraphicsManager.TileSize / 2 - GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileWidth / 2, MapLoc.Y + GraphicsManager.TileSize / 2 - GraphicsManager.GetAttackSheet(Anim.AnimIndex).TileHeight / 2) - offset); }
public Emote(AnimData anim, int height, int cycles) { Anim = anim; locHeight = height; TotalTime = anim.FrameTime * anim.GetTotalFrames(GraphicsManager.GetAttackSheet(anim.AnimIndex).TotalFrames) * cycles; }