Ejemplo n.º 1
0
    private void LoadBoxes()
    {
        for (int i = 0; i < 4; i++)
        {
            Transform crate = boxPlaces[i].transform.GetChild(0);
            Transform text  = boxPlaces[i].transform.GetChild(1);

            crate.gameObject.SetActive(false);
            text.gameObject.SetActive(false);
        }

        boxes = DatabaseDataAcces.getPlayerBoxes(player.id);

        for (int i = 0; i < boxes.Count; i++)
        {
            Transform crate = boxPlaces[i].transform.GetChild(0);
            Transform text  = boxPlaces[i].transform.GetChild(1);

            long now = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;

            long   elapsed = (now - boxes[i].acquired) / (1000 * 60);
            string label   = "OPEN";

            if (elapsed < 120)
            {
                label = (120 - elapsed) + "m";
            }

            text.gameObject.GetComponent <Text>().text = label;
            text.gameObject.SetActive(true);

            BoxOnClick onClick = crate.GetComponent <BoxOnClick>();
            onClick.box    = boxes[i];
            onClick.garage = this;
            crate.gameObject.SetActive(true);
        }
    }