diff --git a/DangerousD/Content/debug.tmx b/DangerousD/Content/debug.tmx index c24a642..f52dbe7 100644 --- a/DangerousD/Content/debug.tmx +++ b/DangerousD/Content/debug.tmx @@ -1,5 +1,5 @@ - + @@ -77,11 +77,6 @@ - - - - - @@ -194,6 +189,11 @@ + + + + + diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 03c24b6..43e191f 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -25,9 +25,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public int leftBorder; public bool isVisible = true; private bool isAttacked = false; + public bool isInvincible; public GameObject objectAttack; - public Player(Vector2 position) : base(position) + public Player(Vector2 position, bool isInvincible = false) : base(position) { Width = 16; Height = 32; @@ -40,6 +41,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities velocity = new Vector2(0, 0); rightBorder = (int)position.X + 100; leftBorder = (int)position.X - 100; + this.isInvincible = isInvincible; } @@ -98,7 +100,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public override void Update(GameTime gameTime) { GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint(); - if (!isAttacked) + if (!isAttacked || isInvincible) { Move(gameTime); } diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index cf209f4..a8e1239 100644 --- a/DangerousD/GameCore/Managers/MapManager.cs +++ b/DangerousD/GameCore/Managers/MapManager.cs @@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Graphics; using System.Xml.Serialization; using DangerousD.GameCore.GameObjects; using System.Globalization; +using DangerousD.GameCore.GameObjects.LivingEntities; namespace DangerousD.GameCore.Managers { @@ -70,22 +71,8 @@ namespace DangerousD.GameCore.Managers Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint()); Type type = Type.GetType($"DangerousD.GameCore.GameObjects.MapObjects.{tileType}"); Activator.CreateInstance(type, pos, tileSize * _scale, sourceRect); - - /*switch (tileType) - { - case "collidable": - new StopTile(pos, tileSize * _scale, sourceRect); - break; - case "platform": - new Platform(pos, tileSize * _scale, sourceRect); - break; - case "non_collidable": - new Tile(pos, tileSize * _scale, sourceRect); - break; - }*/ - } - } + } } } @@ -105,10 +92,20 @@ namespace DangerousD.GameCore.Managers float offsetY = group.Attributes["offsety"] is not null ? float.Parse(group.Attributes["offsety"].Value) : 0; foreach (XmlNode entity in group.ChildNodes) { - Debug.WriteLine(entity.Attributes["type"] is not null ? "." + entity.Attributes["type"].Value : ""); string entityType = entity.Attributes["type"] is not null ? "." + entity.Attributes["type"].Value : ""; Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityGroup}{entityType}"); - Entity inst = (Entity)Activator.CreateInstance(type, new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale); + Vector2 pos = + new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, + float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale; + Entity inst; + if (type.Equals(typeof(Player)) && entity.Attributes["name"].Value == "DEBUGUS") + { + inst = (Entity)Activator.CreateInstance(type, pos, true); + } + else + { + inst = (Entity)Activator.CreateInstance(type, pos); + } inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height)); inst.Height *= _scale; inst.Width *= _scale;