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();
    }
Beispiel #2
0
    public void AddPlayerButton()
    {
        string nick  = nickname.text;
        string first = firstName.text;
        string last  = lastName.text;
        int    a     = int.Parse(age.text);


        Player p = DatabaseDataAcces.getPlayerWithNickname(nick);

        if (p == null)
        {
            p           = new Player();
            p.nickname  = nick;
            p.firstName = first;
            p.lastName  = last;
            p.age       = a;

            DatabaseDataAcces.insertPlayer(p);
        }

        p = DatabaseDataAcces.getPlayerWithNickname(nick);

        int chassisId = DatabaseDataAcces.InsertHasCarPart(p.id, 1, 1);
        int attackId  = DatabaseDataAcces.InsertHasCarPart(p.id, 7, 1);
        int wheelId   = DatabaseDataAcces.InsertHasCarPart(p.id, 5, 1);
        int wheel2Id  = DatabaseDataAcces.InsertHasCarPart(p.id, 5, 1);

        HasCarPart chassis = DatabaseDataAcces.getHasCarPart(chassisId);
        HasCarPart attack  = DatabaseDataAcces.getHasCarPart(attackId);
        HasCarPart wheel   = DatabaseDataAcces.getHasCarPart(wheelId);
        HasCarPart wheel2  = DatabaseDataAcces.getHasCarPart(wheel2Id);

        DatabaseDataAcces.InsertPlayerCar(p.id);

        DatabaseDataAcces.changePart(chassis, 1);
        DatabaseDataAcces.changePart(attack, 1);
        DatabaseDataAcces.changePart(wheel, 1);
        DatabaseDataAcces.changePart(wheel2, 2);

        DatabaseDataAcces.insertBox(p.id, 0);
        DatabaseDataAcces.insertBox(p.id, 0);

        SceneManager.LoadScene("StartupScene");
    }