Example #1
0
    public void OpenBox(int id)
    {
        DatabaseDataAcces.OpenBox(id);

        int randomItemId = Random.Range(1, 11);
        int randomStars  = Random.Range(1, 4);

        DatabaseDataAcces.InsertHasCarPart(player.id, randomItemId, randomStars);

        newItem.SetActive(true);
        newItem.transform.localScale = new Vector3(1, 1, 1);

        if (randomStars == 1)
        {
            stars.sprite = oneStar;
        }
        else if (randomStars == 2)
        {
            stars.sprite = twoStars;
        }
        else
        {
            stars.sprite = threeStars;
        }

        GameObject item = carRenderer.RenderItem(randomItemId);

        item.transform.SetParent(newItem.transform, false);
        item.transform.position   = new Vector3(0f, 0f, 0f);
        item.transform.localScale = new Vector3(100f, 100f);
        item.GetComponent <SpriteRenderer>().sortingOrder = 5;

        LoadBoxes();
    }