public void HandleItemButton()
    {
        index      = snapManager.SnapIndex;
        centerItem = items[index];
        itemData   = centerItem.Data;

        if (actionType == ActionType.Shop)
        {
            coinCount = uiBinder.GetIndicatorsData().coinCount;
        }

        switch (itemData.type)
        {
        case ItemType.Map: {
            switch (itemData.mapData.basicData.state)
            {
            case ItemState.Locked:
                playButton.SetActive(false);

                reachLevelText.text = "reach level " + itemData.mapData.basicData.requirement.ToString();
                levelInfoText.SetActive(true);
                break;

            case ItemState.Unlocked:
                uiBinder.SetMapIndex(index);

                levelInfoText.SetActive(false);
                playButton.SetActive(true);
                break;

            default:
                throw new System.Exception("Map state has a problem.");
            }
            break;
        }

        case ItemType.Body: {
            if (!isBodyListenersAdded && IsActivated)
            {
                HandleBodyListeners();
            }

            switch (centerItem.Data.bodyData.payableData.state)
            {
            case ShopItemState.Locked: {
                if (coinCount >= centerItem.Data.bodyData.basicData.requirement)
                {
                    ActivateUnlockedPayButton(centerItem.Data.bodyData.basicData.requirement.ToString());
                }
                else
                {
                    ActivateLockedPayButton(centerItem.Data.bodyData.basicData.requirement.ToString());
                }
                break;
            }

            case ShopItemState.Unlocked: {
                ActivateUseButton();
            }
            break;

            default:
                break;
            }
            break;
        }

        case ItemType.Extra: {
            if (!isExtraListenersAdded && IsActivated)
            {
                HandleExtraListeners();
            }

            switch (centerItem.Data.extraData.payableData.state)
            {
            case ShopItemState.Locked:
                if (coinCount >= centerItem.Data.extraData.basicData.requirement)
                {
                    ActivateUnlockedPayButton(centerItem.Data.extraData.basicData.requirement.ToString());
                }
                else
                {
                    ActivateLockedPayButton(centerItem.Data.extraData.basicData.requirement.ToString());
                }
                break;

            case ShopItemState.Unlocked: {
                ActivateUseButton();
            }
            break;

            default:
                break;
            }
            break;
        }

        case ItemType.Special:
            if (!isSpecialListenersAdded && IsActivated)
            {
                HandleSpecialListeners();
            }

            switch (centerItem.Data.specialData.payableData.state)
            {
            case ShopItemState.Locked:
                if (coinCount >= centerItem.Data.specialData.basicData.requirement)
                {
                    ActivateUnlockedPayButton(centerItem.Data.specialData.basicData.requirement.ToString());
                }
                else
                {
                    ActivateLockedPayButton(centerItem.Data.specialData.basicData.requirement.ToString());
                }
                break;

            case ShopItemState.Unlocked:
                ActivateUseButton();
                break;

            default:
                break;
            }
            break;

        case ItemType.Flag: {
            if (!isFlagListenersAdded && IsActivated)
            {
                HandleFlagListeners();
            }
            payUnlockedButton.SetActive(false);
            payLockedButton.SetActive(false);
            useButton.SetActive(true);
            break;
        }

        default:
            throw new System.Exception("Item Type mismatch.");
        }
    }
Exemple #2
0
 public void Apply()
 {
     killIndicator.ApplyChanges(binder.GetIndicatorsData().killCount);
     coinIndicator.ApplyChanges(binder.GetIndicatorsData().coinCount);
 }