コード例 #1
0
ファイル: GameManager.cs プロジェクト: Maareks/Endless-Cat
 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);
             }
         }
     }
 }