Ejemplo n.º 1
0
 public void ObstacleCollision(ObstacleObject obstacle, Vector3 position)
 {
     if (!powerUpManager.IsPowerUpActive(PowerUpTypes.Invincibility) && !powerUpManager.IsPowerUpActive(PowerUpTypes.SpeedIncrease) && !playerController.WithinReviveGracePeriod() &&
         !godMode && gameActive)
     {
         playerController.ObstacleCollision(obstacle.GetTransform(), position);
         dataManager.ObstacleCollision();
         if (dataManager.GetCollisionCount() == playerController.maxCollisions)
         {
             GameOver(obstacle.isJump ? GameOverType.JumpObstacle : GameOverType.DuckObstacle, true);
         }
         else
         {
             // the chase object will end the game
             if (playerController.maxCollisions == 0 && chaseController != null)
             {
                 if (chaseController.IsVisible())
                 {
                     GameOver(obstacle.isJump ? GameOverType.JumpObstacle : GameOverType.DuckObstacle, true);
                 }
                 else
                 {
                     chaseController.Approach();
                     audioManager.PlaySoundEffect(SoundEffects.ObstacleCollisionSoundEffect);
                 }
             }
             else
             {
                 // have the chase object approach the character when the collision count gets close
                 if (chaseController != null && dataManager.GetCollisionCount() == playerController.maxCollisions - 1)
                 {
                     chaseController.Approach();
                 }
                 audioManager.PlaySoundEffect(SoundEffects.ObstacleCollisionSoundEffect);
             }
         }
     }
 }