fixed errors zombie
This commit is contained in:
parent
ac1b3b6373
commit
15f0571790
5 changed files with 28 additions and 14 deletions
|
@ -22,7 +22,7 @@ namespace DangerousD.GameCore.GameObjects
|
|||
{
|
||||
Vector2 dir = targetPosition - Pos;
|
||||
dir.Normalize();
|
||||
Pos += dir * speed;
|
||||
_pos += dir * speed;
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
public abstract class GameObject : IDrawableObject
|
||||
{
|
||||
private Vector2 _pos;
|
||||
protected Vector2 _pos;
|
||||
public Vector2 Pos => _pos;
|
||||
public int Width { get; protected set; }
|
||||
public int Height { get; protected set; }
|
||||
|
|
|
@ -22,17 +22,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
//здесь я не понял
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
public virtual void Update(GameTime gameTime, Player player)
|
||||
{
|
||||
if (monster_health <= 0)
|
||||
{
|
||||
Death();
|
||||
isAlive = false;
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
public abstract void Death();
|
||||
|
||||
public abstract void Attack(Player player);
|
||||
public abstract void Attack();
|
||||
|
||||
public abstract void Move(GameTime gameTime);
|
||||
}
|
||||
|
|
|
@ -13,40 +13,46 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
public class Zombie : CoreEnemy
|
||||
{
|
||||
private bool isGoRight = true;
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
public Zombie(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 72;
|
||||
Height = 120;
|
||||
monster_speed = 100;
|
||||
monster_speed = 20;
|
||||
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
||||
name = "Zombie";
|
||||
leftBorder = (int)position.X;
|
||||
rightBorder = (int)position.X + 200;
|
||||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
public override void Update(GameTime gameTime, Player player)
|
||||
{
|
||||
//Move(gameTime);
|
||||
if (monster_health <= 0)
|
||||
Move(gameTime);
|
||||
|
||||
if(Pos.X + 20 <= player.Pos.X || Pos.X - 20 >= player.Pos.X)
|
||||
{
|
||||
isAlive = false;
|
||||
Death();
|
||||
Attack();
|
||||
player.Death(name);
|
||||
}
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
if (isGoRight)
|
||||
{
|
||||
GraphicsComponent.StopAnimation();
|
||||
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
||||
player.Death(name);
|
||||
AppManager.Instance.GameManager.Player.Death(name);
|
||||
}
|
||||
else if (!isGoRight)
|
||||
{
|
||||
GraphicsComponent.StopAnimation();
|
||||
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
||||
player.Death(name);
|
||||
AppManager.Instance.GameManager.Player.Death(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +63,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
double delta = gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
|
@ -75,5 +82,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
monster_health -= damage;
|
||||
//play take damage animation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
|
||||
public void Death(string monsterName)
|
||||
{
|
||||
|
||||
//анимация по имени монстра
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue