added zombie walk and attack animation
This commit is contained in:
parent
03e6f7b75d
commit
d65320f21b
7 changed files with 23 additions and 9 deletions
|
@ -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
|
||||
|
|
1
DangerousD/Content/animations/ZombieLeftAttack
Normal file
1
DangerousD/Content/animations/ZombieLeftAttack
Normal 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"}
|
|
@ -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"}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,5 +20,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public void Death(string monsterName)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace DangerousD.GameCore.Graphics
|
|||
if (interval == 0)
|
||||
{
|
||||
currentFrame++;
|
||||
if (currentAnimation.FramesCount - 1 <= currentFrame)
|
||||
if (currentAnimation.FramesCount <= currentFrame)
|
||||
{
|
||||
if (!currentAnimation.IsCycle)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue