예제 #1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Enemy"))
     {
         foreach (ContactPoint2D hitPos in collision.contacts)
         {
             // If we hit enemy on bottom add to score destroy score and destroy Enemy
             if (hitPos.normal.y > 0)
             {
                 _movementController.movementState = MovementState.Ground;
                 _playerScore.AddToScore(collision.gameObject.GetComponent <DataEnemy>().destroyScore);
                 collision.gameObject.GetComponent <EnemyMovement>().Die();
                 break;
             }
             // Else simulate player's death and calls end game;
             else
             {
                 _gameStatuses.EndGame();
                 _playerSimulator.SimulateDeath();
                 break;
             }
         }
     }
 }