private void UpdateGoodsDisplay()
        {
            goodsPool.AddChildInstancesToPool(goodsContainer);

            List <HLHNPCGoods> itemsAsGoods = npc.GetCurrentLevelGoods();

            for (int i = 0; i < itemsAsGoods.Count; i++)
            {
                HLHNPCGoods goods = itemsAsGoods[i];

                Transform goodsCell = goodsPool.GetInstance <Transform>(goodsModel.gameObject, goodsContainer);

                Item itemAsGoods = goods.GetGoodsItem();

                goodsCell.GetComponent <GoodsCell>().SetUpGoodsCell(goods);

                goodsCell.GetComponent <Button>().onClick.RemoveAllListeners();

                int goodsIndex = i;

                goodsCell.GetComponent <Button>().onClick.AddListener(delegate {
                    currentSelectedItem    = itemAsGoods;
                    currentSelectItemPrice = goods.GetGoodsPrice();
                    itemDetail.SetUpItemDetail(itemAsGoods, currentSelectItemPrice, ItemOperationType.Buy);
                    UpdateGoodsSelection(goodsIndex);
                    currentSelectGoodsIndex = goodsIndex;
                    bagItemsDisplay.HideAllItemSelectedTintIcon();
                });
            }
        }
Exemplo n.º 2
0
        public void SetUpGoodsCell(HLHNPCGoods goods)
        {
            Item itemAsGoods = goods.GetGoodsItem();

            goodsName.text = itemAsGoods.itemName;

            goodsName.color        = CommonData.grayEquipmentColor;
            goodsBackground.sprite = grayFrame;

            if (itemAsGoods is Equipment)
            {
                Equipment equipment = itemAsGoods as Equipment;

                switch (equipment.quality)
                {
                case EquipmentQuality.Gray:
                    goodsName.color        = CommonData.grayEquipmentColor;
                    goodsBackground.sprite = grayFrame;
                    break;

                case EquipmentQuality.Blue:
                    goodsName.color        = CommonData.blueEquipmentColor;
                    goodsBackground.sprite = blueFrame;
                    break;

                case EquipmentQuality.Gold:
                    goodsName.color        = CommonData.goldEquipmentColor;
                    goodsBackground.sprite = goldFrame;
                    break;

                case EquipmentQuality.Purple:
                    goodsName.color        = CommonData.purpleEquipmentColor;
                    goodsBackground.sprite = purpleFrame;
                    break;
                }
            }


            int price = goods.GetGoodsPrice();

            goodsPrice.text = price.ToString();

            Sprite itemSprite = GameManager.Instance.gameDataCenter.GetGameItemSprite(itemAsGoods);

            goodsIcon.sprite = itemSprite;

            goodsIcon.enabled = itemSprite != null;

            selectedIcon.enabled = false;
        }
        private void UpdateGoodsSelection(int selectedGoodsIndex)
        {
            for (int i = 0; i < goodsContainer.childCount; i++)
            {
                Transform goodsCell = goodsContainer.GetChild(i);

                goodsCell.GetComponent <GoodsCell> ().SetSelection(i == selectedGoodsIndex);
            }

            List <HLHNPCGoods> goodsList = npc.GetCurrentLevelGoods();

            HLHNPCGoods goods = goodsList [selectedGoodsIndex];

            Item itemAsGoods = goods.GetGoodsItem();

            itemDetail.SetUpItemDetail(itemAsGoods, goods.GetGoodsPrice(), ItemOperationType.Buy);
        }