public override void OnDestroy()
 {
     base.OnDestroy();
     foreach (var rarityButton in RarityButtons)
     {
         Object.Destroy(rarityButton);
     }
     RarityButtons.Clear();
     Object.Destroy(SuccessDialog);
     SuccessDialog = null;
 }
Exemplo n.º 2
0
 public override void OnDestroy()
 {
     base.OnDestroy();
     if (EpicLoot.HasAuga && RarityButtons.Count > 0)
     {
         Object.Destroy(RarityButtons[0].transform.parent.gameObject);
     }
     foreach (var rarityButton in RarityButtons)
     {
         Object.Destroy(rarityButton);
     }
     RarityButtons.Clear();
     Object.Destroy(SuccessDialog);
     SuccessDialog = null;
 }
Exemplo n.º 3
0
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (RarityButtons.Count == 0)
            {
                if (EpicLoot.HasAuga)
                {
                    var buttonContainer = new GameObject("EnchantButtons", typeof(RectTransform));
                    buttonContainer.transform.SetParent(AugaTabData.ItemInfoGO.transform);
                    var rt = (RectTransform)buttonContainer.transform;
                    rt.localScale = Vector3.one;
                    rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 324);
                    rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 20);
                    rt.anchoredPosition = new Vector2(0, 250);
                    var hlg = buttonContainer.AddComponent <HorizontalLayoutGroup>();
                    hlg.childControlWidth     = true;
                    hlg.childForceExpandWidth = true;

                    var textPrefab = AugaTabData.ItemInfoGO.transform.Find("Titles/Subtitle").GetComponent <Text>();
                    foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
                    {
                        var rarityColor = EpicLoot.GetRarityColorARGB(rarity);
                        var buttonText  = Object.Instantiate(textPrefab, buttonContainer.transform);
                        buttonText.text = EpicLoot.GetRarityDisplayName(rarity);
                        //buttonText.fontSize = 13;
                        buttonText.raycastTarget = true;
                        buttonText.color         = Color.white;
                        var rarityButton = buttonText.gameObject.AddComponent <Button>();
                        rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity));
                        var colors = rarityButton.colors;
                        ColorUtility.TryParseHtmlString("#D1C9C2FF", out var normalColor);
                        ColorUtility.TryParseHtmlString("#EAE1D9FF", out var highlightedColor);
                        ColorUtility.TryParseHtmlString("#A39689FF", out var pressedColor);
                        colors.normalColor      = normalColor;
                        colors.highlightedColor = highlightedColor;
                        colors.pressedColor     = pressedColor;
                        colors.disabledColor    = new Color(rarityColor.r, rarityColor.g, rarityColor.b, 1);
                        rarityButton.colors     = colors;

                        RarityButtons.Add(rarityButton);
                    }
                }
                else
                {
                    var index    = 0;
                    var startPos = new Vector2(60, -95);
                    foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
                    {
                        var rarityColor = EpicLoot.GetRarityColorARGB(rarity);

                        var rarityButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                        rarityButton.gameObject.name = $"{rarity}EnchantButton";
                        rarityButton.gameObject.SetActive(false);
                        rarityButton.onClick = new Button.ButtonClickedEvent();
                        rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity));
                        rarityButton.colors = new ColorBlock()
                        {
                            disabledColor    = Color.white,
                            highlightedColor = Color.white,
                            pressedColor     = Color.white,
                            normalColor      = new Color(0.7f, 0.7f, 0.7f, 1)
                        };
                        rarityButton.spriteState = new SpriteState()
                        {
                            disabledSprite    = rarityButton.spriteState.selectedSprite,
                            selectedSprite    = rarityButton.spriteState.selectedSprite,
                            pressedSprite     = rarityButton.spriteState.pressedSprite,
                            highlightedSprite = rarityButton.spriteState.highlightedSprite
                        };
                        var outlineGO = new GameObject("EnchantOutline", typeof(RectTransform), typeof(Image));
                        var outline   = outlineGO.GetComponent <Image>();
                        outlineGO.transform.SetParent(rarityButton.transform, false);
                        outline.type   = Image.Type.Sliced;
                        outline.sprite = EpicLoot.Assets.SmallButtonEnchantOverlay;
                        outline.rectTransform.anchorMin        = new Vector2(0, 0);
                        outline.rectTransform.anchorMax        = new Vector2(1, 1);
                        outline.rectTransform.anchoredPosition = new Vector2(0, 0);
                        outline.rectTransform.sizeDelta        = new Vector2(0, 0);
                        outline.color   = rarityColor;
                        outline.enabled = true;

                        var buttonTextColor = rarityButton.GetComponent <ButtonTextColor>();
                        buttonTextColor.m_defaultColor   = rarityColor;
                        buttonTextColor.m_defaultColor.a = 0.7f;
                        buttonTextColor.m_disabledColor  = rarityColor;
                        var text = rarityButton.GetComponentInChildren <Text>();
                        text.text  = rarity.ToString();
                        text.color = rarityColor;
                        RarityButtons.Add(rarityButton);
                        var rt = rarityButton.gameObject.RectTransform();
                        rt.anchoredPosition = startPos + (index * new Vector2(rt.rect.width + 4, 0));
                        index++;
                    }
                }
            }

            if (SuccessDialog == null)
            {
                if (EpicLoot.HasAuga)
                {
                    var resultsPanel = Auga.API.Workbench_CreateNewResultsPanel();
                    resultsPanel.SetActive(false);
                    SuccessDialog          = resultsPanel.gameObject.AddComponent <CraftSuccessDialog>();
                    SuccessDialog.NameText = SuccessDialog.transform.Find("Topic").GetComponent <Text>();
                }
                else
                {
                    SuccessDialog = CraftSuccessDialog.Create(inventoryGui.m_variantDialog.transform.parent);
                }
            }
        }
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (RarityButtons.Count == 0)
            {
                var index    = 0;
                var startPos = new Vector2(60, -95);
                foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
                {
                    var rarityColor = EpicLoot.GetRarityColorARGB(rarity);

                    var rarityButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                    rarityButton.gameObject.name = $"{rarity}EnchantButton";
                    rarityButton.gameObject.SetActive(false);
                    rarityButton.onClick = new Button.ButtonClickedEvent();
                    rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity));
                    rarityButton.colors = new ColorBlock()
                    {
                        disabledColor    = Color.white,
                        highlightedColor = Color.white,
                        pressedColor     = Color.white,
                        normalColor      = new Color(0.7f, 0.7f, 0.7f, 1)
                    };
                    rarityButton.spriteState = new SpriteState()
                    {
                        disabledSprite    = rarityButton.spriteState.selectedSprite,
                        selectedSprite    = rarityButton.spriteState.selectedSprite,
                        pressedSprite     = rarityButton.spriteState.pressedSprite,
                        highlightedSprite = rarityButton.spriteState.highlightedSprite
                    };
                    var outlineGO = new GameObject("EnchantOutline", typeof(RectTransform), typeof(Image));
                    var outline   = outlineGO.GetComponent <Image>();
                    outlineGO.transform.SetParent(rarityButton.transform, false);
                    outline.type   = Image.Type.Sliced;
                    outline.sprite = EpicLoot.Assets.SmallButtonEnchantOverlay;
                    outline.rectTransform.anchorMin        = new Vector2(0, 0);
                    outline.rectTransform.anchorMax        = new Vector2(1, 1);
                    outline.rectTransform.anchoredPosition = new Vector2(0, 0);
                    outline.rectTransform.sizeDelta        = new Vector2(0, 0);
                    outline.color   = rarityColor;
                    outline.enabled = true;

                    var buttonTextColor = rarityButton.GetComponent <ButtonTextColor>();
                    buttonTextColor.m_defaultColor   = rarityColor;
                    buttonTextColor.m_defaultColor.a = 0.7f;
                    buttonTextColor.m_disabledColor  = rarityColor;
                    var text = rarityButton.GetComponentInChildren <Text>();
                    text.text  = rarity.ToString();
                    text.color = rarityColor;
                    RarityButtons.Add(rarityButton);
                    var rt = rarityButton.gameObject.RectTransform();
                    rt.anchoredPosition = startPos + (index * new Vector2(rt.rect.width + 4, 0));
                    index++;
                }
            }

            if (SuccessDialog == null)
            {
                var newDialog = Object.Instantiate(inventoryGui.m_variantDialog, inventoryGui.m_variantDialog.transform.parent);
                SuccessDialog = newDialog.gameObject.AddComponent <CraftSuccessDialog>();
                Object.Destroy(newDialog);
                SuccessDialog.gameObject.name = "CraftingSuccessDialog";

                var background = SuccessDialog.gameObject.transform.Find("VariantFrame").gameObject.RectTransform();
                background.gameObject.name = "Frame";
                for (int i = 1; i < background.transform.childCount; ++i)
                {
                    var child = background.transform.GetChild(i);
                    Object.Destroy(child.gameObject);
                }
                background.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 380);
                background.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 550);
                background.anchoredPosition += new Vector2(20, -270);

                SuccessDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                SuccessDialog.MagicBG.name   = "MagicItemBG";
                SuccessDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                SuccessDialog.MagicBG.color  = Color.white;

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

                var closeButton = SuccessDialog.gameObject.GetComponentInChildren <Button>();
                closeButton.onClick = new Button.ButtonClickedEvent();
                closeButton.onClick.AddListener(SuccessDialog.OnClose);
                closeButton.transform.SetAsLastSibling();
            }
        }
Exemplo n.º 5
0
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (RarityButtons.Count == 0)
            {
                var index    = 0;
                var startPos = new Vector2(60, -95);
                foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
                {
                    var rarityColor = EpicLoot.GetRarityColorARGB(rarity);

                    var rarityButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                    rarityButton.gameObject.name = $"{rarity}EnchantButton";
                    rarityButton.gameObject.SetActive(false);
                    rarityButton.onClick = new Button.ButtonClickedEvent();
                    rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity));
                    rarityButton.colors = new ColorBlock()
                    {
                        disabledColor    = Color.white,
                        highlightedColor = Color.white,
                        pressedColor     = Color.white,
                        normalColor      = new Color(0.7f, 0.7f, 0.7f, 1)
                    };
                    rarityButton.spriteState = new SpriteState()
                    {
                        disabledSprite    = rarityButton.spriteState.selectedSprite,
                        selectedSprite    = rarityButton.spriteState.selectedSprite,
                        pressedSprite     = rarityButton.spriteState.pressedSprite,
                        highlightedSprite = rarityButton.spriteState.highlightedSprite
                    };
                    var outlineGO = new GameObject("EnchantOutline", typeof(RectTransform), typeof(Image));
                    var outline   = outlineGO.GetComponent <Image>();
                    outlineGO.transform.SetParent(rarityButton.transform, false);
                    outline.type   = Image.Type.Sliced;
                    outline.sprite = EpicLoot.Assets.SmallButtonEnchantOverlay;
                    outline.rectTransform.anchorMin        = new Vector2(0, 0);
                    outline.rectTransform.anchorMax        = new Vector2(1, 1);
                    outline.rectTransform.anchoredPosition = new Vector2(0, 0);
                    outline.rectTransform.sizeDelta        = new Vector2(0, 0);
                    outline.color   = rarityColor;
                    outline.enabled = true;

                    var buttonTextColor = rarityButton.GetComponent <ButtonTextColor>();
                    buttonTextColor.m_defaultColor   = rarityColor;
                    buttonTextColor.m_defaultColor.a = 0.7f;
                    buttonTextColor.m_disabledColor  = rarityColor;
                    var text = rarityButton.GetComponentInChildren <Text>();
                    text.text  = rarity.ToString();
                    text.color = rarityColor;
                    RarityButtons.Add(rarityButton);
                    var rt = rarityButton.gameObject.RectTransform();
                    rt.anchoredPosition = startPos + (index * new Vector2(rt.rect.width + 4, 0));
                    index++;
                }
            }

            if (SuccessDialog == null)
            {
                SuccessDialog = CraftSuccessDialog.Create(inventoryGui.m_variantDialog.transform.parent);
            }
        }