From a05ae287aa87259817e6ca7627986e14eeab6098 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Tue, 2 Jan 2018 23:36:55 +0100 Subject: dank --- Penguloon/Levels/Map.cs | 53 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'Penguloon/Levels/Map.cs') diff --git a/Penguloon/Levels/Map.cs b/Penguloon/Levels/Map.cs index 03e1c4f..806c8de 100644 --- a/Penguloon/Levels/Map.cs +++ b/Penguloon/Levels/Map.cs @@ -64,6 +64,25 @@ namespace Penguloon.Levels } public void Draw(float deltaTime) + { + DrawMap(); + + DrawSpareTiles(); + + for (int i = 0; i < Enemies.Count; i++) + { + if (Enemies[i].Texture != null) + ParentScene.Main.SpriteBatch.Draw(Enemies[i].Texture, + destinationRectangle: Enemies[i].Box); + } + + for (int i = 0; i < Objects.Count; i++) + { + Objects[i].Draw(deltaTime); + } + } + + private void DrawMap() { for (int y = 0; y < TileMap.GetLength(0); y++) { @@ -77,16 +96,19 @@ namespace Penguloon.Levels case LevelType.Sand: tileTexture = ContentManager.GetSandTileTextureByType(TileMap[y, x].Type); break; } - if(tileTexture != null) - ParentScene.Main.SpriteBatch.Draw(tileTexture, - destinationRectangle: new Rectangle(x * TileWidth, y * TileHeight, TileWidth, TileHeight)); + if (tileTexture != null) + ParentScene.Main.SpriteBatch.Draw(tileTexture, + destinationRectangle: new Rectangle(x * TileWidth, y * TileHeight, TileWidth, TileHeight)); //if (ParentScene.ObjectSeletor.State == Controls.State.Selected) // ParentScene.Main.SpriteBatch.Draw(tileTexture, // destinationRectangle: new Rectangle(x * TileWidth, y * TileHeight, TileWidth, TileHeight)); } } + } + private void DrawSpareTiles() + { Texture2D tileTextureSpare = null; Texture2D unplaceableTileTexture = null; @@ -113,17 +135,19 @@ namespace Penguloon.Levels } } - - for (int i = 0; i < Enemies.Count; i++) - { - if (Enemies[i].Texture != null) - ParentScene.Main.SpriteBatch.Draw(Enemies[i].Texture, - destinationRectangle: Enemies[i].Box); - } - for (int i = 0; i < Objects.Count; i++) { - Objects[i].Draw(deltaTime); + if (ParentScene.ObjectSeletor.State != Controls.State.Selected) continue; + + for (int x = 0; x < Objects[i].TileSpanX; x++) + { + for (int y = 0; y < Objects[i].TileSpanY; y++) + { + ParentScene.Main.SpriteBatch.Draw(unplaceableTileTexture, + destinationRectangle: new Rectangle((int)Objects[i].Position.X + (x * TileWidth), + (int)Objects[i].Position.Y + (y * TileHeight), TileWidth, TileHeight)); + } + } } } @@ -235,6 +259,11 @@ namespace Penguloon.Levels var b = new HealthGeneratorObject(pos, this); Objects.Add(b); } + if (type == typeof(MortarObject)) + { + var b = new MortarObject(pos, this); + Objects.Add(b); + } } } -- cgit v1.2.3-70-g09d2