public GamePage() { this.InitializeComponent(); // Create the game. var launchArguments = string.Empty; _game = MonoGame.Framework.XamlGame <FabulousAdventure> .Create(launchArguments, Window.Current.CoreWindow, swapChainPanel); }
public PlayerCharacter(Camera theCamera, Vector2 startPosition, Level currentLevel, float initialSpeed, float initialJumpSpeed, float initialJumpHeight, float initialFallSpeed, FabulousAdventure adv, int health) { m_weapon = new List <Weapon>(maxWeapons); AddWeapon(new Fireballer(this)); AddWeapon(new Vortexer(this)); this.health = health; this.adv = adv; this.TheCamera = theCamera; this.position = startPosition; level = currentLevel; speed = initialSpeed; jumpSpeed = initialJumpSpeed; jumpHeight = initialJumpHeight; weight = initialFallSpeed; //If the character start position is above the ground, they'll fall to the ground CurrentState = CharState.Falling; CollisionArea = new Rectangle((int)startPosition.X, (int)startPosition.Y, 50, 50); }
public Level(int LevelIndex, ContentManager theContentManager, FabulousAdventure adv) { this.adv = adv; m_Tiles = new List <Tile>(); XmlDocument currentLevel; currentLevel = new XmlDocument(); XmlReader reader = XmlReader.Create("Levels/" + LevelIndex + ".xml"); currentLevel.Load(reader); //Get background music for the level from the BackgroundMusic node XmlNodeList music = currentLevel.DocumentElement.GetElementsByTagName("BackgroundMusic"); BGM = music[0].InnerText; //Get start position for the level from the StartTile node XmlNodeList startPosition = currentLevel.GetElementsByTagName("StartPosition"); StartPosition = new Vector2(float.Parse(startPosition[0].Attributes["XPosition"].Value), float.Parse(startPosition[0].Attributes["YPosition"].Value)); XmlNodeList mapSize = currentLevel.GetElementsByTagName("MapSize"); MapBounds = new Rectangle(0, 0, int.Parse(mapSize[0].Attributes["MapWidth"].Value), int.Parse(mapSize[0].Attributes["MapHeight"].Value)); XmlNodeList tileLayers = currentLevel.GetElementsByTagName("TileLayer"); foreach (XmlNode tileLayer in tileLayers) { XmlNodeList tiles = tileLayer.ChildNodes; foreach (XmlNode tile in tiles) { Tile currentTile = new Tile(int.Parse(tile["TileType"].InnerText), bool.Parse(tile["Visible"].InnerText), bool.Parse(tile["Walkable"].InnerText), new Vector2( int.Parse(tile["Column"].InnerText), int.Parse(tile["Row"].InnerText))); currentTile.LoadContent(theContentManager, tile["TileTexture"].InnerText); m_Tiles.Add(currentTile); } } XmlNodeList doors = currentLevel.GetElementsByTagName("Doors"); m_Doors = new List <Door>(); foreach (XmlNode doorData in doors) { XmlNodeList aDoor = doorData.ChildNodes; foreach (XmlNode data in aDoor) { Door currentDoor = new Door(int.Parse(data["DoorNumber"].InnerText), bool.Parse(data["Visible"].InnerText), new Vector2(int.Parse(data["Column"].InnerText), int.Parse(data["Row"].InnerText)), int.Parse(data["LinkedDoor"].InnerText)); currentDoor.LoadContent(theContentManager, data["DoorTexture"].InnerText); m_Doors.Add(currentDoor); } } XmlNodeList enemies = currentLevel.GetElementsByTagName("Enemies"); foreach (XmlNode enemy in enemies) { XmlNodeList enemyData = enemy.ChildNodes; foreach (XmlNode newEnemyData in enemyData) { if (newEnemyData["EnemyType"].InnerText == "Target") { Enemy currentEnemy = new Target(int.Parse(newEnemyData["Health"].InnerText), new Vector2(float.Parse(newEnemyData["Column"].InnerText), float.Parse(newEnemyData["Row"].InnerText))); currentEnemy.LoadContent(theContentManager, newEnemyData["EnemyTexture"].InnerText); EnemyManager.addEnemy(currentEnemy); } if (newEnemyData["EnemyType"].InnerText == "HorizontalTarget") { Enemy currentEnemy = new HorizontalTarget(int.Parse(newEnemyData["Health"].InnerText), new Vector2(float.Parse(newEnemyData["Column"].InnerText), float.Parse(newEnemyData["Row"].InnerText))); currentEnemy.LoadContent(theContentManager, newEnemyData["EnemyTexture"].InnerText); EnemyManager.addEnemy(currentEnemy); } } } //BGMCue = Sound.Play(BGM); }