예제 #1
0
        private string GenerateEnchantTooltip(EnchantRecipe recipe)
        {
            var sb            = new StringBuilder();
            var rarityColor   = EpicLoot.GetRarityColor(SelectedRarity);
            var rarityDisplay = EpicLoot.GetRarityDisplayName(SelectedRarity);

            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine($"{recipe.FromItem.m_shared.m_name} \u2794 <color={rarityColor}>{rarityDisplay}</color> {recipe.FromItem.GetDecoratedName(rarityColor)}");
            sb.AppendLine($"<color={rarityColor}>");

            var   effectCountWeights = LootRoller.GetEffectCountsPerRarity(SelectedRarity);
            float totalWeight        = effectCountWeights.Sum(x => x.Value);

            foreach (var effectCountEntry in effectCountWeights)
            {
                var count   = effectCountEntry.Key;
                var weight  = effectCountEntry.Value;
                var percent = (int)(weight / totalWeight * 100.0f);
                var label   = count == 1 ? $"{count} $mod_epicloot_enchant_effect" : $"{count} $mod_epicloot_enchant_effects";
                sb.AppendLine($"  ‣ {label} {percent}%");
            }
            sb.Append("</color>");

            return(sb.ToString());
        }
예제 #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();
            }
        }
예제 #3
0
        private string GetGambleTooltip()
        {
            _sb.Clear();

            _sb.AppendLine("$mod_epicloot_gamble_tooltip");
            _sb.AppendLine();
            _sb.AppendLine("$mod_epicloot_gamble_tooltip_chance");

            var rarityChance = AdventureDataManager.Config.Gamble.GambleRarityChance;

            if (ItemInfo.GuaranteedRarity)
            {
                rarityChance = AdventureDataManager.Config.Gamble.GambleRarityChanceByRarity[(int)ItemInfo.Rarity];
            }

            var labels = new[]
            {
                "$mod_epicloot_gamble_tooltip_nonmagic",
                EpicLoot.GetRarityDisplayName(ItemRarity.Magic),
                EpicLoot.GetRarityDisplayName(ItemRarity.Rare),
                EpicLoot.GetRarityDisplayName(ItemRarity.Epic),
                EpicLoot.GetRarityDisplayName(ItemRarity.Legendary)
            };

            var totalWeight = (float)AdventureDataManager.Config.Gamble.GambleRarityChance.Sum();

            for (var i = 0; i < 5; ++i)
            {
                var color   = i == 0 ? "white" : EpicLoot.GetRarityColor((ItemRarity)(i - 1));
                var percent = rarityChance[i] / totalWeight * 100;
                if (percent >= 0.01)
                {
                    _sb.AppendLine($"<color={color}>{labels[i]}: {percent:0.#}%</color>");
                }
            }

            return(Localization.instance.Localize(_sb.ToString()));
        }
예제 #4
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);
                }
            }
        }