コード例 #1
0
    private void SetPanelLabelsText(ShopItemPanel panel)
    {
        var labelTradeAmountBuy  = panel.Panel.transform.Find("Labels/LabelTradeAmountBuy");
        var labelTotalAmountBuy  = panel.Panel.transform.Find("Labels/LabelTotalAmountBuy");
        var labelTradeAmountSell = panel.Panel.transform.Find("Labels/LabelTradeAmountSell");
        var labelTotalAmountSell = panel.Panel.transform.Find("Labels/LabelTotalAmountSell");

        labelTradeAmountBuy.GetComponent <Text>().text  = _tradeScript.ItemsToBuy.Single(x => x.Item.ItemType == panel.ItemType).TradeAmount.ToString();
        labelTotalAmountBuy.GetComponent <Text>().text  = _tradeScript.ItemsToBuy.Single(x => x.Item.ItemType == panel.ItemType).Item.Amount.ToString();
        labelTradeAmountSell.GetComponent <Text>().text = _tradeScript.ItemsToSell.Single(x => x.Item.ItemType == panel.ItemType).TradeAmount.ToString();
        labelTotalAmountSell.GetComponent <Text>().text = _tradeScript.ItemsToSell.Single(x => x.Item.ItemType == panel.ItemType).Item.Amount.ToString();
    }
コード例 #2
0
        private void AddItemPanel(ShopItem item, bool visible)
        {
            var control = new ShopItemPanel(item)
            {
                Visible = visible
            };

            control.Action += itemPanel_Action;
            itemPanels.Add(item.GetHashCode(), control);
            flowPanel.SuspendLayout();
            flowPanel.Controls.Add(control);
            flowPanel.ResumeLayout();
        }
コード例 #3
0
    void GenerateItemsButtons()
    {
        int i = 0;

        foreach (ItemType item in Enum.GetValues(typeof(ItemType)))
        {
            GameObject panel         = Instantiate(ItemPanelPrefab);
            var        ShopItemPanel = new ShopItemPanel {
                ItemType = item, Panel = panel
            };
            _shopItemPanels.Add(ShopItemPanel);

            var imageObject = panel.transform.Find("Image");

            var buttonPlusBuy   = panel.transform.Find("Buttons/ButtonPlusBuy");
            var buttonMinusBuy  = panel.transform.Find("Buttons/ButtonMinusBuy");
            var buttonPlusSell  = panel.transform.Find("Buttons/ButtonPlusSell");
            var buttonMinusSell = panel.transform.Find("Buttons/ButtonMinusSell");

            imageObject.GetComponent <Image>().sprite = GetItemImageByType(item);

            var item1 = item;
            buttonPlusBuy.GetComponent <Button>().onClick.AddListener(() => _tradeScript.RaiseBuyAmount(item1.ToString()));
            buttonMinusBuy.GetComponent <Button>().onClick.AddListener(() => _tradeScript.DecreaseBuyAmount(item1.ToString()));
            buttonPlusSell.GetComponent <Button>().onClick.AddListener(() => _tradeScript.RaiseSellAmount(item1.ToString()));
            buttonMinusSell.GetComponent <Button>().onClick.AddListener(() => _tradeScript.DecreaseSellAmount(item1.ToString()));

            panel.transform.SetParent(ItemsPanel.transform, false);
            panel.transform.localScale    = new Vector3(1, 1, 1);
            panel.transform.localPosition = new Vector3(0, 0 - i * 70, 0);

            _itemsPanelRectTransform.sizeDelta = new Vector2(_itemsPanelRectTransform.sizeDelta.x, _itemsPanelRectTransform.sizeDelta.y + 70);

            SetPanelLabelsText(ShopItemPanel);

            i++;
        }
    }
コード例 #4
0
ファイル: ShopDialog.cs プロジェクト: aggpys/Atreia-World
        private void AddItemPanel(ShopItem item, bool visible)
        {
            var control = new ShopItemPanel(item)
            {
                Visible = visible
            };

            control.Action += itemPanel_Action;
            itemPanels.Add(item.GetHashCode(), control);
            flowPanel.SuspendLayout();
            flowPanel.Controls.Add(control);
            flowPanel.ResumeLayout();
        }