public void Interact() { if (isOpened == false) { if (playerCollectables.KeysAmount > 0) { StartCoroutine(open()); highlightningBehaviour = GetComponent <HighlightningBehaviour>(); if (highlightningBehaviour) { IHighlightable ih = highlightningBehaviour.GetComponent <IHighlightable>(); if (ih != null) { ih.Unhighlight(); } Destroy(highlightningBehaviour); } playerCollectables.IncreaseKeysAmount(-1); } else { AudioManager.instance.PlaySound("LockedChest"); cameraShake.Shake(0.015f, 0.017f); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (!isCollected) { if (collision.CompareTag("Player")) { playerCollectables.IncreaseKeysAmount(1); OnCollection.Raise(); if (destructible != null) { destructible.Destroy(transform); } isCollected = true; } } }