diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb
index 82b499e..05bebc6 100644
--- a/DangerousD/Content/Content.mgcb
+++ b/DangerousD/Content/Content.mgcb
@@ -26,7 +26,6 @@
/processorParam:TextureFormat=Color
/build:animation1.png
-
#begin ButtonFont.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
@@ -55,6 +54,17 @@
/processorParam:TextureFormat=Compressed
/build:Font2.spritefont
+#begin menuFon.jpg
+/importer:TextureImporter
+/processor:TextureProcessor
+/processorParam:ColorKeyColor=255,0,255,255
+/processorParam:ColorKeyEnabled=True
+/processorParam:GenerateMipmaps=False
+/processorParam:PremultiplyAlpha=True
+/processorParam:ResizeToPowerOfTwo=False
+/processorParam:MakeSquare=False
+/processorParam:TextureFormat=Color
+/build:menuFon.jpg
#begin MonstersAnimations.png
/importer:TextureImporter
@@ -68,18 +78,6 @@
/processorParam:TextureFormat=Color
/build:MonstersAnimations.png
-#begin menuFon.jpg
-/importer:TextureImporter
-/processor:TextureProcessor
-/processorParam:ColorKeyColor=255,0,255,255
-/processorParam:ColorKeyEnabled=True
-/processorParam:GenerateMipmaps=False
-/processorParam:PremultiplyAlpha=True
-/processorParam:ResizeToPowerOfTwo=False
-/processorParam:MakeSquare=False
-/processorParam:TextureFormat=Color
-/build:menuFon.jpg
-
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
/importer:TextureImporter
/processor:TextureProcessor
@@ -92,10 +90,17 @@
/processorParam:TextureFormat=Color
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
-#begin sus.tmx
-/importer:TiledMapImporter
-/processor:TiledMapProcessor
-/build:sus.tmx
+#begin tiles.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/processorParam:ColorKeyColor=255,0,255,255
+/processorParam:ColorKeyEnabled=True
+/processorParam:GenerateMipmaps=False
+/processorParam:PremultiplyAlpha=True
+/processorParam:ResizeToPowerOfTwo=False
+/processorParam:MakeSquare=False
+/processorParam:TextureFormat=Color
+/build:tiles.png
#begin wall.jpg
/importer:TextureImporter
diff --git a/DangerousD/Content/level1.tmx b/DangerousD/Content/level1.tmx
new file mode 100644
index 0000000..0febad6
--- /dev/null
+++ b/DangerousD/Content/level1.tmx
@@ -0,0 +1,611 @@
+
+
diff --git a/DangerousD/Content/lvl1.tmx b/DangerousD/Content/lvl1.tmx
deleted file mode 100644
index 6909dd5..0000000
--- a/DangerousD/Content/lvl1.tmx
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
diff --git a/DangerousD/Content/tiles.BMP b/DangerousD/Content/tiles.BMP
deleted file mode 100644
index a9709a0..0000000
Binary files a/DangerousD/Content/tiles.BMP and /dev/null differ
diff --git a/DangerousD/Content/tiles.png b/DangerousD/Content/tiles.png
new file mode 100644
index 0000000..3e35587
Binary files /dev/null and b/DangerousD/Content/tiles.png differ
diff --git a/DangerousD/DangerousD.csproj b/DangerousD/DangerousD.csproj
index 725d7c1..99e6800 100644
--- a/DangerousD/DangerousD.csproj
+++ b/DangerousD/DangerousD.csproj
@@ -19,9 +19,6 @@
-
-
-
diff --git a/DangerousD/GameCore/GameObjects/MapObject.cs b/DangerousD/GameCore/GameObjects/MapObject.cs
index c12598b..e2a94a3 100644
--- a/DangerousD/GameCore/GameObjects/MapObject.cs
+++ b/DangerousD/GameCore/GameObjects/MapObject.cs
@@ -3,15 +3,13 @@ using Microsoft.Xna.Framework;
using System.Security.Cryptography.X509Certificates;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework.Graphics;
-using MonoGame.Extended.Sprites;
-
namespace DangerousD.GameCore.GameObjects;
public abstract class MapObject : GameObject
{
public bool IsColliderOn;
private Rectangle _sourceRectangle;
- protected override GraphicsComponent GraphicsComponent { get; } = new("map");
+ protected override GraphicsComponent GraphicsComponent { get; } = new("tiles");
public MapObject(Vector2 position, Rectangle sourceRectangle) : base(position)
{
_sourceRectangle = sourceRectangle;
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs
index 999a009..abf76bf 100644
--- a/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs
+++ b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs
@@ -9,6 +9,4 @@ public class Platform : MapObject
{
IsColliderOn = true;
}
-
- protected override GraphicsComponent GraphicsComponent { get; }
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs
index e73eaaf..4a5dafd 100644
--- a/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs
+++ b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs
@@ -9,6 +9,4 @@ public class StopTile : MapObject
{
IsColliderOn = true;
}
-
- protected override GraphicsComponent GraphicsComponent { get; }
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs
index 5776344..72b7581 100644
--- a/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs
+++ b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs
@@ -9,6 +9,4 @@ public class Tile : MapObject
{
IsColliderOn = false;
}
-
- protected override GraphicsComponent GraphicsComponent { get; }
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index 2891dbf..bc69f2d 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -24,18 +24,18 @@ namespace DangerousD.GameCore
IDrawableObject LoginGUI;
IDrawableObject LobbyGUI;
- public GameManager GameManager { get; private set; } = new GameManager();
+ public GameManager GameManager { get; private set; } = new();
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
public NetworkManager NetworkManager { get; private set; } = new NetworkManager();
public AppManager()
{
+ Content.RootDirectory = "Content";
Instance = this;
_graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
IsMouseVisible = true;
+ resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / 30);
- resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
gameState = GameState.Menu;
MenuGUI = new MenuGUI();
LoginGUI = new LoginGUI();
@@ -44,6 +44,7 @@ namespace DangerousD.GameCore
protected override void Initialize()
{
+ GameManager.Initialize();
AnimationBuilder.LoadAnimations();
MenuGUI.Initialize();
LoginGUI.Initialize();
@@ -134,7 +135,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
- GameManager.mapManager.LoadLevel("");
+ GameManager.mapManager.LoadLevel("Level1");
break;
default:
throw new ArgumentOutOfRangeException();
diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs
index a6840d6..c7d0c91 100644
--- a/DangerousD/GameCore/Managers/GameManager.cs
+++ b/DangerousD/GameCore/Managers/GameManager.cs
@@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
+using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
namespace DangerousD.GameCore
{
@@ -30,6 +31,15 @@ namespace DangerousD.GameCore
physicsManager = new PhysicsManager();
}
+ public void Initialize()
+ {
+ //mapManager.LoadLevel("Level1");
+ }
+
+ public void LoadContent()
+ {
+ }
+
internal void Register(GameObject gameObject)
{
if (gameObject is LivingEntity)
diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs
index c566cf9..e36089b 100644
--- a/DangerousD/GameCore/Managers/MapManager.cs
+++ b/DangerousD/GameCore/Managers/MapManager.cs
@@ -8,11 +8,15 @@ namespace DangerousD.GameCore.Managers
{
public class MapManager
{
+ private int _columns;
+
//Level
public void LoadLevel(string level)
{
+ LoadTilesData();
+
XmlDocument xml = new();
- xml.Load($"{level}.tmx");
+ xml.Load($"../../../Content/{level}.tmx");
Vector2 tileSize = new(int.Parse(xml.DocumentElement.Attributes["tilewidth"].Value),
int.Parse(xml.DocumentElement.Attributes["tileheight"].Value));
@@ -28,19 +32,21 @@ namespace DangerousD.GameCore.Managers
{
string tileType = layer.Attributes["class"].Value;
- foreach (XmlNode chunk in layer.ChildNodes)
+ foreach (XmlNode chunk in layer.SelectNodes("//chunk"))
{
- Vector2 chunkSize = new(int.Parse(chunk.Attributes["width"].Value),
- int.Parse(chunk.Attributes["height"].Value));
- Vector2 chunkPos = new(int.Parse(chunk.Attributes["x"].Value), int.Parse(chunk.Attributes["y"].Value));
+ int chunkW = int.Parse(chunk.Attributes["width"].Value);
+ int chunkX = int.Parse(chunk.Attributes["x"].Value);
+ int chunkY = int.Parse(chunk.Attributes["y"].Value);
- List tiles = chunk.Value.Split(',').Select(int.Parse).ToList();
+ List tiles = chunk.InnerText.Split(',').Select(int.Parse).ToList();
for (int i = 0; i < tiles.Count; i++)
{
- Vector2 pos = new((chunkPos.Y + i % chunkSize.X) * tileSize.Y,
- (chunkPos.Y + i / chunkSize.X) * tileSize.Y);
- Rectangle sourceRect = new(pos.ToPoint(), tileSize.ToPoint());
+ if (tiles[i] == 0) continue;
+
+ Vector2 pos = new((chunkX + i % chunkW) * tileSize.X,
+ (chunkY + i / chunkW) * tileSize.Y);
+ Rectangle sourceRect = new(new Point(tiles[i] % _columns, tiles[i] / _columns), tileSize.ToPoint());
switch (tileType)
{
@@ -56,5 +62,14 @@ namespace DangerousD.GameCore.Managers
}}
}
}
+
+ private void LoadTilesData()
+ {
+ XmlDocument xml = new();
+ xml.Load($"../../../Content/map.tsx");
+ XmlNode root = xml.DocumentElement;
+
+ _columns = int.Parse(root.Attributes["columns"].Value);
+ }
}
}