Facebook
From Eratic Mousedeer, 5 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 220
  1.  
  2.  
  3.  
  4.  
  5. // W LoadContent()
  6. LoadLevel("Level1.xml");
  7.  
  8.  
  9.  
  10.  
  11. // W Draw
  12. protected void LoadLevel(string levelName)
  13.         {
  14.             using (FileStream fs = File.OpenRead("Levels/" + levelName))
  15.             {
  16.                 XmlSerializer serializer = new XmlSerializer(typeof(Level));
  17.                 level = (Level)serializer.Deserialize(fs);
  18.             }
  19.  
  20.             // Generate blocks based on level.layout array
  21.             for (int i = 0; i < level.layout.Length; i++)
  22.             {
  23.                 for (int j = 0; j < level.layout[i].Length; j++)
  24.                 {
  25.                     if (level.layout[i][j] != 9)
  26.                     {
  27.                         Block tempBlock = new Block((BlockColor)level.layout[i][j], this);
  28.                         tempBlock.LoadContent();
  29.                         tempBlock.position = new Vector2(64 + j * 64, 100 + i * 32);
  30.                         blocks.Add(tempBlock);
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.  
  36.         protected void NextLevel()
  37.         {
  38.             // Add points
  39.             AddScore(5000 + 5000 * speedMult + 500 * (balls.Count - 1) * speedMult);
  40.  
  41.             balls.Clear();
  42.             powerups.Clear();
  43.  
  44.             paddle.position = new Vector2(512, 740);
  45.             StartLevelBreak();
  46.  
  47.             // Disable powerups
  48.             ballCatchActive = false;
  49.             paddle.ChangeTexture("paddle");
  50.  
  51.             if (level.nextLevel == "Level1.xml")
  52.             {
  53.                 speedMult++;
  54.             }
  55.             LoadLevel(level.nextLevel);
  56.  
  57.             levelNumber++;
  58.         }