end game when all characters dead
the game starts with one character that can multiply throughout the game. Best way I thought of doing that (but i'm open to better ideas) is to have all the multiples instantiate at start as inactive and then become active when the character multiplies. As each one dies it becomes inactive and can be reactivated later.
Now I only want it to be game over when all the characters are dead. I assume the best way is to use a linq to check if all the characters are dead (i'e inactive) and then end game (again, if there is a better way of doing it please let me know). But I'm struggling with the linq code. Here it is: void start() { players = GameObject.FindWithTag("Player"); }
public bool AllPlayersDisabled
{
get
{
return PlayersCheckDisabled();
}
}
private bool PlayersCheckDisabled()
{
bool check = players.Any(obj => obj.ActiveInHierarchy == false);
if (check)
{
return (true);
}
else
{
return (false);
}
}
Then i'll call game over with AllPlayersDisabled. But can't get it to work. Any help would be really appreciated. thanks!