Example #1
0
    public void Init(Item _itemData)
    {
        itemData = _itemData;

        // set the proper values on the entry
        gameObject.name = itemData.ID;

        string costText = itemData.Cost.ToString();

        labelCost.text    = costText;
        labelName.text    = itemData.Name;
        spriteIcon.sprite = SpriteCacheManager.GetSprite(itemData.TextureName);

        BuyButtonStateCheck();

        // set the description
        SetDescription(itemData);

        // if this item is currently locked...
        if (itemData.IsLocked())
        {
            // show the UI
            LevelLockObject.CreateLock(spriteIcon.gameObject.transform.parent.gameObject, itemData.UnlockAtLevel);

            // delete the buy button
            button.gameObject.SetActive(false);
        }
    }
Example #2
0
    public void SetState(AccessoryButtonType buttonType)
    {
        switch (buttonType)
        {
        case AccessoryButtonType.UnboughtLocked:
            // Only want to spawn one lock
            if (!islockExists)
            {
                islockExists = true;

                // Show the lock
                GameObject goLock = LevelLockObject.CreateLock(transform.gameObject, itemData.UnlockAtLevel);
                GameObjectUtils.ResetLocalTransform(goLock);
            }

            buyButton.gameObject.SetActive(false);
            unequipButton.gameObject.SetActive(false);
            equipButton.gameObject.SetActive(false);
            break;

        case AccessoryButtonType.Unbought:
            buyButton.gameObject.SetActive(true);
            unequipButton.gameObject.SetActive(false);
            equipButton.gameObject.SetActive(false);
            break;

        case AccessoryButtonType.BoughtEquipped:
            buyButton.gameObject.SetActive(false);
            unequipButton.gameObject.SetActive(true);
            equipButton.gameObject.SetActive(false);
            break;

        case AccessoryButtonType.BoughtUnequipped:
            buyButton.gameObject.SetActive(false);
            unequipButton.gameObject.SetActive(false);
            equipButton.gameObject.SetActive(true);
            break;

        default:
            Debug.LogError("Invalid state for button type");
            break;
        }
    }