private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(Key)) { Destroy(other.gameObject); key = true; inventory.AddKey(); soundEffector.PlayGemSound(); } if (other.gameObject.CompareTag(Constants.Door)) { if (other.gameObject.GetComponent <Door>().isOpen&& canTp) { canTp = false; other.gameObject.GetComponent <Door>().Teleport(gameObject); StartCoroutine(TeleportWait()); } else if (key) { other.gameObject.GetComponent <Door>().Unlock(); } } if (other.gameObject.CompareTag(Coin)) { Destroy(other.gameObject); _coins++; soundEffector.PlayCoinSound(); } if (other.gameObject.CompareTag(Heart)) { if (_currentHp != maxHp) { Destroy(other.gameObject); RecountHp(1); soundEffector.PlayGemSound(); } } if (other.gameObject.CompareTag(Mushroom)) { Destroy(other.gameObject); RecountHp(-1); soundEffector.PlayHitSound(); } if (other.gameObject.CompareTag(GemBlue)) { Destroy(other.gameObject); inventory.AddBlueGem(); soundEffector.PlayGemSound(); } if (other.gameObject.CompareTag(GemGreen)) { Destroy(other.gameObject); inventory.AddGreenGem(); soundEffector.PlayGemSound(); } if (other.gameObject.CompareTag(GemYellow)) { Destroy(other.gameObject); inventory.AddYellowGem(); soundEffector.PlayGemSound(); } if (other.gameObject.CompareTag(TimerButtonStart)) { _healthCountdownTimer = 0f; } if (other.gameObject.CompareTag(TimerButtonStop)) { _healthCountdownTimer = -1f; healthCountdown.fillAmount = 0f; } if (other.gameObject.CompareTag(HiddenPass)) { other.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.5f); SpriteRenderer[] spriteRenderers = other.GetComponentsInChildren <SpriteRenderer>(); foreach (var spriteRenderer in spriteRenderers) { spriteRenderer.color = new Color(1, 1, 1, 0.5f); } } }