Esempio n. 1
0
    private void OnTriggerStay(Collider other)
    {
        if (other.name == "Player")
        {
            UI_Manager _uiManager = GameObject.Find("Canvas").GetComponent <UI_Manager>();
            Player     _player    = GameObject.Find("Player").GetComponent <Player>();
            if (_player.playerHasCoin == false)
            {
                _uiManager.CollectCoinOverlayOn();
            }
            else if (_player.playerHasCoin == true)
            {
                _uiManager.CollectCoinOverlayOff();
            }
            rb.WakeUp();

            if (Input.GetKeyDown(KeyCode.E))
            {
                if (_player != null)
                {
                    Debug.Log("Player Has Coin");
                    _player.playerHasCoin = true;
                    AudioSource.PlayClipAtPoint(_coinPickUp, transform.position, 1f);
                    _uiManager.CollectCoinOverlayOff();


                    if (_uiManager != null)
                    {
                        _uiManager.CollectedCoin();
                    }
                    Destroy(this.gameObject, 0.5f);
                }
            }
        }
    }
Esempio n. 2
0
    //check for collision
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player")
        {
            _uiManager.actionText("Press E to pick up the coin");
            if (Input.GetKeyDown(KeyCode.E))
            {
                Player player = other.GetComponent <Player>();
                if (player != null)
                {
                    player.hasCoin = true;
                    AudioSource.PlayClipAtPoint(_coinSound, Camera.main.transform.position, 1.0f);

                    if (_uiManager != null)
                    {
                        _uiManager.CollectedCoin();
                    }

                    Destroy(this.gameObject);
                }
                _uiManager.actionDone();
            }
        }
    }