/// <summary> /// Perform the collision event for the remaining event args /// </summary> /// <param name="args">The list of args to perform</param> private void PerformRemainingCollisions(List <CollisionEventArgs> args) { // Setup bool isDead = false; bool isWon = false; bool unground = false; double ground = double.NaN; // Collision events foreach (CollisionEventArgs arg in args) { if (arg.Command == "coin") { Player.Score.CoinsCollected++; PlaceTile(arg.Sender, false); } else if (arg.Command == "megacoin") { Player.Score.MegaCoinsCollected++; PlaceTile(arg.Sender, false); } else if (arg.Command == "died") { isDead = true; } else if (arg.Command == "haltandwin") { isWon = true; } else if (arg.Command == "ground") { ground = (double)arg.Argument; } else if (arg.Command == "unground") { unground = true; } } // Unground the player if (unground) { Player.Ground(); Player.Unground(MagicNumbers.GRAVITY); } // Ground the player if (Double.IsNaN(ground)) { Player.Unground(); } else { bool wasGround = Player.Gravity == null; Player.Ground(); Player.Bottom = ground; if (!wasGround && _display.JumpAgain()) { Player.Jump(); } } // Player reached the bottom if (Player.Top >= Map.MapHeight) { isDead = true; } // Check if the game is over if (isDead || isWon) { GameOver(isDead); } }