protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); String path = "./../../../../Scores.txt"; TextWriter tw = new StreamWriter(path, true); tw.WriteLine("Player 1: " + scoreByBomberman["Player One"] + "/ Player 2: " + scoreByBomberman["Player Two"]); tw.Close(); } for (int i = 0; i < bombermans.Count; i++) { bombermans[i].Update(gameTime); if (background.fireIntersectSomething(bombermans[i].getCurrentPosition())) { if (bombermans[i] is BombermanPlayerOne) { this.scoreByBomberman["Player Two"] += 1; } else { this.scoreByBomberman["Player One"] += 1; } background = Background.getInstance(true); enemy = null; bombermans.Clear(); bombermans.Add(BombermanPlayerOne.getInstance(true)); bombermans.Add(BombermanPlayerTwo.getInstance(true)); lastDieTime = gameTime.TotalGameTime; } } if (enemy == null) { if (gameTime.TotalGameTime.Subtract(lastDieTime).Seconds > 30) { enemy = Enemy.getInstance(true); } } else { enemy.Update(gameTime); } background.Update(gameTime); base.Update(gameTime); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); visualScore = new Dictionary <string, SpriteFont>(); visualScore.Add("Player One", Content.Load <SpriteFont>("Shared/Images/Score")); visualScore.Add("Player Two", Content.Load <SpriteFont>("Shared/Images/Score")); sounds = new Dictionary <string, Song>(); sounds.Add("enviroment", Content.Load <Song>("Shared/Sounds/EnviromentMusic")); soundsEffects = new Dictionary <string, SoundEffect>(); soundsEffects.Add("bomb", Content.Load <SoundEffect>("Shared/Sounds/Bomb")); soundsEffects.Add("bonus", Content.Load <SoundEffect>("Shared/Sounds/bonus")); scoreByBomberman = new Dictionary <string, int>(); scoreByBomberman.Add("Player Two", 0); scoreByBomberman.Add("Player One", 0); bombermans.Add(BombermanPlayerOne.getInstance()); bombermans.Add(BombermanPlayerTwo.getInstance()); background = Background.getInstance(); }