I don't know if what I am trying to do is possible in C# and I couldn't find an answer online. I have 4 enemy objects. One of them dies. I want that enemy to be removed from the array. If the enemy is in the middle of the array, I want the next enemy to take its spot so that the array does not have empty spots in the middle. Here is the code (where I wrote "//remove here" is where I want the object to be removed):
public static int numberOfEnemies = random.Next(1, 4);
// create 1-4 enemies
public static Enemy[] enemyNumber = new Enemy[numberOfEnemies];
// initialize enemies
int h = 0;
do
{
enemyNumber[h] = new Enemy(playerLevel);
h++;
System.Threading.Thread.Sleep(25);
} while (h != numberOfEnemies);
// code where the fight happens i did not include
// enemy dies
if (enemyNumber[0].Ehealth <= 0){
{
Console.WriteLine("Enemy {0} is dead!", eName);
// remove here
}
}