added zombie walk and attack animation

This commit is contained in:
bmvolf 2023-08-15 18:17:26 +03:00
parent 03e6f7b75d
commit d65320f21b
7 changed files with 23 additions and 9 deletions

View file

@ -13,7 +13,7 @@
#---------------------------------- Content ---------------------------------# #---------------------------------- Content ---------------------------------#
#begin animation1.png #begin ../../../animation1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255 /processorParam:ColorKeyColor=255,0,255,255
@ -23,7 +23,7 @@
/processorParam:ResizeToPowerOfTwo=False /processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:animation1.png /build:../../../animation1.png;animation1.png
#begin File.spritefont #begin File.spritefont
/importer:FontDescriptionImporter /importer:FontDescriptionImporter

View file

@ -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"}

View file

@ -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"}

View file

@ -32,7 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
public abstract void Death(); public abstract void Death();
public abstract void Attack(); public abstract void Attack(Player player);
public abstract void Move(GameTime gameTime); public abstract void Move(GameTime gameTime);
} }

View file

@ -17,10 +17,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
Width = 72; Width = 72;
Height = 120; Height = 120;
GraphicsComponent.StartAnimation("ZombieRightAttack");
monster_speed = 100; monster_speed = 100;
name = "Zombie";
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack"}, "ZombieMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveRight");
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
@ -33,11 +33,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
base.Update(gameTime); base.Update(gameTime);
} }
public override void Attack() public override void Attack(Player player)
{ {
if (isGoRight) if (isGoRight)
{ {
GraphicsComponent.StopAnimation();
GraphicsComponent.StartAnimation("ZombieRightAttack");
player.Death(name);
}
else if (!isGoRight)
{
GraphicsComponent.StopAnimation();
GraphicsComponent.StartAnimation("ZombieLeftAttack");
player.Death(name);
} }
} }

View file

@ -20,5 +20,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
} }
public void Death(string monsterName)
{
}
} }
} }

View file

@ -110,7 +110,7 @@ namespace DangerousD.GameCore.Graphics
if (interval == 0) if (interval == 0)
{ {
currentFrame++; currentFrame++;
if (currentAnimation.FramesCount - 1 <= currentFrame) if (currentAnimation.FramesCount <= currentFrame)
{ {
if (!currentAnimation.IsCycle) if (!currentAnimation.IsCycle)
{ {