/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here XmlManager xml = new XmlManager("Game.xml"); gameElements = xml.Load(); gameElements.Initialize(Content, GraphicsDevice); if (GraphicsDevice.DisplayMode.Height == gameElements.Resolution.Y && GraphicsDevice.DisplayMode.Width == gameElements.Resolution.X) { graphics.IsFullScreen = true; } graphics.PreferredBackBufferWidth = (int)gameElements.Resolution.X; graphics.PreferredBackBufferHeight = (int)gameElements.Resolution.Y; this.IsMouseVisible = true; base.Initialize(); }
public void Update(Player Player, StartMenu startMenu, GameWindow gameWindow, GameElements gameElements, ContentManager Content, GraphicsDevice graphicsDevice) { if (!isGameOver) { if (!Player.IsAlive(gameWindow)) { isGameOver = true; } } if (State == MenuStates.MainMenu) { VelocityOfMenu = 0; isGameOver = false; gameElements.newGame = true; } if (State == MenuStates.Moving) { GenerateCurrentMenu(gameWindow); } if (State == MenuStates.Scores) { VelocityOfMenu = 0; GenerateCredits(); } if (State == MenuStates.EndGame) { VelocityOfMenu = 0; GenerateEndMenu(); } if (State == MenuStates.GameShouldStart) { VelocityOfMenu = 0; gameElements.newGame = true; XmlManager xml = new XmlManager("Game.xml"); gameElements = xml.Load(); StartMenu.MyName = StartMenu.prevname; startMenu.State = StartMenu.MenuState.GameShouldStart; startMenu.GameStarted = true; Player.points = 0; } string name = StartMenu.MyName; int score = Player.points; List <KeyValuePair <string, int> > ScoreList = new List <KeyValuePair <string, int> >(); ReadListFromFile(ScoreList); ScoreList.Add(new KeyValuePair <string, int>(name, score)); SortListIfNeeded(ScoreList); WriteListToFile(ScoreList); }