Example #1
0
 public override void Update(GameTime gameTime)
 {
     CollisionManager.Wereld.Clear();
     CollisionManager.traps.Clear();
     CollisionManager.finish.Clear();
     foreach (var p in map[level].ObjectGroups[0].Objects)
     {
         CollisionManager.Wereld.Add(new Blok(new Rectangle((int)p.X, (int)p.Y, (int)p.Width, (int)p.Height)));
     }
     foreach (var p in map[level].ObjectGroups[2].Objects)
     {
         CollisionManager.traps.Add(new Blok(new Rectangle((int)p.X, (int)p.Y, (int)p.Width, (int)p.Height)));
     }
     foreach (var p in map[level].ObjectGroups[1].Objects)
     {
         CollisionManager.finish.Add(new Blok(new Rectangle((int)p.X, (int)p.Y, (int)p.Width, (int)p.Height)));
     }
     player.Update(gameTime);
     if (collisionManager.CheckFinish(player.CollisionRectangle))
     {
         if (level < map.Count - 1)
         {
             level = level + 2;
             _game.ChangeState(new GameState(_game, _graphicsDevice, _content, level));
         }
         else if (level == map.Count - 1)
         {
             MediaPlayer.Stop();
             MediaPlayer.Play(VictorySound);
             _game.ChangeState(new VictoryState(_game, _graphicsDevice, _content));
         }
     }
     else if (collisionManager.CheckTrap(player.CollisionRectangle))
     {
         MediaPlayer.Stop();
         MediaPlayer.Play(GameOverSound);
         _game.ChangeState(new DeathState(_game, _graphicsDevice, _content));
     }
 }