/// <summary>Converts a grid point to pixel point</summary> /// <param name="x">A X point of pixel coordinates.</param> /// <param name="y">A Y point of pixel coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Pixel point.</returns> public static Point2D Grid2Pixel(int x, int y, IEngineCamera camera) { int tileWidth = (camera != null ? camera.TileWidth : TileWidth); int tileHeight = (camera != null ? camera.TileHeight : TileHeight); return(Grid2Pixel(x, y, tileWidth, tileHeight)); }
public static Point2D Grid2PixelCenter(int x, int y, IEngineCamera camera) { int tileWidth = (camera != null ? camera.TileWidth : TileWidth); int tileHeight = (camera != null ? camera.TileHeight : TileHeight); return(Grid2Pixel(x, y) + new Point2D(tileWidth / 2, tileHeight / 2)); }
public void Draw(SpriteBatch batch, IEngineCamera camera, double totalSeconds, ETileDrawType drawType, Point2D min, Point2D max, bool makePreview) { bool drawBackground = (drawType & ETileDrawType.BackGround) == ETileDrawType.BackGround; bool drawForeground = (drawType & ETileDrawType.ForeGround) == ETileDrawType.ForeGround; foreach (TileLayer layer in Layers) { if (!(layer.IsBackground && drawBackground) && !(layer.IsForeground && drawForeground)) { continue; } layer.Draw(batch, camera, min, max, 0f, makePreview); } if ((drawType & ETileDrawType.Animation) == ETileDrawType.Animation) { AnimationLayer.Draw(batch, camera, totalSeconds, min, max); } if ((drawType & ETileDrawType.Fog) == ETileDrawType.Fog) { DrawFog(batch, camera, min, max); } }
public void Draw(SpriteBatch spriteBatch, IEngineCamera camera, double totalSeconds, Point2D basePos) { Update(totalSeconds); if (mCurrentFrame == -1) { return; } Frames[mCurrentFrame].Draw(spriteBatch, basePos); }
public void Draw(SpriteBatch batch, IEngineCamera camera, double TotalSeconds, Point2D min, Point2D max) { for (var x = min.X; x < max.X; x++) { for (var y = min.Y; y < max.Y; y++) { var ani = GetCell(x, y); if (ani == null) { continue; } // Draw from bottom middle of the Cell ani.Draw(batch, camera, TotalSeconds, new Point2D(x * camera.TileWidth + camera.TileWidth / 2, y * camera.TileHeight + camera.TileHeight / 2)); } } }
public void DrawFog(SpriteBatch spriteBatch, IEngineCamera camera, Point2D min, Point2D max) { if (FogIndex == string.Empty) { return; } var fogTex = EngineCore.ContentLoader.GetFog(FogIndex); var screenSize = new Point(Constants.GraphicsDevice.Viewport.Width / camera.TileWidth, Constants.GraphicsDevice.Viewport.Height / camera.TileHeight); for (var x = 0; x < Width; x += screenSize.X) { for (var y = 0; y < Width; y += screenSize.Y) { spriteBatch.Draw(fogTex, new Rectangle(x * camera.TileWidth, y * camera.TileHeight, screenSize.X * camera.TileWidth, screenSize.Y * camera.TileHeight), FogColor * FogDense); } } }
public void Draw(SpriteBatch batch, IEngineCamera camera, Point2D min, Point2D max) { Rectangle destRect; Texture2D drawTex = Constants.TextureNotMoveable; Color drawColor = Constants.ColorNotMoveable; for (int x = min.X; x < max.X; x++) { for (int y = min.Y; y < max.Y; y++) { ECollisionType type = GetCell(x, y); if (type == ECollisionType.Moveable) { drawTex = Constants.TextureMoveable; drawColor = Constants.ColorMoveable; } else if (type == ECollisionType.Water) { drawTex = Constants.TextureWater; drawColor = Constants.ColorWater; } else if (type == ECollisionType.Underwater) { drawTex = Constants.TextureUnderwater; drawColor = Constants.ColorUnderwater; } else { // Default draw to not moveable drawTex = Constants.TextureNotMoveable; drawColor = Constants.ColorNotMoveable; } destRect = new Rectangle(x * camera.TileWidth, y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(drawTex, destRect, drawColor); } } }
/// <summary>Converts a grid point to pixel point</summary> /// <param name="p">A point of grid coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Pixel point.</returns> public static Point2D Grid2Pixel(Point2D p, IEngineCamera camera) { return Grid2Pixel(p.X, p.Y, camera); }
public void Draw(SpriteBatch batch, IEngineCamera camera, double TotalSeconds) { Draw(batch, camera, TotalSeconds, new Point2D(0, 0), new Point2D(Width, Height)); }
/// <summary>Converts a pixel point to grid point</summary> /// <param name="p">A point of pixel coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Grid point.</returns> public static Point2D Pixel2Grid(Point2D p, IEngineCamera camera) { return Pixel2Grid(p.X, p.Y, camera); }
/// <summary> /// Draws all layers using the camera viewport /// </summary> /// <param name="batch"></param> /// <param name="camera"></param> /// <param name="alphaMod"></param> /// <param name="makePreview"></param> public void Draw(SpriteBatch batch, IEngineCamera camera, float alphaMod, bool makePreview) { var min = new Point2D(camera.X, camera.Y); var max = new Point2D(camera.X + camera.Viewport.Width, camera.Y + camera.Viewport.Height); min = TileCell.Pixel2Grid(min); max = TileCell.Pixel2Grid(max); Draw(batch, camera, min, max, alphaMod, makePreview); }
/// <summary> /// Draws all layers using min/max (grid based!) /// </summary> /// <param name="batch"></param> /// <param name="camera"></param> /// <param name="min">grid based start position</param> /// <param name="max">grid based max position</param> /// <param name="alphaMod"></param> /// <param name="makePreview"></param> public void Draw(SpriteBatch batch, IEngineCamera camera, Point2D min, Point2D max, float alphaMod, bool makePreview) { var drawCol = new Color(new Vector4(1f, 1f, 1f, Alpha + alphaMod)); int preX = 0, preY = 0; for (var layerX = min.X; layerX < max.X; layerX++, preX++) { for (var layerY = min.Y; layerY < max.Y; layerY++, preY++) { var cell = GetCell(layerX, layerY); if (cell.IsEqualTo(TileCell.Empty) || cell.TextureSource.TextureIndex == string.Empty) continue; var drawTo = makePreview ? new Point(preX, preY) : new Point(layerX, layerY); if (cell.IsAutoTexture) { DrawAutotile(batch, camera, cell, cell.Texture, new Point(layerX, layerY), mMinusOne); continue; } var texture = cell.Texture; var sourceRect = new Rectangle(cell.SourceX, cell.SourceY, cell.Width, cell.Height); Rectangle destRect; if (cell.Rotation.Equals(0f) == false) { destRect = new Rectangle(drawTo.X * camera.TileWidth + (int)Math.Ceiling(camera.TileWidth * 0.5f), drawTo.Y * camera.TileHeight + (int)Math.Ceiling(camera.TileHeight * 0.5f), camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, drawCol, cell.Rotation, new Vector2(cell.Width * 0.5f, cell.Height * 0.5f), cell.FlipEffect, 0f); } else { destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, drawCol, 0f, Vector2.Zero, cell.FlipEffect, 0); } } preY = 0; } }
/// <summary>Converts a grid point to pixel point</summary> /// <param name="x">A X point of pixel coordinates.</param> /// <param name="y">A Y point of pixel coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Pixel point.</returns> public static Point2D Grid2Pixel(int x, int y, IEngineCamera camera) { int tileWidth = (camera != null ? camera.TileWidth : TileWidth); int tileHeight = (camera != null ? camera.TileHeight : TileHeight); return Grid2Pixel(x, y, tileWidth, tileHeight); }
public void DrawAutotile(SpriteBatch batch, IEngineCamera camera, TileCell cell, Texture2D texture, Point drawTo, Point preDraw) { var color = new Color(new Vector4(1f, 1f, 1f, Alpha)); var cellType = cell.AutoTextureType; var partWidth = camera.TileWidth / 2; var partHeight = camera.TileHeight / 2; var partWidthConst = TileCell.TileWidth / 2; var partheightConst = TileCell.TileHeight / 2; if (preDraw != mMinusOne) drawTo = preDraw; var sourceRect = new Rectangle(cell.X, cell.Y, cell.Width, cell.Height); var destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); // keine anliegenden if (cellType.Has(EAutoTileType.StandAlone | EAutoTileType.BottomLeft | EAutoTileType.BottomRight | EAutoTileType.TopLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top)) { batch.Draw(texture, destRect, sourceRect, color); return; } #region nur Rechts, Rechts + UntenRechts, Rechts + ObenRechts if (cellType.Has(EAutoTileType.Right) && cellType.HasNot(EAutoTileType.Left | EAutoTileType.Top | EAutoTileType.Bottom)) { // linkes Eck sourceRect = new Rectangle(0, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte oben sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte unten sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region nur Links, Links + UntenLinks, Links + ObenLinks if (cellType.Has(EAutoTileType.Left) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right)) { // rechtes Eck sourceRect = new Rectangle(partWidthConst, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte oben sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte unten sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Rechts und Links, kein Oben und Unten if (cellType.HasAll(EAutoTileType.Right | EAutoTileType.Left) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Bottom)) { // Mitte oben sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte unten sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Oben und Unten, kein Links und Rechts if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Top) && cellType.HasNot(EAutoTileType.Left | EAutoTileType.Right)) { // Mitte links sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region nur Oben, Oben + ObenLink, Oben + ObenRechts, Oben + ObenLinks + ObenRechts if (cellType.Has(EAutoTileType.Top) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.Left | EAutoTileType.Right)) { // unteres Eck sourceRect = new Rectangle(0, partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte links sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region nur Unten, Unten + UntenLink, Unten + UntenRechts, Unten + UntenLinks + UntenRechts if (cellType.Has(EAutoTileType.Bottom) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Left | EAutoTileType.Right)) { // oberes Eck sourceRect = new Rectangle(0, 0, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte links sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Mitte rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, texture.Height - TileCell.TileHeight - partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region T-Kreuzung nach Unten (Links + Rechts + Unten) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.BottomLeft | EAutoTileType.BottomRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region T-Kreuzung nach Oben (Links + Rechts + Oben) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.TopLeft | EAutoTileType.TopRight)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region T-Kreuzung nach Links (Oben + Unten + Links) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Left) && cellType.HasNot(EAutoTileType.Right | EAutoTileType.BottomLeft | EAutoTileType.TopLeft)) { // rechte Kante sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, texture.Height - TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // links sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region T-Kreuzung nach Rechts (Oben + Unten + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right) && cellType.HasNot(EAutoTileType.Left | EAutoTileType.TopRight | EAutoTileType.BottomRight)) { // linke Kante sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Kreuz (Oben + Unten + Links + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left) && cellType.HasNot(EAutoTileType.BottomLeft | EAutoTileType.BottomRight | EAutoTileType.TopLeft | EAutoTileType.TopRight)) { // mitte sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Kreuz + Oben Links (Oben + Unten + Links + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.BottomLeft | EAutoTileType.BottomRight | EAutoTileType.TopRight)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Kreuz + Oben Rechts (Oben + Unten + Links + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.BottomLeft | EAutoTileType.BottomRight | EAutoTileType.TopLeft)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Kreuz + Unten Links (Oben + Unten + Links + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.TopLeft | EAutoTileType.TopRight | EAutoTileType.BottomLeft)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Kreuz + Unten Rechts (Oben + Unten + Links + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.BottomLeft) && cellType.HasNot(EAutoTileType.TopLeft | EAutoTileType.TopRight | EAutoTileType.BottomRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke unten links (Oben + Rechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Right) && cellType.HasNot(EAutoTileType.Left | EAutoTileType.Bottom | EAutoTileType.TopRight)) { // Ecke unten Links 32drawTo.X16 sourceRect = new Rectangle(0, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke oben Links 16drawTo.X16 sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke oben Rechts 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke unten rechts (Oben + Links) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Left) && cellType.HasNot(EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.TopLeft)) { // Ecke unten Rechts 32drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke oben Rechts 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, texture.Height - TileCell.TileHeight, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke oben Links 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke oben links (Unten + Rechts) if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Right) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Left | EAutoTileType.BottomRight)) { // Ecke oben Links 32drawTo.X16 sourceRect = new Rectangle(0, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke unten Links 16drawTo.X16 sourceRect = new Rectangle(0, TileCell.TileHeight + partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke unten Rechts 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke oben rechts (Unten + Links) if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Left) && cellType.HasNot(EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.BottomLeft)) { // Ecke oben Rechts 32drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke unten Rechts 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, TileCell.TileHeight + partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // Ecke unten Links 16drawTo.X16 sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke links oben + diagonal (Unten + Rechts + UntenRechts) if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Left)) { sourceRect = new Rectangle(0, TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke rechts oben + diagonal (Unten + Links + UntenLinks) if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Left | EAutoTileType.BottomLeft) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.Right)) { sourceRect = new Rectangle(TileCell.TileWidth * 2, TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke links unten + diagonal (Oben + Rechts + ObenRechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Right | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.Left)) { sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Ecke rechts unten + diagonal (Oben + Links + ObenLinks) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Left | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.Right)) { sourceRect = new Rectangle(TileCell.TileWidth * 2, texture.Height - TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seiten links mitte + diagonalen (Oben + Unten + Rechts + ObenRechts + UntenRechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.BottomRight | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.Left)) { sourceRect = new Rectangle(0, texture.Height - TileCell.TileHeight * 2, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seiten rechts mitte + diagonalen (Oben + Unten + Links + ObenLinks + UntenLinks) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Left | EAutoTileType.BottomLeft | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.Right)) { sourceRect = new Rectangle(TileCell.TileWidth * 2, texture.Height - TileCell.TileHeight * 2, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seiten oben mitte + diagonalen (Links + Rechts + Unten + UntenLinks + UntenRechts) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.BottomLeft | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.Top)) { sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seiten unten mitte + diagonalen (Links + Rechts + Oben + ObenLinks + ObenRechts) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.TopLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.Bottom)) { sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - TileCell.TileHeight, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite links mitte + diagonalen + linker Ausgang (Oben + Unten + Rechts + Links + ObenRechts + UntenRechts) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.BottomRight | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.TopLeft | EAutoTileType.BottomLeft)) { // linke Seite sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // rechte seite sourceRect = new Rectangle(partWidthConst, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite rechts mitte + diagonalen + rechter Ausgang (Oben + Unten + Rechts + Links + ObenLinks + UntenLinks) if (cellType.HasAll(EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.Right | EAutoTileType.Left | EAutoTileType.BottomLeft | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.TopRight | EAutoTileType.BottomRight)) { // linke Seite sourceRect = new Rectangle(partWidthConst, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // rechte seite sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite oben mitte + diagonalen + oberer Ausgang (Links + Rechts + Unten + Oben + UntenLinks + UntenRechts) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.BottomLeft | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.TopLeft | EAutoTileType.TopRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite unten mitte + diagonalen + unterer Ausgang (Links + Rechts + Unten + Oben + ObenLinks + ObenRechts) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.TopLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.BottomLeft | EAutoTileType.BottomRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // untere Kante sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite links mitte + Land unten rechts if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.Right | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.BottomRight | EAutoTileType.Left)) { // links seite sourceRect = new Rectangle(0, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // rechts oben sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // rechts unten sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite links mitte + Land oben rechts if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.Right | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.TopRight | EAutoTileType.Left)) { // links seite sourceRect = new Rectangle(0, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // rechts oben sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // rechts unten sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite oben mitte + Land unten rechts if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.BottomLeft) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.BottomRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite oben mitte + Land unten links if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Bottom | EAutoTileType.BottomRight) && cellType.HasNot(EAutoTileType.Top | EAutoTileType.BottomLeft)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite unten mitte + Land oben rechts if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.TopRight)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite unten mitte + Land oben links if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.Bottom | EAutoTileType.TopLeft)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, texture.Height - partheightConst, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite rechts mitte + Land unten links if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.Left | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.BottomLeft | EAutoTileType.Right)) { // rechts seite sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // links oben sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // links unten sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Seite rechts mitte + Land oben links if (cellType.HasAll(EAutoTileType.Bottom | EAutoTileType.Top | EAutoTileType.Left | EAutoTileType.BottomLeft) && cellType.HasNot(EAutoTileType.TopLeft | EAutoTileType.Right)) { // rechts seite sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, TileCell.TileHeight * 2, partWidthConst, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); // links oben sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // links unten sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte (Alles) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomLeft | EAutoTileType.BottomRight | EAutoTileType.TopLeft | EAutoTileType.TopRight)) { sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, TileCell.TileHeight); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, camera.TileHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Unten Links (Alles) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomRight | EAutoTileType.TopLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.BottomLeft)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Unten Rechts (Alles) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomLeft | EAutoTileType.TopLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.BottomRight)) { // obere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Oben Links (Alles) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomRight | EAutoTileType.BottomLeft | EAutoTileType.TopRight) && cellType.HasNot(EAutoTileType.TopLeft)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Oben Rechts (Alles) if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomRight | EAutoTileType.BottomLeft | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.TopRight)) { // untere Kante sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, TileCell.TileWidth, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, camera.TileWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Unten Links + Oben Rechts if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.BottomRight | EAutoTileType.TopLeft) && cellType.HasNot(EAutoTileType.TopRight | EAutoTileType.BottomLeft)) { // oben links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth * 2, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); return; } #endregion #region Mitte - Unten Rechts + Oben Links if (cellType.HasAll(EAutoTileType.Left | EAutoTileType.Right | EAutoTileType.Top | EAutoTileType.Bottom | EAutoTileType.TopRight | EAutoTileType.BottomLeft) && cellType.HasNot(EAutoTileType.BottomRight | EAutoTileType.TopLeft)) { // oben Rechts sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten links sourceRect = new Rectangle(TileCell.TileWidth, TileCell.TileHeight * 2, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // oben links sourceRect = new Rectangle(TileCell.TileWidth * 2, 0, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth, drawTo.Y * camera.TileHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); // unten rechts sourceRect = new Rectangle(TileCell.TileWidth * 2 + partWidthConst, partheightConst, partWidthConst, partheightConst); destRect = new Rectangle(drawTo.X * camera.TileWidth + partWidth, drawTo.Y * camera.TileHeight + partHeight, partWidth, partHeight); batch.Draw(texture, destRect, sourceRect, color); } #endregion }
public static Point2D Grid2PixelCenter(int x, int y, IEngineCamera camera) { int tileWidth = (camera != null ? camera.TileWidth : TileWidth); int tileHeight = (camera != null ? camera.TileHeight : TileHeight); return Grid2Pixel(x, y) + new Point2D(tileWidth / 2, tileHeight / 2); }
public void Draw(SpriteBatch batch, IEngineCamera camera) { Draw(batch, camera, new Point2D(0, 0), new Point2D(Width, Height)); }
public void Draw(SpriteBatch batch, IEngineCamera camera, double totalSeconds, ETileDrawType drawType, Point2D min, Point2D max, bool makePreview) { bool drawBackground = (drawType & ETileDrawType.BackGround) == ETileDrawType.BackGround; bool drawForeground = (drawType & ETileDrawType.ForeGround) == ETileDrawType.ForeGround; foreach (TileLayer layer in Layers) { if (!(layer.IsBackground && drawBackground) && !(layer.IsForeground && drawForeground)) { continue; } layer.Draw(batch, camera, min, max, 0f, makePreview); } if ((drawType & ETileDrawType.Animation) == ETileDrawType.Animation) AnimationLayer.Draw(batch, camera, totalSeconds, min, max); if ((drawType & ETileDrawType.Fog) == ETileDrawType.Fog) DrawFog(batch, camera, min, max); }
/// <summary>Converts a pixel point to grid point</summary> /// <param name="p">A point of pixel coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Grid point.</returns> public static Point2D Pixel2Grid(Point2D p, IEngineCamera camera) { return(Pixel2Grid(p.X, p.Y, camera)); }
/// <summary>Converts a grid point to pixel point</summary> /// <param name="p">A point of grid coordinates.</param> /// <param name="camera">A camera to take the tile size from (defaults to TileCell constants)</param> /// <returns>Pixel point.</returns> public static Point2D Grid2Pixel(Point2D p, IEngineCamera camera) { return(Grid2Pixel(p.X, p.Y, camera)); }
public void Draw(SpriteBatch batch, IEngineCamera camera, double TotalSeconds, Point2D min, Point2D max) { for (var x = min.X; x < max.X; x++) { for (var y = min.Y; y < max.Y; y++) { var ani = GetCell(x, y); if (ani == null) continue; // Draw from bottom middle of the Cell ani.Draw(batch, camera, TotalSeconds, new Point2D(x * camera.TileWidth + camera.TileWidth / 2, y * camera.TileHeight + camera.TileHeight / 2)); } } }