void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Enemy")) { StartCoroutine(GameOver()); } if (collision.CompareTag("Goal")) { StartCoroutine(Winning()); } if (collision.CompareTag("Warp") && warpManager.activatedWarp.GetComponent <Warp>().canEnter) { if (!_teleportHasPlayed) { FindObjectOfType <AudioManager>().Play("Teleport"); _teleportHasPlayed = true; } _teleportHasPlayed = false; StartCoroutine(WarpEnter(collision.gameObject)); } if (collision.CompareTag("Key")) { if (!_keyHasPlayed) { FindObjectOfType <AudioManager>().Play("Key"); _keyHasPlayed = true; } Destroy(collision.gameObject); goal.ActivateGoal(); } }
public void ActivateGoal(bool left) { if (left) { leftGoal.ActivateGoal(); } else { rightGoal.ActivateGoal(); } }