private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player" && !PlayerHealthComp.isInDeathMode)
     {
         PlayerHealthComp.KillPlayer();
     }
 }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         PlayerHealthComp.Resurrect();
         if (disappearAfterTouch)
         {
             Destroy(gameObject);
         }
     }
 }
 //called after Reset button is pressed
 public void ResetValues()
 {
     playerRb       = transform.GetComponent <Rigidbody2D>();
     boxCollider2d  = transform.GetComponent <BoxCollider2D>();
     aliveSpeed     = 10f;
     jumpForce      = 20f;
     ghostModeSpeed = 6f;
     isPlayerDead   = false;
     isFacingRight  = true;
     PlayerHealthComp.Resurrect();
 }
Beispiel #4
0
    // Only grab a key when the player is currently not holding another one, and while they are holding Left Shift button
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.GetComponent <KeyComp>() && Input.GetKey(KeyCode.LeftShift) && !keyInHand)
        {
            if (collision.gameObject.tag == "ResKey")
            {
                PlayerHealthComp.Resurrect();
            }

            keyInHand = collision.gameObject.GetComponent <KeyComp>();
            SoundManager.instance.PlaySound(SoundManager.SoundName.key);
        }
    }
Beispiel #5
0
    public void CompleteLevel()
    {
        if (goToNextScene && isUnlocked)
        {
            PlayerHealthComp.Resurrect();

            int currentScene = SceneManager.GetActiveScene().buildIndex;
            int sceneCount   = SceneManager.sceneCountInBuildSettings;
            int nextScene    = currentScene + 1 >= sceneCount ? 0 : currentScene + 1;

            SceneManager.LoadScene(nextScene);
            SoundManager.instance.PlayBackground();
        }
    }