public void AjoutEnnemi() { int r = random.Next(0, spawnable.Count); var ennemiPosition = new Vector2(spawnable[r].Position.X, spawnable[r].Position.Y); Ennemi ennemi = new Ennemi(); ennemi.Initialize(ennemiTexture, ennemiPosition); ennemis.Add(ennemi); }
public void Update(GameTime gameTime, Player pPlayer, Ennemi pEnnemi, Texture2D pTexture2, Texture2D pTexture) { Vector2.Distance(ref pEnnemi.Position, ref pPlayer.Position, out float distance); if (distance < 130f) { pEnnemi.ennemiTexture = pTexture2; Vector2 direction = pPlayer.Position - Position; direction.Normalize(); Position += direction * ennemiVitesse; } else { pEnnemi.ennemiTexture = pTexture; } if (Health <= 0) { Active = false; } }