Ejemplo n.º 1
0
 /// <summary>
 /// Method that checks the collision between the player and the different entities on the
 /// different levels. Such as the platform or obstacles. Also checks if the platform is to be dropped of at.
 /// The direction check of platform checks the speed to land.
 /// </summary>
 public void CheckCollsion()
 {
     if (ObstacleCollision.CollisionObstacle(CollisionChecker.player.GetsShape(), obstacles))
     {
         CollisionChecker.player.Alive = false;
         gameOverChecker = true;
     }
     else if (PlatformCollision.CollisionReleasePlatform(CollisionChecker.player.GetsShape()) &&
              CollisionChecker.player.GetsShape().Direction.Y > -0.004f)
     {
         PassengerCollision.CheckDropOffCollision(CollisionChecker.player);
         CollisionChecker.player.Changephysics();
         platformChecker = true;
     }
     else if (PlatformCollision.CollisionPlatform(CollisionChecker.player.GetsShape(), platforms) &&
              CollisionChecker.player.GetsShape().Direction.Y > -0.004f)
     {
         CollisionChecker.player.Changephysics();
         platformChecker = true;
     }
     else if (PlatformCollision.CollisionPlatform(CollisionChecker.player.GetsShape(), platforms) &&
              CollisionChecker.player.GetsShape().Direction.Y < -0.004f)
     {
         ObstacleCollision.CreateExplosion(CollisionChecker.player);
         gameOverChecker = true;
     }
     else if (PassengerCollision.CheckCollisionPassenger(passengers, CollisionChecker.player, specifiedPlatform))
     {
         passengerChecker = true;
     }
 }
        /// <summary>
        ///     Checks if the player is at the right platform
        /// </summary>
        /// <param name="player">player</param>
        /// <returns>bool checking if its the right platform</returns>
        public static bool CollisionReleasePlatform(DynamicShape player)
        {
            foreach (var passenger in PassengerCollision.GetPassengerPickups())
            {
                if (passenger.GetReleasePlatformChar() != '^' &&
                    PlatformCollision.CollisionPlatform(player,
                                                        passenger.GetReleasePlatform()) &&
                    GameRunning.GetLevelCounter() == passenger.SetOffLevel)
                {
                    return(true);
                }
            }

            return(false);
        }