예제 #1
0
 public override void OnDestroy()
 {
     base.OnDestroy();
     foreach (var toggle in EffectSelectors)
     {
         Object.Destroy(toggle);
     }
     EffectSelectors.Clear();
     Object.Destroy(ChoiceDialog);
     ChoiceDialog = null;
 }
예제 #2
0
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (ChoiceDialog == null)
            {
                ChoiceDialog = CreateDialog <AugmentChoiceDialog>(inventoryGui, "AugmentChoiceDialog");

                var background = ChoiceDialog.gameObject.transform.Find("Frame").gameObject.RectTransform();
                ChoiceDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                ChoiceDialog.MagicBG.name   = "MagicItemBG";
                ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                ChoiceDialog.MagicBG.color  = Color.white;

                ChoiceDialog.NameText    = Object.Instantiate(inventoryGui.m_recipeName, background);
                ChoiceDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background);
                ChoiceDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -47);
                ChoiceDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 340);
                ChoiceDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background);

                var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>();
                Object.Destroy(closeButton.gameObject);

                for (int i = 0; i < 3; i++)
                {
                    var button = Object.Instantiate(inventoryGui.m_craftButton, background);
                    var rt     = button.gameObject.RectTransform();
                    rt.anchoredPosition = new Vector2(0, -155 - (i * 45));
                    rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);
                    ChoiceDialog.EffectChoiceButtons.Add(button);
                }
            }

            if (AvailableAugmentsDialog == null)
            {
                AvailableAugmentsDialog = CreateDialog <AugmentsAvailableDialog>(inventoryGui, "AvailableAugmentsDialog");

                var background = AvailableAugmentsDialog.gameObject.transform.Find("Frame").gameObject.RectTransform();
                AvailableAugmentsDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                AvailableAugmentsDialog.MagicBG.name   = "MagicItemBG";
                AvailableAugmentsDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                AvailableAugmentsDialog.MagicBG.color  = Color.white;

                AvailableAugmentsDialog.NameText    = Object.Instantiate(inventoryGui.m_recipeName, background);
                AvailableAugmentsDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background);
                AvailableAugmentsDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110);
                AvailableAugmentsDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460);
                AvailableAugmentsDialog.Description.resizeTextForBestFit = true;
                AvailableAugmentsDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background);

                var closeButton = AvailableAugmentsDialog.gameObject.GetComponentInChildren <Button>();
                closeButton.onClick = new Button.ButtonClickedEvent();
                closeButton.onClick.AddListener(AvailableAugmentsDialog.OnClose);
                closeButton.transform.SetAsLastSibling();
            }

            if (AvailableAugmentsButton == null)
            {
                AvailableAugmentsButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                AvailableAugmentsButton.gameObject.name = "AvailableAugmentsButton";
                AvailableAugmentsButton.gameObject.SetActive(false);
                AvailableAugmentsButton.onClick = new Button.ButtonClickedEvent();
                AvailableAugmentsButton.onClick.AddListener(ShowAvailableAugmentsDialog);

                var text = AvailableAugmentsButton.GetComponentInChildren <Text>();
                text.text = "Available Effects";

                var rt = AvailableAugmentsButton.gameObject.RectTransform();
                rt.anchoredPosition += new Vector2(50, 0);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 150);
            }
        }
예제 #3
0
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (ChoiceDialog == null)
            {
                if (EpicLoot.HasAuga)
                {
                    var resultDialog = Auga.API.Workbench_CreateNewResultsPanel();
                    resultDialog.SetActive(false);

                    ChoiceDialog = resultDialog.AddComponent <AugmentChoiceDialog>();

                    var icon = ChoiceDialog.transform.Find("InventoryElement/icon").GetComponent <Image>();
                    ChoiceDialog.MagicBG        = Object.Instantiate(icon, icon.transform.parent);
                    ChoiceDialog.MagicBG.name   = "MagicItemBG";
                    ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                    ChoiceDialog.MagicBG.color  = Color.white;
                    ChoiceDialog.MagicBG.rectTransform.anchorMin        = new Vector2(0, 0);
                    ChoiceDialog.MagicBG.rectTransform.anchorMax        = new Vector2(1, 1);
                    ChoiceDialog.MagicBG.rectTransform.sizeDelta        = new Vector2(0, 0);
                    ChoiceDialog.MagicBG.rectTransform.anchoredPosition = new Vector2(0, 0);

                    ChoiceDialog.NameText = ChoiceDialog.transform.Find("Topic").GetComponent <Text>();

                    var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>();
                    Object.Destroy(closeButton.gameObject);

                    var tooltip = (RectTransform)ChoiceDialog.transform.Find("TooltipScrollContainer");
                    tooltip.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 360);
                    var scrollbar = (RectTransform)ChoiceDialog.transform.Find("ScrollBar");
                    scrollbar.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 360);

                    for (var i = 0; i < 3; i++)
                    {
                        var button = Auga.API.MediumButton_Create(resultDialog.transform, $"AugmentButton{i}", string.Empty);
                        Auga.API.Button_SetTextColors(button, Color.white, Color.white, Color.white, Color.white, Color.white, Color.white);
                        button.navigation = new Navigation {
                            mode = Navigation.Mode.None
                        };
                        var rt = (RectTransform)button.transform;
                        rt.anchoredPosition = new Vector2(0, -220 - (i * 40));
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 295);
                        ChoiceDialog.EffectChoiceButtons.Add(button);
                    }
                }
                else
                {
                    ChoiceDialog = CreateDialog <AugmentChoiceDialog>(inventoryGui, "AugmentChoiceDialog");

                    var background = ChoiceDialog.gameObject.transform.Find("Frame").gameObject.RectTransform();
                    ChoiceDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                    ChoiceDialog.MagicBG.name   = "MagicItemBG";
                    ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                    ChoiceDialog.MagicBG.color  = Color.white;

                    ChoiceDialog.NameText    = Object.Instantiate(inventoryGui.m_recipeName, background);
                    ChoiceDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background);
                    ChoiceDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -47);
                    ChoiceDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 340);
                    ChoiceDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background);

                    var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>();
                    Object.Destroy(closeButton.gameObject);

                    for (var i = 0; i < 3; i++)
                    {
                        var button = Object.Instantiate(inventoryGui.m_craftButton, background);
                        var rt     = button.gameObject.RectTransform();
                        rt.anchoredPosition = new Vector2(0, -155 - (i * 45));
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);
                        ChoiceDialog.EffectChoiceButtons.Add(button);
                    }
                }
            }

            if (!EpicLoot.HasAuga)
            {
                if (AvailableAugmentsDialog == null)
                {
                    AvailableAugmentsDialog = CreateDialog <AugmentsAvailableDialog>(inventoryGui, "AvailableAugmentsDialog");

                    var background = AvailableAugmentsDialog.gameObject.transform.Find("Frame").gameObject.RectTransform();
                    AvailableAugmentsDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                    AvailableAugmentsDialog.MagicBG.name   = "MagicItemBG";
                    AvailableAugmentsDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                    AvailableAugmentsDialog.MagicBG.color  = Color.white;

                    AvailableAugmentsDialog.NameText    = Object.Instantiate(inventoryGui.m_recipeName, background);
                    AvailableAugmentsDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background);
                    AvailableAugmentsDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110);
                    AvailableAugmentsDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460);
                    AvailableAugmentsDialog.Description.resizeTextForBestFit = true;
                    AvailableAugmentsDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background);

                    var closeButton = AvailableAugmentsDialog.gameObject.GetComponentInChildren <Button>();
                    closeButton.onClick = new Button.ButtonClickedEvent();
                    closeButton.onClick.AddListener(AvailableAugmentsDialog.OnClose);
                    closeButton.transform.SetAsLastSibling();
                }

                if (AvailableAugmentsButton == null)
                {
                    AvailableAugmentsButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                    AvailableAugmentsButton.gameObject.name = "AvailableAugmentsButton";
                    AvailableAugmentsButton.gameObject.SetActive(false);
                    AvailableAugmentsButton.onClick = new Button.ButtonClickedEvent();
                    AvailableAugmentsButton.onClick.AddListener(ShowAvailableAugmentsDialog);

                    var text = AvailableAugmentsButton.GetComponentInChildren <Text>();
                    text.text = Localization.instance.Localize("$mod_epicloot_augment_availableeffects");

                    var rt = AvailableAugmentsButton.gameObject.RectTransform();
                    rt.anchoredPosition += new Vector2(50, 0);
                    rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 150);
                }
            }
        }