public static bool priceCheck(ShopItem.Type type, int price, bool openShop = true)
    {
        switch (type)
        {
        case ShopItem.Type.gold:
            if (GameDataManager.instance.gold < price)
            {
                if (openShop)
                {
                    UISystemPopup.open(UISystemPopup.PopupType.GoToGoldShop);
                }
                return(false);
            }
            break;

        case ShopItem.Type.ruby:
            if (GameDataManager.instance.ruby < price)
            {
                if (openShop)
                {
                    UISystemPopup.open(UISystemPopup.PopupType.GoToRubyShop);
                }
                return(false);
            }
            break;
        }

        return(true);
    }
示例#2
0
文件: Player.cs 项目: CZSeas/Champion
    void OnTriggerEnter(Collider c)
    {
        ShopItem shopItem = c.GetComponent <ShopItem>();

        if (shopItem != null)
        {
            UIController.instance.DisplayBottomText(shopItem.PriceString());
            typeOfItemToPickup = shopItem.type;
            currentShopItem    = shopItem;
        }
    }
 public static bool priceCheck(ShopItem.Type type, float price, bool openShop = true)
 {
     return(priceCheck(type, Mathf.RoundToInt(price), openShop));
 }
示例#4
0
    public override void setData(object obj)
    {
        if (obj == null)
        {
            this.gameObject.SetActive(false);
            return;
        }
        else
        {
            this.gameObject.SetActive(true);
        }

        lbBonusNum.enabled = false;

        _type    = UIShopItemList.type;
        _nowItem = (P_Product)obj;

        if (string.IsNullOrEmpty(_nowItem.imgUrl) == false && _nowItem.imgUrl.StartsWith("http"))
        {
            photo.gameObject.SetActive(true);
            goDefaultContainer.SetActive(false);
            goNormalContainer.SetActive(false);
            goItemContainer.SetActive(false);

            _imgUrl = _nowItem.imgUrl;

            photo.init(_nowItem.imgUrl);

            _title = _nowItem.desc.Split('/');

            switch (_type)
            {
            case ShopItem.Type.item:

                if (TutorialManager.instance.isTutorialMode)
                {
                    if (TutorialManager.nowPlayingTutorial("T44") && _nowItem.id == "ITEM_P1_UNIT")
                    {
                        btn.gameObject.name = "P";
                    }
                    else if (TutorialManager.nowPlayingTutorial("T45") && _nowItem.id == "ITEM_P1_SKILL")
                    {
                        btn.gameObject.name = "P";
                    }
                    else
                    {
                        btn.gameObject.name = string.Empty;
                    }
                }

                if (_title.Length == 3 || _title.Length == 4)
                {
                    _currentItemName = _title[0] + " " + _title[1];
                }

                break;
            }


            return;
        }

        _imgUrl = null;

        _title = _nowItem.desc.Split('/');

        goDefaultContainer.SetActive(true);
        photo.gameObject.SetActive(false);


        if (_nowItem.priceType == PRICE_TYPE_MONEY)
        {
                        #if UNITY_ANDROID
            lbPrice.text = Util.GetCommaScore(Mathf.RoundToInt(_nowItem.price));
                        #else
            lbPrice.text = string.Format("{0:F2}", _nowItem.price);
                        #endif
        }
        else
        {
            lbPrice.text = Util.GetCommaScore(Mathf.RoundToInt(_nowItem.price));
        }

        spPriceIcon.spriteName = getPriceType(_nowItem.priceType);
        spPriceIcon.MakePixelPerfect();

        spGiftWord.enabled = _type == ShopItem.Type.gift;

        switch (_type)
        {
        case  ShopItem.Type.energy:

            goNormalContainer.gameObject.SetActive(true);
            goItemContainer.gameObject.SetActive(false);

            spRibon.spriteName = "img_buy_ruby";

            spCenterIcon.spriteName = "img_buy_energy_0" + ((index + 1 < 5)?index + 1:5);
            spCenterIcon.MakePixelPerfect();

            lbNormalItemName.enabled = true;
            lbNormalItemName.text    = _title[0];         //Util.getUIText("ENERGY",_nowItem.count.ToString());
            lbCount.enabled          = false;


            _v   = spPriceIcon.transform.localPosition;
            _v.x = 7; _v.y = -147;
            spPriceIcon.transform.localPosition = _v;

            _v   = lbPrice.transform.localPosition;
            _v.x = 68; _v.y = -149;
            lbPrice.transform.localPosition = _v;

            setBonusLabelAndSprite();

            break;

        case  ShopItem.Type.gold:

            goNormalContainer.gameObject.SetActive(true);
            goItemContainer.gameObject.SetActive(false);

            spRibon.spriteName = "img_buy_ruby";

            spCenterIcon.spriteName = "img_buy_gold_0" + ((index + 1 < 5)?index + 1:5);
            spCenterIcon.MakePixelPerfect();

            lbNormalItemName.enabled = false;
            lbCount.enabled          = true;

            lbCount.text = Util.GetCommaScore(_nowItem.count);

            setBonusLabelAndSprite();

            _v   = spPriceIcon.transform.localPosition;
            _v.x = 7; _v.y = -147;
            spPriceIcon.transform.localPosition = _v;

            _v   = lbPrice.transform.localPosition;
            _v.x = 68; _v.y = -149;
            lbPrice.transform.localPosition = _v;

            break;

        case ShopItem.Type.ruby:
        case ShopItem.Type.gift:

            goNormalContainer.gameObject.SetActive(true);
            goItemContainer.gameObject.SetActive(false);

            spRibon.spriteName = "img_buy_ruby";

            spCenterIcon.spriteName = "img_buy_ruby_0" + ((index + 1 < 5)?index + 1:5);
            spCenterIcon.MakePixelPerfect();

            lbNormalItemName.enabled = false;
            lbCount.enabled          = true;

            lbCount.text = Util.GetCommaScore(_nowItem.count);



            _v   = lbPrice.transform.localPosition;
            _v.x = 68; _v.y = -149;
            lbPrice.transform.localPosition = _v;


            _v   = spPriceIcon.transform.localPosition;
            _v.x = lbPrice.transform.localPosition.x - lbPrice.printedSize.x * 0.5f - 30f;              //7;
            _v.y = -147;
            spPriceIcon.transform.localPosition = _v;

            setBonusLabelAndSprite();

            break;

        case ShopItem.Type.item:

            if (TutorialManager.instance.isTutorialMode)
            {
                btn.gameObject.name = string.Empty;
            }

            goNormalContainer.gameObject.SetActive(false);
            goItemContainer.gameObject.SetActive(true);

            char[] ta        = _nowItem.id.ToCharArray();
            bool   isNormal  = (ta[5] == 'N');
            bool   isPackage = (ta[6] != '1');

            if (TutorialManager.nowPlayingTutorial("T44"))
            {
                btn.gameObject.name = "";
            }

            switch (ta[8])
            {
            case 'U':
                if (isPackage && !isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premiumset_01";
                }
                else if (!isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premium_01";

                    if (TutorialManager.nowPlayingTutorial("T44") && _nowItem.id == "ITEM_P1_UNIT")
                    {
                        btn.gameObject.name = "P";
                    }
                }
                else
                {
                    spEquipIcon.spriteName = "img_buy_normal_01";
                    if (TutorialManager.nowPlayingTutorial("T44"))
                    {
                        btn.gameObject.name = "N";
                    }
                }
                break;

            case 'S':
                if (isPackage && !isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premiumset_02";
                }
                else if (!isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premium_02";

                    if (TutorialManager.nowPlayingTutorial("T45") && _nowItem.id == "ITEM_P1_SKILL")
                    {
                        btn.gameObject.name = "P";
                    }
                }
                else
                {
                    spEquipIcon.spriteName = "img_buy_normal_02";
                }
                break;



            case 'E':
                if (isPackage && !isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premiumset_03";
                }
                else if (!isNormal)
                {
                    spEquipIcon.spriteName = "img_buy_premium_03";

                    if (TutorialManager.nowPlayingTutorial("T50"))
                    {
                        btn.gameObject.name = "P";
                    }
                }
                else
                {
                    spEquipIcon.spriteName = "img_buy_normal_03";
                }
                break;
            }


            switch (_title.Length)
            {
            case 3:
                lbPrefix.text         = _title[0];
                lbItemName.text       = _title[1];
                lbEquipMiddleMsg.text = _title[2];

                _currentItemName = _title[0] + " " + _title[1];

                break;

            case 4:
                lbPrefix.text = _title[0];

                lbItemName.text       = _title[1];
                lbItemCount.text      = _title[2];
                lbEquipMiddleMsg.text = _title[3];

                _currentItemName = _title[0] + " " + _title[1];
                break;
            }

            lbItemCount.enabled = (isPackage && !isNormal);

            _v   = lbPrefix.transform.localPosition;
            _v.x = 52; _v.y = 148;
            lbPrefix.transform.localPosition = _v;

            _v   = lbPrefix.transform.localScale;
            _v.x = 1.1f; _v.y = 1.1f;
            lbPrefix.transform.localScale = _v;

            _v   = lbItemName.transform.localPosition;
            _v.x = 53; _v.y = 118;
            lbItemName.transform.localPosition = _v;



            spEquipTitleRibon.spriteName = (isNormal)?"img_buy_normal":"img_buy_premium";

            spEquipIcon.MakePixelPerfect();


            _v   = spPriceIcon.transform.localPosition;
            _v.x = 22; _v.y = -147;
            spPriceIcon.transform.localPosition = _v;

            _v   = lbPrice.transform.localPosition;
            _v.x = 77; _v.y = -149;
            lbPrice.transform.localPosition = _v;

            break;
        }
    }