コード例 #1
0
        GameObject PopUpItemPanel(Vector2 Pos, ItemSlot Slot, int IndexOf)
        {
            GameObject PopUp = Manager.GetPanel(Manager.UICanvas().transform, new Vector2(400, 400), Pos);
            Image      temp  = PopUp.GetComponent <Image>();
            Color      color = temp.color; color.a = 1.0f;

            temp.color = color;

            HorizontalLayoutGroup group = PopUp.AddComponent <HorizontalLayoutGroup>();

            PopUp.AddComponent <PopUpMouseControl>();

            group.childControlWidth = false;

            Text info = Manager.TextBox(PopUp.transform, new Vector2(250, 300));

            info.text     = Slot.Item.ItemName + "\n";
            info.text    += Slot.Item.Description + "\n";
            info.fontSize = 20;

            info.text += "Cost: " + Mathf.RoundToInt(Slot.Item.Value * Store.Sell) + " gil";

            VerticalLayoutGroup ButtonPanel = Manager.GetPanel(PopUp.transform, new Vector2(150, 300), Pos).AddComponent <VerticalLayoutGroup>();

            if (Buying)
            {
                switch (Slot.Item.Type)
                {
                case ItemType.General:
                case ItemType.Crafting_Materials:

                    Button Buy1 = Manager.UIButton(ButtonPanel.transform, "Buy 1 ");
                    Button Buy5 = Manager.UIButton(ButtonPanel.transform, "Buy 5 ");
                    Buy1.onClick.AddListener(() =>
                    {
                        Store.BuyItemFrom(Slot);
                        Object.Destroy(PopUp);
                    });
                    Buy5.onClick.AddListener(() =>
                    {
                        Store.BuyXItemsFrom(Slot, 5);

                        Object.Destroy(PopUp);
                    });
                    break;

                case ItemType.Armor:
                case ItemType.Weapon:
                case ItemType.Blueprint_Recipes:
                    Button Buy = Manager.UIButton(ButtonPanel.transform, "Buy");
                    Buy.onClick.AddListener(() =>
                    {
                        Store.BuyItemFrom(Slot);
                        Object.Destroy(PopUp);
                    });

                    break;
                }
            }
            else
            {
                switch (Slot.Item.Type)
                {
                case ItemType.General:
                case ItemType.Crafting_Materials:

                    Button Sell1 = Manager.UIButton(ButtonPanel.transform, "Sell 1 ");
                    Button Sell5 = Manager.UIButton(ButtonPanel.transform, "Sell 5 ");
                    Sell1.onClick.AddListener(() =>
                    {
                        Store.SellItemTo(Slot, IndexOf);
                        Object.Destroy(PopUp);
                    });
                    Sell5.onClick.AddListener(() =>
                    {
                        Store.SellxItemsTo(Slot, IndexOf, 5);
                        ItemPanel = DisplayItems(ItemType.None, MenuPanelParent.transform);

                        Object.Destroy(PopUp);
                    });
                    break;

                case ItemType.Armor:
                case ItemType.Weapon:
                case ItemType.Blueprint_Recipes:
                    Button Sell = Manager.UIButton(ButtonPanel.transform, "sell");
                    Sell.onClick.AddListener(() =>
                    {
                        Store.SellItemTo(Slot, IndexOf);
                        ItemPanel = DisplayItems(ItemType.None, MenuPanelParent.transform);
                        Object.Destroy(PopUp);
                    });

                    break;
                }
            }
            return(PopUp);
        }