void PopulatePowerup()
    {
        powerupIcon.gameObject.SetActive(true);

        if (PlayerData.instance.consumables.Count > 0)
        {
            Consumable c = ConsumableDatabase.GetConsumbale(m_PowerupToUse);

            powerupSelect.gameObject.SetActive(true);
            if (c != null)
            {
                powerupIcon.sprite = c.icon;
                powerupCount.text  = PlayerData.instance.consumables[m_PowerupToUse].ToString();
            }
            else
            {
                powerupIcon.sprite = noItemIcon;
                powerupCount.text  = "";
            }
        }
        else
        {
            powerupSelect.gameObject.SetActive(false);
        }
    }
    public override void Exit(AState to)
    {
        missionPopup.gameObject.SetActive(false);
        inventoryCanvas.gameObject.SetActive(false);

        if (m_Character != null)
        {
            Addressables.ReleaseInstance(m_Character);
        }

        GameState gs = to as GameState;

        skyMeshFilter.gameObject.SetActive(false);
        UIGroundFilter.gameObject.SetActive(false);

        if (gs != null)
        {
            gs.currentModifier = m_CurrentModifier;

            // We reset the modifier to a default one, for next run (if a new modifier is applied, it will replace this default one before the run starts)
            m_CurrentModifier = new Modifier();

            if (m_PowerupToUse != Consumable.ConsumableType.NONE)
            {
                PlayerData.instance.Consume(m_PowerupToUse);
                Consumable inv = Instantiate(ConsumableDatabase.GetConsumbale(m_PowerupToUse));
                inv.gameObject.SetActive(false);
                gs.trackManager.characterController.inventory = inv;
            }
        }
    }
Example #3
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);
            }
        }
    }
Example #4
0
    static public void AddConsumables()
    {
        for (int i = 0; i < ShopItemList.s_ConsumablesTypes.Length; ++i)
        {
            Consumable c = ConsumableDatabase.GetConsumbale(ShopItemList.s_ConsumablesTypes[i]);
            if (c != null)
            {
                PlayerData.instance.consumables[c.GetConsumableType()] = 10;
            }
        }

        PlayerData.instance.Save();
    }
    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);
                };
            }
        }
    }
    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);
            }
        }
    }