C# question as a beginner (again)

I hope I'm not breaking spam policy, but I asked my question so poorly in my last thread that I ruined any real chance of getting my best answer. I'm trying to make examples without using my program so that I can translate the logic to my program (this is a condition of my assignment). This makes for better learning but tougher communication.

I'll say that my last example was bad. A better one is to say that all of my monsters need to respawn at the beginning of my game loop (or level), and every time I kill an instance of the monster I'm able to successfully remove them from he game (I tested this) with something like…

//my list of Monster objects and their properties Monster Snake = new Monster(1, "Python", 10, true); Monster Mummy = new Monster(2, "Xerxes", 20, true); // and so on.... //(int monsterID, string monsterName, int monsterStrength, bool isAlive) //array of objects. All 30 of them Monster[] monsters = {snake, dragon.... mummy}; //generate new monster to fight Random randMonster = new Random(); //associate monster with RNG (30 monsters) var appearingMonster = monsters[randMonster.Next(0,30)]; //after logic that results in killing the monster... appearingMonster.isAlive= false; //this works too, because I run out of monsters if the level is too long! //But I need to respawn all monsters at the beginning of the next "level" //I'm pretty sure I could just do... //snake.isAllive = true; //mummy.isAlive = true; //I could just repeat that for all 30 monsters. //But I'm thinking there has to be a super simple statement that just does that for all monsters at once. Am I wrong? Thanks! //I'm sorry I was so bad at explaining this earlier! 

by gavinrendar via /r/csharp

Leave a Reply