In my game I have an Enemy
class, and in that I have a constructor which I use to make Enemy
objects.
How do I add all Enemy
objects to a list or loop through all of them using a foreach
loop?
I have tried various variations of this:
foreach(object E in Enemy){
//Do collision detection, set AIs next move, etc.
}
However, it always rejects the second part of the foreach
loop, saying that Enemy
is a type but is used as a variable.