diff options
Diffstat (limited to 'Penguloon/Levels/Map.cs')
| -rw-r--r-- | Penguloon/Levels/Map.cs | 53 |
1 files changed, 41 insertions, 12 deletions
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 @@ -65,6 +65,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++) { for (int x = 0; x < TileMap.GetLength(1); x++) @@ -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); + } } } |
