Example #1
0
        public void AddReward(ItemBaseInfo[] rewards, Vector3 startPos)
        {
            if (rewards != null)
            {
                List <ItemBaseInfo> list = new List <ItemBaseInfo>();

                foreach (var reward in rewards)
                {
                    var data = new TDataItemList();
                    if (TableManager.Get().ItemList.GetData(reward.ItemId, out data))
                    {
                        switch (data.id)
                        {
                        case 1:     // 골드
                            UserInfoManager.Get().GetUserInfo().gold += reward.Value;
                            UI_GetProduction.Get().Initialize(ITEM_TYPE.GOLD, startPos,
                                                              Mathf.Clamp(reward.Value, 5, 20));
                            break;

                        case 2:     // 다이아
                            UserInfoManager.Get().GetUserInfo().diamond += reward.Value;
                            UI_GetProduction.Get().Initialize(ITEM_TYPE.DIAMOND, startPos,
                                                              Mathf.Clamp(reward.Value, 5, 20));
                            break;

                        case 11:     // 열쇠
                            UserInfoManager.Get().GetUserInfo().key += reward.Value;
                            UI_GetProduction.Get().Initialize(ITEM_TYPE.KEY, startPos,
                                                              Mathf.Clamp(reward.Value, 5, 20));
                            break;

                        default:     // 주사위
                        {
                            ItemBaseInfo rw = new ItemBaseInfo();
                            rw.ItemId = reward.ItemId;
                            rw.Value  = reward.Value;
                            list.Add(rw);
                        }
                        break;
                        }
                    }
                }

                if (list.Count > 0)
                {
                    gerResult.Initialize(list.ToArray(), false, false);
                }
            }
        }
Example #2
0
        public virtual void UpdateContent(ShopInfo shopInfo, ShopProductInfo shopProductInfo)
        {
            this.shopInfo = shopInfo;
            int maxBuyCount = 0;
            int tapInfo     = 0;

            textPItemId.text  = shopProductInfo.shopProductId.ToString();
            textPItemId.text += $"  ({shopProductInfo.buyCount}/{maxBuyCount})";
            int getCount = 0;
            TDataShopProductList data = null;
            TDataItemList        item = null;

            switch (shopInfo.shopId)
            {
            case 1:         // 이벤트 상품
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType     = (BuyType)data.buyType;
                    tapInfo     = data.tapInfo;
                    imageName   = data.shopImage;
                    maxBuyCount = data.buyLimitCnt;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }
#if UNITY_ANDROID
                    productId = data.googleProductId;
#elif UNITY_IOS
                    productId = data.appleProductId;
#endif
                }
            }
            break;

            case 2:         // 패키지 상품
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType     = (BuyType)data.buyType;
                    tapInfo     = data.tapInfo;
                    imageName   = data.shopImage;
                    maxBuyCount = data.buyLimitCnt;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }
#if UNITY_ANDROID
                    productId = data.googleProductId;
#elif UNITY_IOS
                    productId = data.appleProductId;
#endif
                }
            }
            break;

            case 3:         // 일일 상품
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType = (BuyType)data.buyType;
                    tapInfo = data.tapInfo;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.enabled = true;
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.enabled = true;
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }

                    textPItemId.text = $"x{data.itemValue01}";

                    if (TableManager.Get().ItemList.GetData(itm => itm.id == data.itemId01, out item))
                    {
                        imageIcon.sprite = FileHelper.GetIcon(item.itemIcon);
                    }
                }

                buttonShopItem.interactable = shopProductInfo.buyCount == 0;
            }
            break;

            case 4:         // 박스
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType = (BuyType)data.buyType;
                    tapInfo = data.tapInfo;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        pos   = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }

                    textPItemId.text = $"x{data.itemValue01}";

                    if (TableManager.Get().ItemList.GetData(itm => itm.id == data.itemId01, out item))
                    {
                        imageIcon.sprite = FileHelper.GetIcon(item.itemIcon);
                        imageIcon.SetNativeSize();
                    }
                    textPItemBuyCount.text = $"{data.buyPrice}";
                }
            }
            break;

            case 5:         // 프리미엄
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType   = (BuyType)data.buyType;
                    tapInfo   = data.tapInfo;
                    imageName = data.shopImage;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }
#if UNITY_ANDROID
                    productId = data.googleProductId;
#elif UNITY_IOS
                    productId = data.appleProductId;
#endif
                }
            }
            break;

            case 6:         // 이모티콘
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType = (BuyType)data.buyType;
                    tapInfo = data.tapInfo;
                    textPItemBuyCount.text = $"{data.buyType}:{data.buyPrice}";
                }
            }
            break;

            case 7:         // 다이아
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType   = (BuyType)data.buyType;
                    tapInfo   = data.tapInfo;
                    imageName = data.shopImage;
#if UNITY_ANDROID
                    productId = data.googleProductId;
#elif UNITY_IOS
                    productId = data.appleProductId;
#endif
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        pos   = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }

                    textPItemId.text = $"x{data.itemValue01}";

                    if (TableManager.Get().ItemList.GetData(itm => itm.id == data.itemId01, out item))
                    {
                        imageIcon.sprite = FileHelper.GetIcon(data.shopImage);
                    }
                }
            }
            break;

            case 8:         // 골드
            {
                if (TableManager.Get().ShopProductList.GetData(shopProductInfo.shopProductId, out data))
                {
                    buyType   = (BuyType)data.buyType;
                    tapInfo   = data.tapInfo;
                    imageName = data.shopImage;
                    switch (buyType)
                    {
                    case BuyType.gold:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.dia:
                        imagePriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
                        textPItemBuyCount.text = data.buyPrice.ToString();
                        break;

                    case BuyType.cash:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        var pos = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.free:
                        imagePriceIcon.enabled = false;
                        textPItemBuyCount.text = LocalizationManager.GetLangDesc("Shop_Buyfree");
                        pos   = textPItemBuyCount.rectTransform.anchoredPosition;
                        pos.x = 0;
                        textPItemBuyCount.rectTransform.anchoredPosition = pos;
                        break;

                    case BuyType.ad:
                        imagePriceIcon.enabled = false;
                        break;
                    }

                    textPItemId.text = $"x{data.itemValue01}";

                    if (TableManager.Get().ItemList.GetData(itm => itm.id == data.itemId01, out item))
                    {
                        imageIcon.sprite = FileHelper.GetIcon(data.shopImage);
                    }
                    textPItemBuyCount.text = $"{data.buyPrice}";
                }
            }
            break;
            }

            // Tap
            if (data != null)
            {
                switch ((ETapInfoKey)data.tapInfo)
                {
                case ETapInfoKey.tap_hot:
                    textBadge.text = "HOT";
                    textBadge.transform.parent.gameObject.SetActive(true);
                    textValue.transform.parent.gameObject.SetActive(false);
                    textFirstBuy.transform.parent.gameObject.SetActive(false);
                    break;

                case ETapInfoKey.tap_best:
                    textBadge.text = "BEST";
                    textBadge.transform.parent.gameObject.SetActive(true);
                    textValue.transform.parent.gameObject.SetActive(false);
                    textFirstBuy.transform.parent.gameObject.SetActive(false);
                    break;

                case ETapInfoKey.tap_new:
                    textBadge.text = "NEW";
                    textBadge.transform.parent.gameObject.SetActive(true);
                    textValue.transform.parent.gameObject.SetActive(false);
                    textFirstBuy.transform.parent.gameObject.SetActive(false);
                    break;

                case ETapInfoKey.tap_oneplusone:
                    textBadge.text = "1+1";
                    textBadge.transform.parent.gameObject.SetActive(true);
                    textValue.transform.parent.gameObject.SetActive(false);
                    textFirstBuy.transform.parent.gameObject.SetActive(true);
                    break;

                case ETapInfoKey.tap_value:
                    textValue.text = $"{data.tapValue}";
                    textBadge.transform.parent.gameObject.SetActive(false);
                    textValue.transform.parent.gameObject.SetActive(true);
                    textFirstBuy.transform.parent.gameObject.SetActive(false);
                    break;
                }
            }

            buttonShopItem.onClick = new Button.ButtonClickedEvent();

            //shopProductInfo.shopProductId 값으로 테이블에 존재하는 상품 데이터 조회
            //string productId = "mhl_package_crystal_150";

            if (buyType == BuyType.cash)
            {
                textPItemBuyCount.text = InAppManager.Instance.GetIDToProduct(productId)?.metadata.localizedPriceString;
            }
            //else textPItemBuyCount.text = string.Empty;

            shopProductId = shopProductInfo.shopProductId;

            //아이템의 buyType에 따라서 구매 버튼 눌렀을때 다르게 처리하기
            buttonShopItem.onClick.AddListener(() =>
            {
                if (buyType == BuyType.dia || buyType == BuyType.gold)
                {
                    UI_Main.Get().shopBuyPopup.Initialize(imageIcon.sprite, textPItemId.text, buyType,
                                                          textPItemBuyCount.text, item, tapInfo, Buy);
                }
                else
                {
                    Buy();
                }
            });

            SetColor();
        }
Example #3
0
    public void Initialize(Sprite icon, string count, BuyType priceType, string price, TDataItemList item, int tab, UnityAction callback)
    {
        gameObject.SetActive(true);
        //obj_Double.SetActive(isDouble);

        image_Icon.sprite = icon;
        text_Count.text   = count;

        switch (priceType)
        {
        case BuyType.gold:
            image_PriceIcon.enabled = true;
            image_PriceIcon.sprite  = FileHelper.GetIcon("icon_gold");
            var pos = text_Price.rectTransform.anchoredPosition;
            pos.x = 37.5f;
            text_Price.rectTransform.anchoredPosition = pos;
            text_Price.text = price;
            //btn_Buy.interactable = UserInfoManager.Get().GetUserInfo().gold >= Int32.Parse(price);
            break;

        case BuyType.dia:
            image_PriceIcon.enabled = true;
            image_PriceIcon.sprite  = FileHelper.GetIcon("icon_dia");
            pos   = text_Price.rectTransform.anchoredPosition;
            pos.x = 37.5f;
            text_Price.rectTransform.anchoredPosition = pos;
            text_Price.text = price;
            //btn_Buy.interactable = UserInfoManager.Get().GetUserInfo().diamond >= Int32.Parse(price);
            break;

        case BuyType.cash:
            image_PriceIcon.enabled = false;
            text_Price.text         = price;
            pos   = text_Price.rectTransform.anchoredPosition;
            pos.x = 0;
            text_Price.rectTransform.anchoredPosition = pos;
            break;

        case BuyType.free:
            image_PriceIcon.enabled = false;
            text_Price.text         = LocalizationManager.GetLangDesc("Shop_Buyfree");
            pos   = text_Price.rectTransform.anchoredPosition;
            pos.x = 0;
            text_Price.rectTransform.anchoredPosition = pos;
            break;

        case BuyType.ad:
            image_PriceIcon.enabled = false;
            break;
        }

        if (item != null)
        {
            text_Title.text = LocalizationManager.GetLangDesc(item.itemName_langId);
            if ((ITEM_TYPE)item.itemType == ITEM_TYPE.DICE)
            {
                TDataDiceInfo diceInfo;
                if (TableManager.Get().DiceInfo.GetData(dice => dice.id == item.id, out diceInfo))
                {
                    obj_Gauge.SetActive(true);

                    int level     = 1;
                    int diceCount = 0;

                    if (UserInfoManager.Get().GetUserInfo().dicGettedDice.ContainsKey(diceInfo.id))
                    {
                        level     = UserInfoManager.Get().GetUserInfo().dicGettedDice[diceInfo.id][0];
                        diceCount = UserInfoManager.Get().GetUserInfo().dicGettedDice[diceInfo.id][1];
                    }
                    TDataDiceUpgrade dataDiceUpgrade;
                    if (TableManager.Get().DiceUpgrade
                        .GetData(x => x.diceLv == level + 1 && x.diceGrade == diceInfo.grade, out dataDiceUpgrade))
                    {
                        int needDiceCount = dataDiceUpgrade.needCard;
                        slider_Gauge.value  = diceCount / (float)needDiceCount;
                        text_Class.text     = $"{Global.g_class} {level}";
                        text_DiceCount.text = $"{diceCount}/{needDiceCount}";
                        obj_UpgradeIcon.SetActive(diceCount >= needDiceCount);
                    }
                }
            }
            else
            {
                obj_Gauge.SetActive(false);
            }
        }
        else
        {
            text_Title.text = string.Empty;
            obj_Gauge.SetActive(false);
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate(rts_Frame);

        btn_Buy.onClick.RemoveAllListeners();
        btn_Buy.onClick.AddListener(() =>
        {
            if (priceType == BuyType.gold)
            {
                if (UserInfoManager.Get().GetUserInfo().gold < Int32.Parse(price))
                {
                    UI_Main.Get().moveShopPopup.Initialize(UI_BoxOpenPopup.COST_TYPE.GOLD);
                    return;
                }
            }
            else if (priceType == BuyType.dia)
            {
                if (UserInfoManager.Get().GetUserInfo().diamond < Int32.Parse(price))
                {
                    UI_Main.Get().moveShopPopup.Initialize(UI_BoxOpenPopup.COST_TYPE.DIAMOND);
                    return;
                }
            }
            callback?.Invoke();
            Close();
        });
        SetColor();
    }