Esempio n. 1
0
            private void OnItemToggleClicked()
            {
                UIToggle toggle = UIToggle.current;

                if (toggle.value == false)
                {
                    return;
                }

                OperationRedeemCommodity commodity = (OperationRedeemCommodity)toggle.Param;

                mCurrentCommodity = commodity;

                if (commodity == null)
                {
                    return;
                }

                mCommodityNameLabel.text        = GoodsHelper.GetGoodsOriginalNameByTypeId(commodity.IconGoodsId);
                mCommodityDescriptLabel.text    = GoodsHelper.GetGoodsDescriptionByTypeId(commodity.IconGoodsId);
                mCostMoneyTypeSprite.spriteName = UIWidgetHelp.GetMoneySpriteName(commodity.PriceType);
                mBuyNumberInput.value           = "1";

                UpdateCostMoneyLabel();
            }
Esempio n. 2
0
            private void UpdateContent()
            {
                UpdateMoneyLabel();

                ModelHelper.ClearChildren(mCommodityContent);

                const int ITEM_WIDTH  = 168;
                const int ITEM_HEIGHT = 192;

                List <OperationRedeemCommodity> commodites = OperationRedeemManager.Instance.FashionCommodities;

                if (mCurrentShopType == OperationRedeemManager.ShopType.STUFF)
                {
                    commodites = OperationRedeemManager.Instance.StuffCommodities;
                }

                int index = 0;

                foreach (var item in commodites)
                {
                    GameObject itemObject = GameObject.Instantiate(mCommoditySampleItem) as GameObject;
                    itemObject.transform.parent        = mCommodityContent;
                    itemObject.transform.localScale    = Vector3.one;
                    itemObject.transform.localPosition = new Vector3((index % 3) * ITEM_WIDTH, -(index / 3) * ITEM_HEIGHT, 0);

                    UILabel    nameLabel          = ModelHelper.FindChildComponentInHierarchy <UILabel>(itemObject.transform, "NameLabel");
                    UILabel    priceLabel         = ModelHelper.FindChildComponentInHierarchy <UILabel>(itemObject.transform, "PriceLabel");
                    UIToggle   itemToggle         = itemObject.GetComponent <UIToggle>();
                    UISprite   moneyTypeSprite    = ModelHelper.FindChildComponentInHierarchy <UISprite>(itemObject.transform, "MoneyTypeSprite");
                    GameObject limitTimeContainer = ModelHelper.FindChildInHierarchy(itemObject.transform, "LimitTimeContainer").gameObject;

                    Transform iconGoodsRoot = ModelHelper.FindChildComponentInHierarchy <Transform>(itemObject.transform, "IconGoodsRoot");

                    priceLabel.text            = item.Price.ToString();
                    moneyTypeSprite.spriteName = UIWidgetHelp.GetMoneySpriteName(item.PriceType);

                    if (item.EndTime > 0)
                    {
                        limitTimeContainer.SetActive(true);
                    }
                    else
                    {
                        limitTimeContainer.SetActive(false);
                    }

                    GameObject iconGoods = UIWidgetHelp.Instance.CreateGoodsItem(item.IconGoodsId, 0, false, false);
                    iconGoods.transform.parent        = iconGoodsRoot;
                    iconGoods.transform.localPosition = new Vector3(0, 39, 0);
                    iconGoods.transform.localScale    = new Vector3(0.7f, 0.7f, 0.7f);

                    Collider iconCollider = iconGoods.GetComponent <Collider>();
                    if (iconCollider != null)
                    {
                        GameObject.Destroy(iconCollider);
                        iconCollider = null;
                    }

                    nameLabel.text   = GoodsHelper.GetGoodsOriginalNameByTypeId(item.IconGoodsId);
                    itemToggle.Param = item;

                    EventDelegate.Add(itemToggle.onChange, OnItemToggleClicked);

                    if (index == 0)
                    {
                        itemToggle.value = true;
                    }

                    ++index;
                }

                mCommodityScrollView.ResetPosition();

                mReduceButton.gameObject.SetActive(true);
                mAddButton.gameObject.SetActive(true);
                mMaxButton.gameObject.SetActive(true);
            }