Exemplo n.º 1
0
    public virtual void Die()
    {
        this.isDead = true;
        if (gameObject.tag.Equals("Player"))
        {
            gameObject.GetComponent <MeshRenderer>().enabled = false;
            var renderers = gameObject.GetComponentsInChildren <MeshRenderer>();
            foreach (MeshRenderer mr in renderers)
            {
                mr.enabled = false;
            }
            gameObject.GetComponent <BoxCollider>().enabled   = false;
            gameObject.GetComponent <Rigidbody>().isKinematic = true;
            StartCoroutine(LoadGameOver());
            //SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        //Drop Item Or Key
        ItemDrop dropper = gameObject.GetComponent <ItemDrop>();

        if (dropper)
        {
            if (HoldingKey)
            {
                //Debug.Log("I Should Drop A Key");
                //Drop Key
                dropper.DropKey(this.gameObject.transform);
            }
            else
            {
                //Drop Item
                dropper.DropItem(this.gameObject.transform);
            }
        }
    }