private void OnMagicEffect(Packet props) { MapPosition Position = (MapPosition)props["Position"]; MagicEffect Effect = new MagicEffect(Viewport.GameData, (int)props["Effect"]); TileAnimations Animations = null; if (!PlayingAnimations.TryGetValue(Position, out Animations)) { Animations = new TileAnimations(); PlayingAnimations.Add(Position, Animations); } Animations.Effects.Add(Effect); }
private void OnAnimatedText(Packet props) { MapPosition Position = (MapPosition)props["Position"]; String Text = (String)props["Text"]; int Color = (int)props["Color"]; TileAnimations Animations = null; if (!PlayingAnimations.TryGetValue(Position, out Animations)) { Animations = new TileAnimations(); PlayingAnimations.Add(Position, Animations); } Animations.Effects.Add(new AnimatedText(Text, Color)); }
public void DrawScene(SpriteBatch Batch, GameTime Time, ClientViewport Viewport, Dictionary <MapPosition, TileAnimations> PlayingAnimations = null) { MapPosition Center = Viewport.ViewPosition; int StartZ = 7; int EndZ = Center.Z; if (Center.Z <= 7) { Center.Y -= (7 - Center.Z); Center.X -= (7 - Center.Z); } else { StartZ = Math.Min(Center.Z + 2, 15); EndZ = Center.Z; Center.X -= 2; Center.Y -= 2; } Vector2 TopLeft = new Vector2( -(Center.X - 7) * 32, -(Center.Y - 5) * 32 ); for (int Z = StartZ; Z >= EndZ; --Z) { for (int X = Center.X - 8; X <= Center.X + 9; ++X) { for (int Y = Center.Y - 6; Y <= Center.Y + 7; ++Y) { ClientTile Tile = Viewport.Map[new MapPosition(X, Y, Z)]; Vector2 pos = new Vector2(32 * X + TopLeft.X, 32 * Y + TopLeft.Y); TileAnimations Animations = null; if (PlayingAnimations != null && Tile != null) { PlayingAnimations.TryGetValue(Tile.Position, out Animations); } DrawTile(Batch, Time, pos, Tile, Animations); } } TopLeft -= new Vector2(32, 32); } }
public void DrawSceneForeground(SpriteBatch Batch, Vector2 ScreenOffset, Vector2 Scale, GameTime Time, ClientViewport Viewport, Dictionary <MapPosition, TileAnimations> PlayingAnimations = null) { MapPosition Center = Viewport.ViewPosition; Vector2 TopLeft = new Vector2( -(Center.X - 7) * 32, -(Center.Y - 5) * 32 ); int StartZ = 7; int EndZ = Center.Z; if (Center.Z <= 7) { Center.Y -= (7 - Center.Z); Center.X -= (7 - Center.Z); } else { StartZ = Math.Min(Center.Z + 2, 15); EndZ = Center.Z; } for (int X = Center.X - 8; X <= Center.X + 8; ++X) { for (int Y = Center.Y - 6; Y <= Center.Y + 6; ++Y) { ClientTile Tile = Viewport.Map[new MapPosition(X, Y, Center.Z)]; Vector2 DrawOffset = new Vector2(32 * X + TopLeft.X, 32 * Y + TopLeft.Y); DrawOffset *= Scale; TileAnimations Animations = null; if (PlayingAnimations != null && Tile != null) { PlayingAnimations.TryGetValue(Tile.Position, out Animations); } DrawTileForeground(Batch, Time, ScreenOffset + DrawOffset, Tile, Animations); } } }
private void OnShootEffect(Packet props) { MapPosition FromPosition = (MapPosition)props["From"]; MapPosition ToPosition = (MapPosition)props["To"]; int Type = (int)props["Effect"]; MapPosition Max = new MapPosition(); Max.X = Math.Max(FromPosition.X, ToPosition.X); Max.Y = Math.Max(FromPosition.Y, ToPosition.Y); Max.Z = ToPosition.Z; TileAnimations Animations = null; if (!PlayingAnimations.TryGetValue(Max, out Animations)) { Animations = new TileAnimations(); PlayingAnimations.Add(Max, Animations); } Animations.Effects.Add(new DistanceEffect(Viewport.GameData, Type, FromPosition, ToPosition)); }
public void DrawTileForeground(SpriteBatch Batch, GameTime Time, Vector2 Offset, ClientTile Tile, TileAnimations Animations) { if (Tile == null) { return; } foreach (ClientThing Thing in Tile.Objects) { if (Thing is ClientCreature) { DrawCreatureBars(Batch, (ClientCreature)Thing, Offset); } } if (Animations != null) { foreach (GameEffect Effect in Animations.Effects) { if (!Effect.Expired && Effect is AnimatedText) { AnimatedText Text = (AnimatedText)Effect; Vector2 DrawOffset = Offset + Text.Offset; // DrawOffset.X += 16; // DrawOffset.Y += 26; DrawBoldedText(Batch, Text.Text, DrawOffset, true, MakeColor(Text.Color)); } } } }
public void DrawTile(SpriteBatch Batch, GameTime Time, Vector2 Position, ClientTile Tile, TileAnimations Animations) { if (Tile == null) { return; } // Draw ground if (Tile.Ground != null) { DrawSprite(Batch, Time, Tile, Tile.Ground.Sprite, Tile.Ground.Subtype, -1, ref Position, Color.White); } foreach (ClientThing Thing in Tile.ObjectsByDrawOrder) { if (Thing is ClientCreature) { DrawCreature(Batch, Time, (ClientCreature)Thing, Position, Color.White); } else { ClientItem Item = (ClientItem)Thing; DrawSprite(Batch, Time, Tile, Item.Sprite, Item.Subtype, -1, ref Position, Color.White); } } if (Animations != null) { foreach (GameEffect Effect in Animations.Effects) { if (!Effect.Expired) { if (Effect is MagicEffect) { MagicEffect Magic = (MagicEffect)Effect; DrawSprite(Batch, Time, Tile, Magic.Sprite, -1, Magic.Frame, Position, Color.White); } else if (Effect is DistanceEffect) { DistanceEffect Distance = (DistanceEffect)Effect; DrawSprite(Batch, Time, Tile, Distance.Sprite, Distance.Frame, 0, Position + Distance.Offset, Color.White); } } } } }
public void DrawTileForeground(SpriteBatch Batch, GameTime Time, Vector2 Offset, ClientTile Tile, TileAnimations Animations) { if (Tile == null) return; foreach (ClientThing Thing in Tile.Objects) { if (Thing is ClientCreature) DrawCreatureBars(Batch, (ClientCreature)Thing, Offset); } if (Animations != null) { foreach (GameEffect Effect in Animations.Effects) { if (!Effect.Expired && Effect is AnimatedText) { AnimatedText Text = (AnimatedText)Effect; Vector2 DrawOffset = Offset + Text.Offset; // DrawOffset.X += 16; // DrawOffset.Y += 26; DrawBoldedText(Batch, Text.Text, DrawOffset, true, MakeColor(Text.Color)); } } } }
public void DrawTile(SpriteBatch Batch, GameTime Time, Vector2 Position, ClientTile Tile, TileAnimations Animations) { if (Tile == null) return; // Draw ground if (Tile.Ground != null) DrawSprite(Batch, Time, Tile, Tile.Ground.Sprite, Tile.Ground.Subtype, -1, ref Position, Color.White); foreach (ClientThing Thing in Tile.ObjectsByDrawOrder) { if (Thing is ClientCreature) DrawCreature(Batch, Time, (ClientCreature)Thing, Position, Color.White); else { ClientItem Item = (ClientItem)Thing; DrawSprite(Batch, Time, Tile, Item.Sprite, Item.Subtype, -1, ref Position, Color.White); } } if (Animations != null) { foreach (GameEffect Effect in Animations.Effects) { if (!Effect.Expired) { if (Effect is MagicEffect) { MagicEffect Magic = (MagicEffect)Effect; DrawSprite(Batch, Time, Tile, Magic.Sprite, -1, Magic.Frame, Position, Color.White); } else if (Effect is DistanceEffect) { DistanceEffect Distance = (DistanceEffect)Effect; DrawSprite(Batch, Time, Tile, Distance.Sprite, Distance.Frame, 0, Position + Distance.Offset, Color.White); } } } } }