private void OnMouseOver() { if (Vector3.Distance(transform.position, player.transform.position) < 5) { if (playerItemScript.GetHasItem() == false || itemAccepted) { displayTextScript.SetEnabled(false); } else { displayTextScript.SetEnabled(true); playerItemScript.AllowDroppingItems(false); if (playerItemScript.GetHeldObject().name == itemToAccept.name && Input.GetKeyDown(KeyCode.E)) { playerItemScript.DisableItemOnPedestal(); playerItemScript.GetItemPlace(itemPlace); playerItemScript.TriggerAnimPlace(); itemAccepted = true; m_MyAudioSource.Play(); if (doorManagerScript != null) { doorManagerScript.CheckWinCondition(); } else if (gateManagerScript != null) { gateManagerScript.OpenGate(); } else { Debug.Log(gameObject.name + " is missing door reference"); } } } } }
private void OnMouseOver() { if (Vector3.Distance(transform.position, player.transform.position) < 5) { if (playerItemScript.GetHeldObject().CompareTag("Key")) { displayTextScript.SetText("Press E to unlock"); } if (Input.GetKeyDown(KeyCode.E) && !openChest && playerItemScript.GetHeldObject().CompareTag("Key")) { openChest = true; displayTextScript.SetEnabled(false); animChest.SetTrigger("openChest"); playerItemScript.DestroyKey(); m_MyAudioSource.Play(); } } }