public void ReadXml(XmlReader reader) { // Read the wrapper element reader.Read(); // deserialize basic gameplay elements DeserializeGameplayMembers(reader); XmlSerializer bonusSerializer = new XmlSerializer(typeof(Bonus)); bonus = bonusSerializer.Deserialize(reader) as Bonus; // Deserialize the player XmlSerializer playerSerializer = new XmlSerializer(typeof(Player)); player = playerSerializer.Deserialize(reader) as Player; // Deserialize the aliens XmlSerializer enemySerializer = new XmlSerializer(typeof(Enemy)); int enemyCount = int.Parse(reader.GetAttribute("Count")); // Read past the opening element for the alien list reader.Read(); for (int i = 0; i < enemyCount; i++) { enemies.Add(enemySerializer.Deserialize(reader) as Enemy); } // Advance past the closing element if it exists if (enemyCount > 0) { reader.Read(); } reader.Read(); }
public GameplayHelper(ContentManager contentManager, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice) { random = new Random(); worldBounds = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight); gameOver = true; player = new Player(); enemies = new List<Enemy>(); bonus = new Bonus(); InitializeAssets(contentManager, spriteBatch, graphicsDevice); }
public GameplayHelper() { random = new Random(); worldBounds = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight); gameOver = true; player = new Player(); enemies = new List<Enemy>(); bonus = new Bonus(); }