using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Chests : MonoBehaviour
{
    //void Start () 
    //{

    //}

    //void Update () 
    //{

    //}

    //void OnTriggerEnter(Collider other)
    //{
    //    Debug.Log("Chests");
    //    Global.Chests++;
    //    Destroy(gameObject);
    //}

    void OnCollisionEnter(Collision collision)
    {
        Global.Chests++;
        Debug.Log("Chests");
        updateAfterColectiongBox();
        Destroy(gameObject);

    }

    //void OnCollisionStay(Collision collisionInfo)
    //{
    //    Global.Chests++;
    //    Debug.Log("Chests");
    //    Destroy(gameObject);
    //}

    void updateAfterColectiongBox()
    {
        Text Text = GameObject.Find("UI").transform.FindChild("Text").GetComponent<Text>();
        Text.text = "Chests Collected:" + Global.Chests.ToString();

    }
}
