diff --git a/DangerousD/Content/animation1.png b/DangerousD/Content/animation1.png new file mode 100644 index 0000000..bbc2157 Binary files /dev/null and b/DangerousD/Content/animation1.png differ diff --git a/DangerousD/Content/animations/playerReload b/DangerousD/Content/animations/playerReload new file mode 100644 index 0000000..2dd0586 --- /dev/null +++ b/DangerousD/Content/animations/playerReload @@ -0,0 +1 @@ +{"id":"playerReload","textureName":"playerAnimation","startSpriteRectangle":{"X":101,"Y":67,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerShootLeft b/DangerousD/Content/animations/playerShootLeft new file mode 100644 index 0000000..f2b9f3b --- /dev/null +++ b/DangerousD/Content/animations/playerShootLeft @@ -0,0 +1 @@ +{"id":"playerShootLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":201,"Y":34,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"4, 0"} diff --git a/DangerousD/Content/animations/playerShootRight b/DangerousD/Content/animations/playerShootRight new file mode 100644 index 0000000..922862b --- /dev/null +++ b/DangerousD/Content/animations/playerShootRight @@ -0,0 +1 @@ +{"id":"playerShootRight","textureName":"playerAnimation","startSpriteRectangle":{"X":201,"Y":1,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"4, 0"} diff --git a/DangerousD/Content/debug.tmx b/DangerousD/Content/debug.tmx new file mode 100644 index 0000000..f52dbe7 --- /dev/null +++ b/DangerousD/Content/debug.tmx @@ -0,0 +1,373 @@ + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570 + + +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +570,570,570,570,570,570,570,570,570,570,570,570,570,570,570,570, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0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, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370 + + +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +369,370,0,0,0,0,0,0,0,0,369,370,0,0,0,0, +382,383,0,0,0,0,0,0,0,0,382,383,0,0,0,0, +395,396,0,0,0,0,0,0,0,0,395,396,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,369,370,0,0,0,0,0,0,0,0,369,370, +0,0,0,0,382,383,0,0,0,0,0,0,0,0,382,383, +0,0,0,0,395,396,0,0,0,0,0,0,0,0,395,396, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DangerousD/Content/lvl.tmx b/DangerousD/Content/lvl.tmx index 271b1e5..5377e12 100644 --- a/DangerousD/Content/lvl.tmx +++ b/DangerousD/Content/lvl.tmx @@ -1,7 +1,7 @@ - + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -130,19 +130,19 @@ 0,0,0,0,0,0,0,0,0,0,13,75,0,0,0,0 -52,0,0,0,52,0,0,0,52,52,52,52,52,52,52,52, +52,0,0,0,0,0,0,0,52,52,52,52,52,52,52,52, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -52,52,0,0,52,0,0,52,52,52,52,52,52,52,52,52, +52,52,0,0,0,0,0,52,52,52,52,52,52,52,52,52, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -52,52,52,0,52,0,52,52,52,52,52,52,52,52,52,52, +52,52,52,0,0,0,52,52,52,52,52,52,52,52,52,52, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @@ -441,7 +441,7 @@ - + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -701,7 +701,7 @@ - + diff --git a/DangerousD/Content/tiles.BMP b/DangerousD/Content/tiles.BMP new file mode 100644 index 0000000..a9709a0 Binary files /dev/null and b/DangerousD/Content/tiles.BMP differ diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index ed4dfcb..e16f168 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -1,4 +1,4 @@ -using DangerousD.GameCore.Graphics; + using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 06c41a1..188dfb9 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -27,8 +27,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Height = 40; monster_speed = 3; name = "Zombie"; - leftBorder = (int)position.X - 50; - rightBorder = (int)position.X + 50; + monster_health = 2; + leftBorder = (int)position.X - 100; + rightBorder = (int)position.X + 100; physicsManager = new PhysicsManager(); Random random = new Random(); if(random.Next(0, 2) == 0) @@ -77,7 +78,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Death() { - + AppManager.Instance.GameManager.Remove(this); } public override void Move(GameTime gameTime) @@ -154,5 +155,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public void Attack(GameTime gameTime) {} + + public void TakeDamage() + { + monster_health--; + GraphicsComponent.StartAnimation("ZombieRightAttack"); + if (monster_health <= 0) + { + Death(); + } + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 8a777be..066b1d4 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using DangerousD.GameCore.GameObjects.PlayerDeath; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; -using DangerousD.GameCore.Network; +using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; namespace DangerousD.GameCore.GameObjects.LivingEntities { @@ -25,7 +25,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public int leftBorder; public bool isVisible = true; private bool isAttacked = false; + private bool isShooting = false; public GameObject objectAttack; + private int bullets; public Player(Vector2 position) : base(position) { @@ -36,17 +38,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities AppManager.Instance.InputManager.MovEventJump += Jump; AppManager.Instance.InputManager.MovEventDown += MoveDown; + AppManager.Instance.InputManager.ShootEvent += Shoot; velocity = new Vector2(0, 0); rightBorder = (int)position.X + 100; leftBorder = (int)position.X - 100; + bullets = 5; + this.GraphicsComponent.actionOfAnimationEnd += (a) => + { + if (a == "playerShootLeft" || a == "playerShootRight") + { + isShooting = false; + } + if (a == "playerReload") + { + bullets++; + } + }; } public bool IsAlive { get { return isAlive; } } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", - "playerJumpRight" , "playerJumpLeft"}, "playerStayLeft"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload"}, "playerReload"); public void Attack() { @@ -54,6 +69,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { isVisible = false; } + } public override void OnCollision(GameObject gameObject) { @@ -92,9 +108,47 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public void Shoot() { - + if (bullets > 0) + { + if (!isShooting) + { + isShooting = true; + bullets--; + if (isRight) + { + if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") + { + GraphicsComponent.StartAnimation("playerShootRight"); + } + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), 100, 10), typeof(Zombie)); + if (targets != null) + { + foreach (var target in targets) + { + Zombie targetZombie = (Zombie)target; + targetZombie.TakeDamage(); + } + } + } + else + { + if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") + { + GraphicsComponent.StartAnimation("playerShootRight"); + } + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), -100, 10), typeof(Zombie)); + if (targets != null) + { + foreach (var target in targets) + { + Zombie targetZombie = (Zombie)target; + targetZombie.TakeDamage(); + } + } + } + } + } } - public override void Update(GameTime gameTime) { GraphicsComponent.SetCameraPosition(Pos); @@ -113,25 +167,41 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { float delta = (float)gameTime.ElapsedGameTime.TotalSeconds; velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X; - if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0) + if (GraphicsComponent.GetCurrentAnimation != "playerShootLeft" && GraphicsComponent.GetCurrentAnimation != "playerShootRight") { - if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")//идёт направо + if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0) { - GraphicsComponent.StartAnimation("playerMoveRight"); + isRight = true; + if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")//идёт направо + { + GraphicsComponent.StartAnimation("playerMoveRight"); + } } - } - else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево - { - if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft") + else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево { - GraphicsComponent.StartAnimation("playerMoveLeft"); + isRight = false; + if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft") + { + GraphicsComponent.StartAnimation("playerMoveLeft"); + } } - } - else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит - { - if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft") + else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - GraphicsComponent.StartAnimation("ZombieMoveLeft"); + if(bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } + else if (isRight) + { + GraphicsComponent.StartAnimation("playerRightStay"); + } + else if (!isRight) + { + GraphicsComponent.StartAnimation("playerStayLeft"); + } } } if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index 5d7d6fc..fd23e3c 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; - }*/ - } - } + } } } @@ -100,13 +87,25 @@ namespace DangerousD.GameCore.Managers private void InstantiateEntities(XmlNode group) { - string entityType = group.Attributes["class"].Value; + string entityGroup = group.Attributes["class"] is not null ? group.Attributes["class"].Value : ""; float offsetX = group.Attributes["offsetx"] is not null ? float.Parse(group.Attributes["offsetx"].Value) : 0; float offsetY = group.Attributes["offsety"] is not null ? float.Parse(group.Attributes["offsety"].Value) : 0; foreach (XmlNode entity in group.ChildNodes) { - Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{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); + string entityType = entity.Attributes["type"] is not null ? "." + entity.Attributes["type"].Value : ""; + Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityGroup}{entityType}"); + 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"] is not null && 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;