예제 #1
0
    protected void RefreshButton(ShopItemListItem itm, CharacterAccessories accessory, string compoundName)
    {
        if (accessory.cost > PlayerData.instance.coins)
        {
            itm.buyButton.interactable = false;
            itm.pricetext.color        = Color.red;
        }
        else
        {
            itm.pricetext.color = Color.black;
        }

        if (accessory.premiumCost > PlayerData.instance.premium)
        {
            itm.buyButton.interactable = false;
            itm.premiumText.color      = Color.red;
        }
        else
        {
            itm.premiumText.color = Color.black;
        }

        if (PlayerData.instance.characterAccessories.Contains(compoundName))
        {
            itm.buyButton.interactable = false;
            itm.buyButton.image.sprite = itm.disabledButtonSprite;
            itm.buyButton.transform.GetChild(0).GetComponent <UnityEngine.UI.Text>().text = "Owned";
        }
    }
    protected void RefreshButton(ShopItemListItem itemList, Consumable c)
    {
        int count = 0;

        PlayerData.instance.consumables.TryGetValue(c.GetConsumableType(), out count);
        itemList.countText.text = count.ToString();

        if (c.GetPrice() > PlayerData.instance.coins)
        {
            itemList.buyButton.interactable = false;
            itemList.pricetext.color        = Color.red;
        }
        else
        {
            itemList.pricetext.color = Color.black;
        }

        if (c.GetPremiumCost() > PlayerData.instance.premium)
        {
            itemList.buyButton.interactable = false;
            itemList.premiumText.color      = Color.red;
        }
        else
        {
            itemList.premiumText.color = Color.black;
        }
    }
예제 #3
0
    protected void RefreshButton(ShopItemListItem item, Character ch)
    {
        if (ch.cost > PlayerData.instance.coins)
        {
            item.buyButton.interactable = false;
            item.pricetext.color        = Color.red;
        }
        else
        {
            item.pricetext.color = Color.black;
        }

        if (ch.diamondCost > PlayerData.instance.diamonds)
        {
            item.buyButton.interactable = false;
            item.diamondText.color      = Color.red;
        }
        else
        {
            item.diamondText.color = Color.black;
        }

        if (PlayerData.instance.characters.Contains(ch.characterName))
        {
            item.buyButton.interactable = false;
            item.buyButton.image.sprite = item.disabledButtonSprite;
            item.buyButton.transform.GetChild(0).GetComponent <Text>().text = "Owend";
        }
    }
예제 #4
0
    public void Buy(Character c, ShopItemListItem itm)
    {
        int f = PlayerPrefs.GetInt("solde");


        Debug.Log(c.characterName);
        if (c.characterName.Equals("BG") && PlayerPrefs.GetInt("c2") == 0)
        {
            if (f > c.cost)
            {
                itm.buyButton.image.sprite = itm.disabledButtonSprite;
                itm.buyButton.transform.GetComponentsInChildren <Text>()[0].text     = "purchased";
                itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize = itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize - 3;
                PlayerPrefs.SetInt("c2", 1);
                PlayerPrefs.SetInt("solde", f - c.cost);
                Debug.Log(PlayerPrefs.GetInt("solde"));
            }
        }
        if (c.characterName.Equals("BANTOUF") && PlayerPrefs.GetInt("c1") == 0)
        {
            if (f > c.cost)
            {
                itm.buyButton.image.sprite = itm.disabledButtonSprite;
                itm.buyButton.transform.GetComponentsInChildren <Text>()[0].text     = "purchased";
                itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize = itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize - 3;
                PlayerPrefs.SetInt("c1", 1);
                PlayerPrefs.SetInt("solde", f - c.cost);
            }
        }
    }
예제 #5
0
    protected void RefreshButton(ShopItemListItem itemList, Consumable c)
    {
        int count = 0;

        PlayerData.instance.consumables.TryGetValue(c.GetConsumableType(), out count);
        itemList.countText.text = count.ToString();
    }
예제 #6
0
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        GameObject fishItem = Instantiate(fishPrefabItem);

        fishItem.transform.SetParent(listRoot, false);
        fishItem.GetComponent <ShopItemListItem>()
        .buyButton
        .onClick
        .AddListener(delegate() {
            PlayerData.instance.coins += cheatFishCount;
            PlayerData.instance.Save();
        });

        GameObject premiumItem = Instantiate(premiumPrefabItem);

        premiumItem.transform.SetParent(listRoot, false);
        premiumItem.GetComponent <ShopItemListItem>()
        .buyButton
        .onClick
        .AddListener(delegate() {
            PlayerData.instance.premium += cheatPremiumCount;
            PlayerData.instance.Save();
        });


        for (int i = 0; i < s_ConsumablesTypes.Length; ++i)
        {
            Consumable c = ConsumableDatabase.GetConsumbale(s_ConsumablesTypes[i]);
            if (c != null)
            {
                GameObject newEntry = Instantiate(prefabItem);
                newEntry.transform.SetParent(listRoot, false);

                ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                itm.buyButton.image.sprite = itm.buyButtonSprite;

                itm.nameText.text = c.GetConsumableName();
                itm.icon.sprite   = c.icon;

                itm.countText.gameObject.SetActive(true);

                itm.buyButton.onClick.AddListener(delegate() { Buy(c); });
                m_RefreshCallback += delegate() { RefreshButton(itm, c); };
                RefreshButton(itm, c);
            }
        }
    }
예제 #7
0
    public override void Populate()
    {
        m_RefreshCallback = null;

        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        foreach (KeyValuePair <string, Character> pair in CharacterDatabase.dictionary)
        {
            Character c = pair.Value;
            if (c != null && c.accessories != null && c.accessories.Length > 0)
            {
                GameObject header = Instantiate(headerPrefab);
                header.transform.SetParent(listRoot, false);
                ShopItemListItem itmHeader = header.GetComponent <ShopItemListItem>();
                itmHeader.nameText.text = c.characterName;

                for (int i = 0; i < c.accessories.Length; ++i)
                {
                    CharacterAccessories accessory = c.accessories[i];
                    GameObject           newEntry  = Instantiate(prefabItem);
                    newEntry.transform.SetParent(listRoot, false);

                    ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                    string compoundName = c.characterName + ":" + accessory.accessoryName;

                    itm.nameText.text          = accessory.accessoryName;
                    itm.pricetext.text         = accessory.cost.ToString();
                    itm.icon.sprite            = accessory.accessoryIcon;
                    itm.buyButton.image.sprite = itm.buyButtonSprite;

                    if (accessory.premiumCost > 0)
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(true);
                        itm.premiumText.text = accessory.premiumCost.ToString();
                    }
                    else
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(false);
                    }

                    itm.buyButton.onClick.AddListener(delegate() { Buy(compoundName, accessory.cost, accessory.premiumCost); });

                    m_RefreshCallback += delegate() { RefreshButton(itm, accessory, compoundName); };
                    RefreshButton(itm, accessory, compoundName);
                }
            }
        }
    }
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        for (int i = 0; i < s_ConsumablesTypes.Length; ++i)
        {
            Consumable c = ConsumableDatabase.GetConsumbale(s_ConsumablesTypes[i]);
            if (c != null)
            {
                prefabItem.InstantiateAsync().Completed += (op) =>
                {
                    if (op.Result == null || !(op.Result is GameObject))
                    {
                        Debug.LogWarning(string.Format("Unable to load item shop list {0}.", prefabItem.Asset.name));
                        return;
                    }
                    GameObject newEntry = op.Result;
                    newEntry.transform.SetParent(listRoot, false);

                    ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                    itm.buyButton.image.sprite = itm.buyButtonSprite;

                    itm.nameText.text  = c.GetConsumableName();
                    itm.pricetext.text = c.GetPrice().ToString();

                    if (c.GetPremiumCost() > 0)
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(true);
                        itm.premiumText.text = c.GetPremiumCost().ToString();
                    }
                    else
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(false);
                    }

                    itm.icon.sprite = c.icon;

                    itm.countText.gameObject.SetActive(true);

                    itm.buyButton.onClick.AddListener(delegate() { Buy(c); });
                    m_RefreshCallback += delegate() { RefreshButton(itm, c); };
                    RefreshButton(itm, c);
                };
            }
        }
    }
예제 #9
0
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        foreach (KeyValuePair <string, ThemeData> pair in ThemeDatabase.dictionnary)
        {
            ThemeData theme = pair.Value;
            if (theme != null)
            {
                prefabItem.InstantiateAsync().Completed += (op) =>
                {
                    if (op.Result == null || !(op.Result is GameObject))
                    {
                        Debug.LogWarning(string.Format("Unable to load theme shop list {0}.", prefabItem.Asset.name));
                        return;
                    }
                    GameObject newEntry = op.Result;
                    newEntry.transform.SetParent(listRoot, false);

                    ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                    itm.nameText.text  = theme.themeName;
                    itm.pricetext.text = theme.cost.ToString();
                    itm.icon.sprite    = theme.themeIcon;

                    if (theme.premiumCost > 0)
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(true);
                        itm.premiumText.text = theme.premiumCost.ToString();
                    }
                    else
                    {
                        itm.premiumText.transform.parent.gameObject.SetActive(false);
                    }

                    itm.buyButton.onClick.AddListener(delegate() { Buy(theme); });

                    itm.buyButton.image.sprite = itm.buyButtonSprite;

                    RefreshButton(itm, theme);
                    m_RefreshCallback += delegate() { RefreshButton(itm, theme); };
                };
            }
        }
    }
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        for (int i = 0; i < s_ConsumablesTypes.Length; ++i)
        {
            Consumable c = ConsumableDatabase.GetConsumbale(s_ConsumablesTypes[i]);
            if (c != null)
            {
                GameObject newEntry = Instantiate(prefabItem);
                newEntry.transform.SetParent(listRoot, false);

                ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                itm.buyButton.image.sprite = itm.buyButtonSprite;

                itm.nameText.text  = c.GetConsumableName();
                itm.pricetext.text = c.GetPrice().ToString();

                if (c.GetPremiumCost() > 0)
                {
                    itm.premiumText.transform.parent.gameObject.SetActive(true);
                    itm.premiumText.text = c.GetPremiumCost().ToString();
                }
                else
                {
                    itm.premiumText.transform.parent.gameObject.SetActive(false);
                }

                itm.icon.sprite = c.icon;

                itm.countText.gameObject.SetActive(true);

                itm.buyButton.onClick.AddListener(delegate() { Buy(c); });
                m_RefreshCallback += delegate() { RefreshButton(itm, c); };
                RefreshButton(itm, c);
            }
        }
    }
예제 #11
0
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        foreach (KeyValuePair <string, Character> pair in CharacterDatabase.dictionary)
        {
            Character c = pair.Value;
            if (c != null)
            {
                GameObject newEntry = Instantiate(prefabItem);
                newEntry.transform.SetParent(listRoot, false);

                ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

                itm.icon.sprite    = c.icon;
                itm.nameText.text  = c.characterName;
                itm.pricetext.text = c.cost.ToString();

                itm.buyButton.image.sprite = itm.buyButtonSprite;

                if (c.premiumCost > 0)
                {
                    itm.premiumText.transform.parent.gameObject.SetActive(true);
                    itm.premiumText.text = c.premiumCost.ToString();
                }
                else
                {
                    itm.premiumText.transform.parent.gameObject.SetActive(false);
                }

                itm.buyButton.onClick.AddListener(delegate() { Buy(c); });

                m_RefreshCallback += delegate() { RefreshButton(itm, c); };
                RefreshButton(itm, c);
            }
        }
    }
    void LoadedCharacter(AsyncOperationHandle <GameObject> op, int currentIndex)
    {
        if (op.Result == null || !(op.Result is GameObject))
        {
            Debug.LogWarning(string.Format("Unable to load header {0}.", headerPrefab.Asset.name));
        }
        else
        {
            Character c = m_CharacterList[currentIndex];

            GameObject header = op.Result;
            header.transform.SetParent(listRoot, false);
            ShopItemListItem itmHeader = header.GetComponent <ShopItemListItem>();
            itmHeader.nameText.text = c.characterName;

            prefabItem.InstantiateAsync().Completed += (innerOp) =>
            {
                LoadedAccessory(innerOp, currentIndex, 0);
            };
        }
    }
    void LoadedAccessory(AsyncOperationHandle <GameObject> op, int characterIndex, int accessoryIndex)
    {
        Character c = m_CharacterList[characterIndex];

        if (op.Result == null || !(op.Result is GameObject))
        {
            Debug.LogWarning(string.Format("Unable to load shop accessory list {0}.", prefabItem.Asset.name));
        }
        else
        {
            CharacterAccessories accessory = c.accessories[accessoryIndex];

            GameObject newEntry = op.Result;
            newEntry.transform.SetParent(listRoot, false);

            ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

            string compoundName = c.characterName + ":" + accessory.accessoryName;

            itm.nameText.text          = accessory.accessoryName;
            itm.pricetext.text         = accessory.cost.ToString();
            itm.icon.sprite            = accessory.accessoryIcon;
            itm.buyButton.image.sprite = itm.buyButtonSprite;

            if (accessory.premiumCost > 0)
            {
                itm.premiumText.transform.parent.gameObject.SetActive(true);
                itm.premiumText.text = accessory.premiumCost.ToString();
            }
            else
            {
                itm.premiumText.transform.parent.gameObject.SetActive(false);
            }

            itm.buyButton.onClick.AddListener(delegate()
            {
                Buy(compoundName, accessory.cost, accessory.premiumCost);
            });

            m_RefreshCallback += delegate() { RefreshButton(itm, accessory, compoundName); };
            RefreshButton(itm, accessory, compoundName);
        }

        accessoryIndex++;

        if (accessoryIndex == c.accessories.Length)
        {    //we finish the current character accessory, load the next character
            characterIndex++;
            if (characterIndex < m_CharacterList.Count)
            {
                headerPrefab.InstantiateAsync().Completed += (innerOp) =>
                {
                    LoadedCharacter(innerOp, characterIndex);
                };
            }
        }
        else
        {
            prefabItem.InstantiateAsync().Completed += (innerOp) =>
            {
                LoadedAccessory(innerOp, characterIndex, accessoryIndex);
            };
        }
    }
예제 #14
0
    public override void Populate()
    {
        m_RefreshCallback = null;
        foreach (Transform t in listRoot)
        {
            Destroy(t.gameObject);
        }

        Character c1 = new Character();

        c1.cost          = 400;
        c1.characterName = "BANTOUF";
        c1.icon          = f1;

        Character c2 = new Character();

        c2.cost          = 300;
        c2.characterName = "BG";
        c2.icon          = f2;
        List <Character> list = new List <Character>();

        list.Add(c1);
        list.Add(c2);

        Debug.Log(list.Count);
        foreach (Character c in list)
        {
            if (PlayerPrefs.GetInt("c1") == 1)
            {
                b1 = true;
            }
            if (PlayerPrefs.GetInt("c2") == 1)
            {
                b2 = true;
            }
            Debug.Log(b1 + " b2 :" + b2);
            GameObject newEntry = Instantiate(prefabItem);
            newEntry.transform.SetParent(listRoot, false);

            ShopItemListItem itm = newEntry.GetComponent <ShopItemListItem>();

            //  itm.icon.sprite = c.icon;
            itm.nameText.text  = c.characterName;
            itm.pricetext.text = c.cost.ToString();
            itm.icon.sprite    = c.icon;
            if (c.characterName.Equals("BANTOUF"))
            {
                if (b1 == true)
                {
                    Debug.Log("mechri");
                    itm.buyButton.transform.GetComponentsInChildren <Text>()[0].text     = "purchased";
                    itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize = itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize - 3;
                    itm.buyButton.image.sprite = itm.disabledButtonSprite;
                }
                else
                {
                    itm.buyButton.image.sprite = itm.buyButtonSprite;
                }
            }
            if (c.characterName.Equals("BG"))
            {
                if (b2 == true)
                {
                    itm.buyButton.transform.GetComponentsInChildren <Text>()[0].text     = "purchased";
                    itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize = itm.buyButton.transform.GetComponentsInChildren <Text>()[0].fontSize - 3;
                    itm.buyButton.image.sprite = itm.disabledButtonSprite;
                }
                else
                {
                    itm.buyButton.image.sprite = itm.buyButtonSprite;
                }
            }

            if (c.premiumCost > 0)
            {
                itm.premiumText.transform.parent.gameObject.SetActive(true);
                itm.premiumText.text = c.premiumCost.ToString();
            }
            else
            {
                itm.premiumText.transform.parent.gameObject.SetActive(false);
            }

            itm.buyButton.onClick.AddListener(delegate() { Buy(c, itm); });
        }
    }