Search Results

Search found 1 results on 1 pages for 'p3erfect'.

Page 1/1 | 1 

  • How to reset a List c# and XNA [on hold]

    - by P3erfect
    I need to do a "retry" option when the player finishes the game.For doing this I thought to reset the lists of Monsters and other objects that moved at the first playing or which have been "killed".for example I have a list like that: //the enemy1 class is already done // in Game1 I declare it List<enemy1> enem1 = new List<enemy1>(); //Initialize method List<enemy1> enem1 = new List<enemy1>(); //LoadContent foreach (enemy1 enemy in enem1) { enemy.Load(Content); } enem1.Add(new enemy1(Content.Load<Texture2D>("enemy"), new Vector2(5900, 12600))); //Update foreach (enemy1 enemy in enem1) { enemy.Update(gameTime); } //after being shoted the enemies disappear and i remove them //if the monsters are shoted the bool "visible" goes from false to true for (int i = enem1.Count - 1; i >= 0; --i) { if (enem1[i].visible == true) enem1.RemoveAt(i); } //Draw foreach (enemy1 enemy in enem1) { if(enemy.visble==false) { enemy.Draw(spriteBatch, gameTime); } } //So my problem is to restart the game. I did this in Update method if(lost==false) { //update all the things... } if(lost==true)//this is if I die { //here I have to put the code that restore the list //I tried: foreach (enemy1 enemy in enem1) { enemy.visible=false; } player.life=3;//initializing the player,points,time player.position=initialPosition; points=0; time=0; }//the player works.. } } they should be drawn again but if I removed them they won't be drawn anymore.If I don't remove them ,instead, the enemies are in different places (because they follow me). Any suggestions to restore or reinitialize the list??

    Read the article

1