Esempio n. 1
0
    void RemoveLock()
    {
        string jsonString = File.ReadAllText("Assets/Resources/BoughtItems.json");

        Debug.Log("CIIWB: " + jsonString);

        BoughtItemsScript.BoughtItems it = JsonUtility.FromJson <BoughtItemsScript.BoughtItems>(jsonString);


        for (int i = 0; i < locks.Count; i++)
        {
            Debug.Log(locks[i].name);
        }

        for (int i = 0; i < it.bought_entry_list.Count; i++)
        {
            Debug.Log(it.bought_entry_list[i].name);

            switch (it.bought_entry_list[i].name)
            {
            case "Background 1":
                locks[0].SetActive(false);
                break;

            case "Background 2":
                locks[1].SetActive(false);
                break;

            case "Blue MiniExploders":
                locks[2].SetActive(false);
                break;

            case "Green MiniExploders":
                locks[3].SetActive(false);
                break;

            case "Black Bullet":
                locks[4].SetActive(false);
                break;

            case "Blue Bullet":
                Debug.Log("COMPROU BB");
                locks[5].SetActive(false);
                break;

            case "Laser Machine Gun":
                locks[6].SetActive(false);
                break;

            default:
                break;
            }
        }

        //    BoughtItemsScript.bought = false;
    }
Esempio n. 2
0
    void RemoveLock()
    {
        string path       = Application.dataPath + "/Data/BoughtItems.json";
        string jsonString = File.ReadAllText(path);

        BoughtItemsScript.BoughtItems it = JsonUtility.FromJson <BoughtItemsScript.BoughtItems>(jsonString);

        for (int i = 0; i < it.bought_entry_list.Count; i++)
        {
            switch (it.bought_entry_list[i].name)
            {
            case "Background 1":
                locks[0].SetActive(false);
                break;

            case "Background 2":
                locks[1].SetActive(false);
                break;

            case "Blue MiniExploders":
                locks[2].SetActive(false);
                break;

            case "Green MiniExploders":
                locks[3].SetActive(false);
                break;

            case "Black Bullet":
                locks[4].SetActive(false);
                break;

            case "Blue Bullet":
                Debug.Log("COMPROU BB");
                locks[5].SetActive(false);
                break;

            case "Laser Machine Gun":
                locks[6].SetActive(false);
                break;

            default:
                break;
            }
        }

        //    BoughtItemsScript.bought = false;
    }
Esempio n. 3
0
    private void CreateItemEntry(ItemEntry ie, Transform c, List <Transform> tl)
    {
        float         template_height = 100f;
        Transform     t  = Instantiate(template, c);
        RectTransform rt = t.GetComponent <RectTransform>();

        rt.anchoredPosition = new Vector2(0, -template_height * tl.Count);
        t.gameObject.SetActive(true);

        int    position = tl.Count + 1;
        Sprite s;

        switch (position)
        {
        case 1:
            s = machine_gun;
            break;

        case 2:
            s = background_1;
            break;

        case 3:
            s = background_2;
            break;

        case 4:
            s = mini_exploder_blue;
            // s.transform.localScale = new Vector2(0.5f, 0.5f);
            break;

        case 5:
            s = mini_exploder_green;
            break;

        case 6:
            s = bullet_blue;
            break;

        case 7:
            s = bullet_black;
            break;

        // case 3:
        //     rankString = "3RD";
        //     break;

        default:
            s = machine_gun;
            break;
        }

        t.Find("i").GetComponent <Image>().sprite = s;

        int price = ie.price;

        t.Find("s").GetComponent <Text>().text = price.ToString();

        string name = ie.name;

        t.Find("n").GetComponent <Text>().text = name;

        t.Find("Button").GetComponent <Button>().name = name;
        // Debug.Log(t.Find("Button").GetComponent<Button>());

        // Dont draw button is item is already bought
        string path       = Application.dataPath + "/Data/BoughtItems.json";
        string jsonString = File.ReadAllText(path);

        BoughtItemsScript.BoughtItems it = JsonUtility.FromJson <BoughtItemsScript.BoughtItems>(jsonString);



        // if(it.bought_entry_list.Contains(name))

        for (int i = 0; i < it.bought_entry_list.Count; i++)
        {
            if (name == it.bought_entry_list[i].name)
            {
                t.Find(it.bought_entry_list[i].name).GetComponent <Button>().gameObject.SetActive(false);
            }
        }

        tl.Add(t);
    }