public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var rarityColor     = EpicLoot.GetRarityColor(recipe.ToRarity);
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(recipe.ToRarity);

                __instance.m_recipeIcon.enabled = true;
                __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                __instance.m_recipeName.enabled = true;
                __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor));

                __instance.m_recipeDecription.enabled = true;
                __instance.m_recipeDecription.text    = Localization.instance.Localize(GenerateEnchantTooltip(recipe));

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                SetupRequirementList(__instance, player, recipe);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1);
                __instance.m_craftButton.interactable = canCraft;
                __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant";
                __instance.m_craftButton.GetComponent <UITooltip>().m_text    = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement");
            }
        }
Exemplo n.º 2
0
        public void SetItem(SecretStashItemInfo itemInfo, Currencies currencies)
        {
            ItemInfo = itemInfo;
            var canAfford = CanAfford(currencies);

            Icon.sprite   = ItemInfo.Item.GetIcon();
            Icon.color    = canAfford ? Color.white : new Color(1.0f, 0.0f, 1.0f, 0.0f);
            NameText.text = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName(canAfford ? null : "grey"));

            CoinsCostText.text = ItemInfo.Cost.Coins.ToString();
            CoinsCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.Coins > 0);

            ForestTokenCostText.text = ItemInfo.Cost.ForestTokens.ToString();
            ForestTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.ForestTokens > 0);

            IronBountyTokenCostText.text = ItemInfo.Cost.IronBountyTokens.ToString();
            IronBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.IronBountyTokens > 0);

            GoldBountyTokenCostText.text = ItemInfo.Cost.GoldBountyTokens.ToString();
            GoldBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.GoldBountyTokens > 0);

            if (!canAfford)
            {
                CoinsCostText.color           = Color.grey;
                ForestTokenCostText.color     = Color.grey;
                IronBountyTokenCostText.color = Color.grey;
                GoldBountyTokenCostText.color = Color.grey;
            }

            MagicBG.enabled = itemInfo.GuaranteedRarity || ItemInfo.Item.UseMagicBackground();
            if (canAfford)
            {
                MagicBG.color = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColorARGB(itemInfo.Rarity) : ItemInfo.Item.GetRarityColor();
            }
            else
            {
                MagicBG.color = new Color(1.0f, 0.0f, 1.0f, 0.0f);
            }
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => OnSelected?.Invoke(ItemInfo));

            Tooltip.m_topic = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName());
            Tooltip.m_text  = Localization.instance.Localize(ItemInfo.Item.GetTooltip());

            if (ItemInfo.IsGamble)
            {
                var color         = canAfford ? (itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColor(itemInfo.Rarity) : "white") : "grey";
                var rarityDisplay = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityDisplayName(itemInfo.Rarity) : "$mod_epicloot_merchant_unknown";
                NameText.text = Localization.instance.Localize($"<color={color}>{rarityDisplay} {ItemInfo.Item.m_shared.m_name}</color>");

                Tooltip.m_topic = NameText.text;
                Tooltip.m_text  = GetGambleTooltip();
            }
        }
Exemplo n.º 3
0
        public void AddRecipeToList(InventoryGui __instance, AugmentRecipe recipe, int index)
        {
            var count   = __instance.m_recipeList.Count;
            var element = Object.Instantiate(__instance.m_recipeElementPrefab, __instance.m_recipeListRoot);

            element.SetActive(true);
            element.RectTransform().anchoredPosition = new Vector2(0.0f, count * -__instance.m_recipeListSpace);

            //var canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1);
            var item = recipe.FromItem;

            var image = element.transform.Find("icon").GetComponent <Image>();

            image.sprite = item.GetIcon();
            image.color  = Color.white;

            var bgImage = Object.Instantiate(image, image.transform.parent, true);

            bgImage.name = "MagicItemBG";
            bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex());
            bgImage.sprite = EpicLoot.Assets.GenericItemBgSprite;
            bgImage.color  = EpicLoot.GetRarityColorARGB(item.GetRarity());

            var nameText = element.transform.Find("name").GetComponent <Text>();

            nameText.text = Localization.instance.Localize(item.GetDecoratedName());
            if (item.GetMagicItem() != null && item.GetMagicItem().HasBeenAugmented())
            {
                nameText.text += " ◇";
            }
            nameText.color = Color.white;

            var durability = element.transform.Find("Durability").GetComponent <GuiBar>();

            if (item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability())
            {
                durability.gameObject.SetActive(true);
                durability.SetValue(item.GetDurabilityPercentage());
            }
            else
            {
                durability.gameObject.SetActive(false);
            }

            var quality = element.transform.Find("QualityLevel").GetComponent <Text>();

            quality.gameObject.SetActive(true);
            quality.text = item.m_quality.ToString();

            element.GetComponent <Button>().onClick.AddListener(() => OnSelectedRecipe(__instance, index));
            __instance.m_recipeList.Add(element);
        }
Exemplo n.º 4
0
        private void SetSelectorValues(AugmentRecipe recipe, int i, MagicItem magicItem, ItemRarity rarity)
        {
            var selector           = EffectSelectors[i];
            var augmentableEffects = magicItem.Effects;

            if (EpicLoot.HasAuga)
            {
                selector.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                selector.gameObject.SetActive(true);
            }

            selector.isOn = recipe.EffectIndex == i;
            var t = selector.GetComponentInChildren <Text>();

            t.text  = GetAugmentSelectorText(magicItem, i, augmentableEffects, rarity);
            t.color = EpicLoot.GetRarityColorARGB(rarity);
        }
Exemplo n.º 5
0
        private void GenerateAugmentSelectors(AugmentRecipe recipe, InventoryGui inventoryGui)
        {
            const float spacing        = 34;
            var         checkboxPrefab = Menu.instance.m_settingsPrefab.GetComponent <Settings>().m_invertMouse;
            var         magicItem      = recipe.FromItem.GetMagicItem();
            var         rarity         = recipe.FromItem.GetRarity();
            var         startOffset    = new Vector2(-330, -165);

            var augmentableEffects = magicItem.Effects;
            var effectCount        = augmentableEffects.Count;

            for (var i = 0; i < Mathf.Max(effectCount, EffectSelectors.Count); ++i)
            {
                if (i < effectCount && i >= EffectSelectors.Count)
                {
                    // create new selector
                    var selector = Object.Instantiate(checkboxPrefab, inventoryGui.m_variantButton.transform.parent, false);
                    selector.gameObject.name = $"EffectSelector{i}";
                    var rt = selector.gameObject.RectTransform();
                    rt.anchoredPosition = startOffset + new Vector2(0, i * -spacing);
                    var t = selector.GetComponentInChildren <Text>();
                    t.font              = inventoryGui.m_recipeDecription.font;
                    t.text              = MagicItem.GetEffectText(augmentableEffects[i], rarity, true);
                    t.color             = magicItem.HasBeenAugmented() && recipe.EffectIndex != i ? Color.gray : EpicLoot.GetRarityColorARGB(rarity);
                    t.resizeTextMaxSize = 18;
                    t.resizeTextMinSize = 10;
                    t.rectTransform.anchoredPosition += new Vector2(300, 0);
                    t.alignment = TextAnchor.MiddleLeft;
                    t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 300);
                    t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, spacing);
                    var index = i;
                    selector.onValueChanged.AddListener((selected) => OnSelectorValueChanged(index, selected));
                    selector.isOn = recipe.EffectIndex == i;
                    selector.gameObject.SetActive(true);
                    selector.interactable = !magicItem.HasBeenAugmented() || recipe.EffectIndex == i;

                    EffectSelectors.Add(selector);
                }
                else if (i >= effectCount && i < EffectSelectors.Count)
                {
                    EffectSelectors[i].gameObject.SetActive(false);
                }
                else
                {
                    var selector = EffectSelectors[i];
                    selector.gameObject.SetActive(true);
                    selector.isOn         = recipe.EffectIndex == i;
                    selector.interactable = !magicItem.HasBeenAugmented() || recipe.EffectIndex == i;
                    var t = selector.GetComponentInChildren <Text>();
                    t.text  = MagicItem.GetEffectText(augmentableEffects[i], rarity, true);
                    t.color = magicItem.HasBeenAugmented() && recipe.EffectIndex != i ? Color.gray : EpicLoot.GetRarityColorARGB(rarity);
                }
            }
        }
Exemplo n.º 6
0
        public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var magicItem       = itemData.GetMagicItem();
                var rarity          = itemData.GetRarity();
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(rarity);

                __instance.m_recipeIcon.enabled = true;
                __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                __instance.m_recipeName.enabled = true;
                __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName());

                __instance.m_recipeDecription.enabled = true;

                __instance.m_recipeDecription.text = "Replace one magical effect. Once an effect has been augmented, the others are locked.";

                if (magicItem.HasBeenAugmented())
                {
                    recipe.EffectIndex = magicItem.AugmentedEffectIndex;
                }
                GenerateAugmentSelectors(recipe, __instance);

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                SetupRequirementList(__instance, player, recipe);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft                = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe), false, 1);
                var hasSelectedEffect       = recipe.EffectIndex >= 0;
                var hasAnyAvailableEnchants = GetAvailableAugments(recipe, recipe.FromItem, recipe.FromItem.GetMagicItem(), recipe.FromItem.GetRarity()).Count > 0;
                __instance.m_craftButton.interactable = canCraft && hasSelectedEffect && hasAnyAvailableEnchants;
                __instance.m_craftButton.GetComponentInChildren <Text>().text = "Augment";
                __instance.m_craftButton.GetComponent <UITooltip>().m_text    =
                    hasSelectedEffect ?
                    (canCraft ?
                     (hasAnyAvailableEnchants ?
                      ""
                                : "No available effects")
                            : Localization.instance.Localize("$msg_missingrequirement"))
                        : "Select an effect to augment";
            }
            else
            {
                bgImage.enabled = false;
                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);
                __instance.m_minStationLevelIcon.gameObject.SetActive(false);
                __instance.m_recipeIcon.enabled       = false;
                __instance.m_recipeName.enabled       = false;
                __instance.m_recipeDecription.enabled = false;
                foreach (var toggle in EffectSelectors)
                {
                    toggle.gameObject.SetActive(false);
                }
                foreach (var req in __instance.m_recipeRequirementList)
                {
                    InventoryGui.HideRequirement(req.transform);
                }

                __instance.m_craftButton.interactable = false;
            }
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
0
        public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            __instance.m_craftButton.GetComponentInChildren <Text>().text = Localization.instance.Localize("$mod_epicloot_enchant");

            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var rarityColor     = EpicLoot.GetRarityColor(SelectedRarity);
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(SelectedRarity);

                var isCrafting = __instance.m_craftTimer >= 0.0f;
                for (var index = 0; index < RarityButtons.Count; index++)
                {
                    var rarityButton     = RarityButtons[index];
                    var rarity           = (ItemRarity)index;
                    var canEnchantRarity = CanEnchantRarity(player, rarity);
                    rarityButton.gameObject.SetActive(!isCrafting && canEnchantRarity);
                    rarityButton.interactable = SelectedRarity != rarity;

                    if (!EpicLoot.HasAuga)
                    {
                        var outline = rarityButton.transform.Find("EnchantOutline").GetComponent <Image>();
                        outline.enabled = !rarityButton.interactable;
                    }
                }

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe, SelectedRarity), false, 1);
                __instance.m_craftButton.interactable = canCraft;
                __instance.m_craftButton.GetComponent <UITooltip>().m_text = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement");

                SetupRequirementList(__instance, player, recipe, canCraft);

                if (EpicLoot.HasAuga)
                {
                    AugaTabData.ItemInfoGO.SetActive(true);
                    AugaTabData.RequirementsPanelGO.SetActive(true);

                    Auga.API.ComplexTooltip_ClearTextBoxes(AugaTabData.ItemInfoGO);
                    Auga.API.ComplexTooltip_SetItemNoTextBoxes(AugaTabData.ItemInfoGO, itemData, itemData.m_quality, itemData.m_variant);
                    Auga.API.ComplexTooltip_SetTopic(AugaTabData.ItemInfoGO, Localization.instance.Localize(itemData.GetDecoratedName()));
                    __instance.m_itemCraftType.text = "";

                    var textbox = Auga.API.ComplexTooltip_AddTwoColumnTextBox(AugaTabData.ItemInfoGO);
                    Auga.API.TooltipTextBox_AddLine(textbox, GenerateEnchantTooltip(recipe));
                }
                else
                {
                    __instance.m_recipeIcon.enabled = true;
                    __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                    __instance.m_recipeName.enabled = true;
                    __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor));

                    __instance.m_recipeDecription.enabled = true;
                    __instance.m_recipeDecription.text    = Localization.instance.Localize(GenerateEnchantTooltip(recipe));
                }
            }
            else
            {
                if (EpicLoot.HasAuga)
                {
                    AugaTabData.ItemInfoGO.SetActive(false);
                    AugaTabData.RequirementsPanelGO.SetActive(false);
                }

                bgImage.enabled = false;
                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);
                __instance.m_minStationLevelIcon.gameObject.SetActive(false);
                __instance.m_recipeIcon.enabled       = false;
                __instance.m_recipeName.enabled       = false;
                __instance.m_recipeDecription.enabled = false;
                foreach (var rarityButton in RarityButtons)
                {
                    rarityButton.gameObject.SetActive(false);
                }
                foreach (var req in __instance.m_recipeRequirementList)
                {
                    InventoryGui.HideRequirement(req.transform);
                }

                __instance.m_craftButton.interactable = false;
            }
        }
        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.º 10
0
        public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var rarityColor     = EpicLoot.GetRarityColor(SelectedRarity);
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(SelectedRarity);

                for (var index = 0; index < RarityButtons.Count; index++)
                {
                    var rarityButton     = RarityButtons[index];
                    var rarity           = (ItemRarity)index;
                    var canEnchantRarity = CanEnchantRarity(player, rarity);
                    rarityButton.gameObject.SetActive(canEnchantRarity);
                    rarityButton.interactable = SelectedRarity != rarity;

                    var outline = rarityButton.transform.Find("EnchantOutline").GetComponent <Image>();
                    outline.enabled = !rarityButton.interactable;
                }

                __instance.m_recipeIcon.enabled = true;
                __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                __instance.m_recipeName.enabled = true;
                __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor));

                __instance.m_recipeDecription.enabled = true;
                __instance.m_recipeDecription.text    = Localization.instance.Localize(GenerateEnchantTooltip(recipe));

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                SetupRequirementList(__instance, player, recipe);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe, SelectedRarity), false, 1);
                __instance.m_craftButton.interactable = canCraft;
                __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant";
                __instance.m_craftButton.GetComponent <UITooltip>().m_text    = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement");
            }
            else
            {
                bgImage.enabled = false;
                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);
                __instance.m_minStationLevelIcon.gameObject.SetActive(false);
                __instance.m_recipeIcon.enabled       = false;
                __instance.m_recipeName.enabled       = false;
                __instance.m_recipeDecription.enabled = false;
                foreach (var rarityButton in RarityButtons)
                {
                    rarityButton.gameObject.SetActive(false);
                }
                foreach (var req in __instance.m_recipeRequirementList)
                {
                    InventoryGui.HideRequirement(req.transform);
                }

                __instance.m_craftButton.interactable = false;
            }
        }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
0
        public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            __instance.m_craftButton.GetComponentInChildren <Text>().text = Localization.instance.Localize("$mod_epicloot_augment");

            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var rarity          = itemData.GetRarity();
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(rarity);

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft                = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe), false, 1) || player.NoCostCheat();
                var hasSelectedEffect       = recipe.EffectIndex >= 0;
                var hasAnyAvailableEnchants = GetAvailableAugments(recipe, recipe.FromItem, recipe.FromItem.GetMagicItem(), recipe.FromItem.GetRarity()).Count > 0;
                __instance.m_craftButton.interactable = canCraft && hasSelectedEffect && hasAnyAvailableEnchants;
                __instance.m_craftButton.GetComponent <UITooltip>().m_text =
                    hasSelectedEffect ?
                    (canCraft ?
                     (hasAnyAvailableEnchants ?
                      ""
                                : Localization.instance.Localize("$mod_epicloot_augment_noeffects"))
                            : Localization.instance.Localize("$msg_missingrequirement"))
                        : Localization.instance.Localize("$mod_epicloot_augment_selecteffect");

                SetupRequirementList(__instance, player, recipe, canCraft);

                if (EpicLoot.HasAuga)
                {
                    AugaTabData.ItemInfoGO.SetActive(true);
                    AugaTabData.RequirementsPanelGO.SetActive(true);

                    EpicLoot.AugaTooltipNoTextBoxes = true;
                    Auga.API.ComplexTooltip_SetItemNoTextBoxes(AugaTabData.ItemInfoGO, itemData, itemData.m_quality, itemData.m_variant);
                    Auga.API.ComplexTooltip_SetTopic(AugaTabData.ItemInfoGO, Localization.instance.Localize(itemData.GetDecoratedName()));
                    Auga.API.ComplexTooltip_SetDescription(AugaTabData.ItemInfoGO, Localization.instance.Localize("$mod_epicloot_augment_explain"));
                    EpicLoot.AugaTooltipNoTextBoxes = false;
                    __instance.m_itemCraftType.text = "";
                }
                else
                {
                    __instance.m_recipeIcon.enabled = true;
                    __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                    __instance.m_recipeName.enabled = true;
                    __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName());

                    __instance.m_recipeDecription.enabled = true;
                    __instance.m_recipeDecription.text    = Localization.instance.Localize("$mod_epicloot_augment_explain");
                }

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                GenerateAugmentSelectors(recipe, __instance);
            }
            else
            {
                if (EpicLoot.HasAuga)
                {
                    AugaTabData.ItemInfoGO.SetActive(false);
                    AugaTabData.RequirementsPanelGO.SetActive(false);
                }

                bgImage.enabled = false;
                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);
                __instance.m_minStationLevelIcon.gameObject.SetActive(false);
                __instance.m_recipeIcon.enabled       = false;
                __instance.m_recipeName.enabled       = false;
                __instance.m_recipeDecription.enabled = false;

                if (!EpicLoot.HasAuga)
                {
                    foreach (var toggle in EffectSelectors)
                    {
                        toggle.gameObject.SetActive(false);
                    }
                }

                foreach (var req in __instance.m_recipeRequirementList)
                {
                    InventoryGui.HideRequirement(req.transform);
                }

                __instance.m_craftButton.interactable = false;
            }
        }