public void levelSurvived() { gameManagerScript.playerLifeUp(); }
private void OnCollisionEnter2D(Collision2D collision) { if (drop) { if (collision.gameObject.CompareTag("Ground") == false && collision.gameObject.CompareTag("PlatformArrow") == false && collision.gameObject.CompareTag("Box") == false) { try { Physics2D.IgnoreCollision(this.gameObject.GetComponent <BoxCollider2D>(), collision.gameObject.GetComponent <Collider2D>()); } catch { Debug.Log("Collider Error"); } } else { this.gameObject.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll; drop = false; } } else { //physics2d.ignore if (gameManagerScript.getIsVulnerable() == false) { if (collision.gameObject.CompareTag("HammerEnemy")) { Physics2D.IgnoreCollision(this.gameObject.GetComponent <BoxCollider2D>(), collision.gameObject.GetComponent <BoxCollider2D>()); } else if (collision.gameObject.CompareTag("WitchEnemy")) { Physics2D.IgnoreCollision(this.gameObject.GetComponent <BoxCollider2D>(), collision.gameObject.GetComponent <BoxCollider2D>()); } else if (collision.gameObject.CompareTag("Life")) { gameManagerScript.playerLifeUp(); Destroy(collision.gameObject); GetComponent <AudioSource>().PlayOneShot(extraheart); } else if (collision.gameObject.CompareTag("Dog")) { gameManagerScript.setCurrentLevel("WinScreen"); gameManagerScript.startCurrentLevel(); } } else if (collision.gameObject.CompareTag("HammerEnemy") && gameManagerScript.getIsVulnerable() == true) { gameManagerScript.playerDeath(); if (hit == 0) { GetComponent <AudioSource>().PlayOneShot(Swing1); GetComponent <AudioSource>().PlayOneShot(PlayerDeath, 3); hit++; } /* * * Debug.Log("HammerCollision"); * GameObject.Find("GameManager").GetComponent<MainGameManagerScript>().playerLives = GameObject.Find("GameManager").GetComponent<MainGameManagerScript>().playerLives - 1; * Scene scene = SceneManager.GetActiveScene(); * SceneManager.LoadScene(scene.name); */ } else if (collision.gameObject.CompareTag("WitchEnemy") && gameManagerScript.getIsVulnerable() == true) { //GetComponent<AudioSource>().PlayOneShot(PlayerDeath); gameManagerScript.playerDeath(); if (hit == 0) { GetComponent <AudioSource>().PlayOneShot(PlayerDeath); hit++; } } else if (collision.gameObject.CompareTag("Spikes") && gameManagerScript.getIsVulnerable() == true) { //GetComponent<AudioSource>().PlayOneShot(PlayerDeath); gameManagerScript.playerDeath(); if (hit == 0) { GetComponent <AudioSource>().PlayOneShot(PlayerDeath); hit++; } } else if (collision.gameObject.CompareTag("Life") && gameManagerScript.getIsVulnerable() == true) { gameManagerScript.playerLifeUp(); Destroy(collision.gameObject); GetComponent <AudioSource>().PlayOneShot(extraheart); } else if (collision.gameObject.CompareTag("Dog") && gameManagerScript.getIsVulnerable() == true) { gameManagerScript.setCurrentLevel("WinScreen"); gameManagerScript.startCurrentLevel(); } } }