public void Initialize(ContentManager Content, GraphicsDevice graphicsDevice) { startMenu = new StartMenu(Content); gameOver = new GameOver(Content); playerBullets = new PlayerBullets(); Bullets = new Bullets(); HpBar = new HpBar(); Player.Initialize(); HpBar.Initialize(Player, graphicsDevice); Background.Initialize(this.Resolution); Font = Content.Load <SpriteFont>("Font1"); }
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); }