Ejemplo n.º 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());
        }
Ejemplo n.º 2
0
        public void SetupRequirementList(InventoryGui __instance, Player player, EnchantRecipe recipe, bool canCraft)
        {
            var requirementStates = new[] { Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent };

            var index = 0;
            var cost  = GetRecipeCost(recipe, SelectedRarity);

            foreach (var product in cost)
            {
                if (SetupRequirement(__instance, __instance.m_recipeRequirementList[index].transform, product.Key, product.Value, player, true, out var haveMaterials))
                {
                    requirementStates[index] = haveMaterials ? Auga.RequirementWireState.Have : Auga.RequirementWireState.DontHave;
                    ++index;
                }
            }

            for (; index < __instance.m_recipeRequirementList.Length; ++index)
            {
                InventoryGui.HideRequirement(__instance.m_recipeRequirementList[index].transform);
            }

            if (EpicLoot.HasAuga)
            {
                Auga.API.RequirementsPanel_SetWires(AugaTabData.RequirementsPanelGO, requirementStates, canCraft);
            }
        }
Ejemplo n.º 3
0
        public static Piece.Requirement[] GetRecipeRequirementArray(EnchantRecipe recipe, ItemRarity rarity)
        {
            var cost = GetRecipeCost(recipe, rarity);

            return(cost.Select(x => new Piece.Requirement()
            {
                m_amount = x.Value, m_resItem = x.Key
            }).ToArray());
        }
Ejemplo n.º 4
0
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         var recipe = new EnchantRecipe {
             FromItem = item.Extended()
         };
         Recipes.Add(recipe);
     }
 }
        public void AddRecipeToList(InventoryGui __instance, EnchantRecipe 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  = canCraft ? Color.white : new Color(0.66f, 0.66f, 0.66f, 1f);

            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(recipe.ToRarity);
            if (!canCraft)
            {
                bgImage.color -= new Color(0, 0, 0, 0.66f);
            }

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

            nameText.text  = Localization.instance.Localize(item.m_shared.m_name);
            nameText.color = canCraft ? EpicLoot.GetRarityColorARGB(recipe.ToRarity) : new Color(0.66f, 0.66f, 0.66f, 1f);

            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);
        }
Ejemplo n.º 6
0
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         if (Player.m_localPlayer.m_knownMaterial.Contains($"Magic Runestone"))
         {
             var recipe = new EnchantRecipe {
                 FromItem = item.Extended()
             };
             Recipes.Add(recipe);
         }
     }
 }
Ejemplo n.º 7
0
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         //foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
         {
             if (Player.m_localPlayer.m_knownMaterial.Contains($"Magic Runestone"))
             {
                 var recipe = new EnchantRecipe {
                     FromItem = item.Extended()
                 };                                                             // todo, no rarity in recipe
                 Recipes.Add(recipe);
             }
         }
     }
 }
Ejemplo n.º 8
0
        public void SetupRequirementList(InventoryGui __instance, Player player, EnchantRecipe recipe)
        {
            var index = 0;
            var cost  = GetRecipeCost(recipe, SelectedRarity);

            foreach (var product in cost)
            {
                if (SetupRequirement(__instance, __instance.m_recipeRequirementList[index].transform, product.Key, product.Value, player))
                {
                    ++index;
                }
            }

            for (; index < __instance.m_recipeRequirementList.Length; ++index)
            {
                InventoryGui.HideRequirement(__instance.m_recipeRequirementList[index].transform);
            }
        }
        private static void AddEnchantCosts(EnchantRecipe recipe)
        {
            const int runestoneCost = 1;
            const int dustCost      = 5;
            const int otherCost     = 5;

            var rarity          = recipe.ToRarity;
            var dustPrefab      = ObjectDB.instance.GetItemPrefab($"Dust{rarity}").GetComponent <ItemDrop>();
            var essencePrefab   = ObjectDB.instance.GetItemPrefab($"Essence{rarity}").GetComponent <ItemDrop>();
            var reagentPrefab   = ObjectDB.instance.GetItemPrefab($"Reagent{rarity}").GetComponent <ItemDrop>();
            var runestonePrefab = ObjectDB.instance.GetItemPrefab($"Runestone{rarity}").GetComponent <ItemDrop>();

            var item = recipe.FromItem;

            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
            case ItemDrop.ItemData.ItemType.Tool:
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(runestonePrefab, runestoneCost));
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(dustPrefab, dustCost));
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(essencePrefab, otherCost));
                break;

            case ItemDrop.ItemData.ItemType.Shield:
            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
            case ItemDrop.ItemData.ItemType.Utility:
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(runestonePrefab, runestoneCost));
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(dustPrefab, dustCost));
                recipe.Cost.Add(new KeyValuePair <ItemDrop, int>(reagentPrefab, otherCost));
                break;
            }
        }
Ejemplo n.º 10
0
 public static List <KeyValuePair <ItemDrop, int> > GetRecipeCost(EnchantRecipe recipe, ItemRarity rarity)
 {
     return(GetEnchantCosts(recipe.FromItem, rarity));
 }