예제 #1
0
    public void OnTriggerEnter(Collider other)
    {
        Trash t = other.gameObject.GetComponent <Trash>();

        if (t != null)
        {
            MapHandler m = FindObjectOfType <MapHandler>();
            if (t.type == type)
            {
                m.AddScore(t.value);
                Destroy(t.gameObject);
            }
            else
            {
                m.RemoveScore();
                Destroy(t.gameObject);
            }
        }

        TruckDepot depot = other.gameObject.GetComponent <TruckDepot>();

        if (depot != null)
        {
            Canvas[] canvasses = FindObjectsOfType <Canvas>();
            if (canvasses != null)
            {
                for (int i = 0; i < canvasses.Length; i++)
                {
                    if (canvasses[i].name == "TruckSpawner")
                    {
                        canvasses[i].enabled = true;
                    }
                }
            }
        }
    }