try to move enemy
This commit is contained in:
parent
8815d65e85
commit
4925b11ab3
9 changed files with 32 additions and 21 deletions
|
@ -22,7 +22,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
//здесь я не понял
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime, Player player)
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
if (monster_health <= 0)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
isAlive = false;
|
||||
}
|
||||
|
||||
Move(gameTime, AppManager.Instance.GameManager.Player);
|
||||
Move(gameTime);
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
|
||||
public abstract void Attack();
|
||||
|
||||
public abstract void Move(GameTime gameTime, Player player);
|
||||
public abstract void Move(GameTime gameTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FlameSkullMoveLeft", "FlameSkullMoveRight" }, "FlameSkullMoveRight");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
/* if (player.Pos.X - _pos.X <= 20 || player.Pos.X - _pos.X <= -20)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "");
|
||||
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
"SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
|
||||
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SpiderMoveRight", "SpiderMoveLeft", "SpiderDown", "SpiderUp" }, "");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "");
|
||||
|
||||
public override void Attack(Player player)
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
||||
|
||||
public override void Update(GameTime gameTime, Player player)
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
Move(gameTime);
|
||||
|
||||
var player = AppManager.Instance.GameManager.Player;
|
||||
if(Pos.X + 20 <= player.Pos.X || Pos.X - 20 >= player.Pos.X)
|
||||
{
|
||||
Attack();
|
||||
|
@ -61,15 +61,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime, Player player)
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
double delta = gameTime.ElapsedGameTime.TotalSeconds;
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveRight");
|
||||
velocity = new Vector2(monster_speed, 0);
|
||||
_pos = new Vector2(Pos.X + monster_speed * (delta), Pos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,8 +80,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
||||
velocity = new Vector2(-monster_speed, 0);
|
||||
_pos = new Vector2(Pos.X - monster_speed * (delta), Pos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
if(Pos.X <= leftBorder)
|
||||
{
|
||||
isGoRight = true;
|
||||
}
|
||||
if(Pos.X >= rightBorder)
|
||||
{
|
||||
isGoRight = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
|
|
Loading…
Add table
Reference in a new issue