private static void Reset(GameWindow window, ContentManager content) { player.Reset(380, 400, 2.5f, 4.5f); player2.Reset(580, 600, 2.5f, 4.5f); enemies.Clear(); //Skapa fiender Random random = new Random(); Texture2D tmpSprite = content.Load <Texture2D>("mine"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Mine temp = new Mine(tmpSprite, rndX, rndY); enemies.Add(temp); //Lägg till i listan } tmpSprite = content.Load <Texture2D>("tripod"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 5); Tripod temp = new Tripod(tmpSprite, rndX, rndY); enemies.Add(temp); //Lägg till i listan } }
public static void GenerateEnemies(ContentManager content, GameWindow window) { //Skapa fiender och hur många enemies = new List <Enemy>(); Random random = new Random(); Texture2D tmpSprite = content.Load <Texture2D>("mine"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Mine temp = new Mine(tmpSprite, rndX, -rndY); enemies.Add(temp); } tmpSprite = content.Load <Texture2D>("tripod"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 5); Tripod temp = new Tripod(tmpSprite, rndX, -rndY); enemies.Add(temp); } SpriteFont tmpFont = content.Load <SpriteFont>("myFont"); printText = new PrintText(tmpFont); highScore = new HighScore(5, tmpFont); highScore.LoadFromFile("highscore.txt"); return; }