diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 8c17266..b32dbb2 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -13,7 +13,7 @@ #---------------------------------- Content ---------------------------------# -#begin animation1.png +#begin ../../../animation1.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -23,7 +23,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:animation1.png +/build:../../../animation1.png;animation1.png #begin File.spritefont /importer:FontDescriptionImporter diff --git a/DangerousD/Content/animations/ZombieLeftAttack b/DangerousD/Content/animations/ZombieLeftAttack new file mode 100644 index 0000000..a5eae6c --- /dev/null +++ b/DangerousD/Content/animations/ZombieLeftAttack @@ -0,0 +1 @@ +{"id":"ZombieLeftAttack","textureName":"animation1","startSpriteRectangle":{"X":126,"Y":50,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":25}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"} diff --git a/DangerousD/Content/animations/ZombieRightAttack b/DangerousD/Content/animations/ZombieRightAttack index 5df80a2..d2e6456 100644 --- a/DangerousD/Content/animations/ZombieRightAttack +++ b/DangerousD/Content/animations/ZombieRightAttack @@ -1 +1 @@ -{"id":"ZombieRightAttack","textureName":"animation1","startSpriteRectangle":{"X":126,"Y":6,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false} +{"id":"ZombieRightAttack","textureName":"animation1","startSpriteRectangle":{"X":126,"Y":9,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":25}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs index 5b73955..c49c08b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs @@ -32,7 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public abstract void Death(); - public abstract void Attack(); + public abstract void Attack(Player player); public abstract void Move(GameTime gameTime); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 9605857..ae4a8c8 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -17,10 +17,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { Width = 72; Height = 120; - GraphicsComponent.StartAnimation("ZombieRightAttack"); monster_speed = 100; + name = "Zombie"; } - protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack"}, "ZombieMoveRight"); + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveRight"); public override void Update(GameTime gameTime) { @@ -33,11 +33,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters base.Update(gameTime); } - public override void Attack() + public override void Attack(Player player) { if (isGoRight) { - + GraphicsComponent.StopAnimation(); + GraphicsComponent.StartAnimation("ZombieRightAttack"); + player.Death(name); + } + else if (!isGoRight) + { + GraphicsComponent.StopAnimation(); + GraphicsComponent.StartAnimation("ZombieLeftAttack"); + player.Death(name); } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs index 8caadd3..9683e16 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs @@ -20,5 +20,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { } + + public void Death(string monsterName) + { + + } } } diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index f858f3f..c5834ab 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -110,7 +110,7 @@ namespace DangerousD.GameCore.Graphics if (interval == 0) { currentFrame++; - if (currentAnimation.FramesCount - 1 <= currentFrame) + if (currentAnimation.FramesCount <= currentFrame) { if (!currentAnimation.IsCycle) {