updated death

This commit is contained in:
bmvolf 2023-08-17 23:53:50 +03:00
parent 607d047c6d
commit 801f0e97d8
2 changed files with 13 additions and 2 deletions

View file

@ -23,6 +23,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public int rightBorder;
public int leftBorder;
public bool isVisible = true;
private bool isAttacked = false;
public GameObject objectAttack;
public Player(Vector2 position) : base(position)
@ -70,6 +71,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
public void Death(string monsterName)
{
isAttacked = true;
if(monsterName == "Zombie")
{
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
@ -77,7 +79,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{
if (a == "DeathFrom" + monsterName)
{
AppManager.Instance.ChangeGameState(GameState.GameOver);
AppManager.Instance.ChangeGameState(GameState.Death);
}
};
}
@ -99,6 +101,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public override void Update(GameTime gameTime)
{
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
if (!isAttacked)
{
Move(gameTime);
}
else
{
velocity.X = 0;
}
base.Update(gameTime);
}

View file

@ -25,7 +25,7 @@ namespace DangerousD.GameCore
public List<Player> players;
public List<GameObject> otherObjects = new();
public Player GetPlayer1 => players[0];
public Player GetPlayer1;
public GameManager()
{
others = new List<GameObject>();
@ -49,6 +49,7 @@ namespace DangerousD.GameCore
{
livingEntities.Add(gameObject as LivingEntity);
players.Add(objPl);
GetPlayer1 = players[0];
}
else if (gameObject is LivingEntity objLE)
{