/// <summary>
 /// Sets the SlotID for the inventory slot.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="id"></param>
 public void SetID(ItemEntry.ItemType type, int id, bool allowAnyType)
 {
     slotID              = new SlotID();
     slotID.type         = type;
     slotID.id           = id;
     slotID.allowAnyType = allowAnyType;
 }
Exemple #2
0
    /// <summary>
    /// Returns the kanji representation with activations, projectiles and values etc...
    /// Takes the index for the position in the kanji list.
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    public ItemEntry.ItemType GetRandomItem()
    {
        int roll = Random.Range(1, 101);

        roll -= list[0].probability;
        ItemEntry.ItemType selectedType = list[0].baseType;
        int position = 1;

        while (roll > 0)
        {
            roll        -= list[position].probability;
            selectedType = list[position].baseType;
            position++;
        }

        return(selectedType);
    }
    /// <summary>
    /// Takes an item which is a recipe and changes it into the corresponding item.
    /// </summary>
    public void CreateFromRecipe()
    {
        ItemEntry item = selectedItem.reference;

        if (item == null || !item.isRecipe)
        {
            return;
        }

        item.isRecipe = false;
        item.bought   = false;
        ItemEntry.ItemType type = item.type;

        switch (type)
        {
        case ItemEntry.ItemType.AMULET:
            item.icon = baseImages[3];
            break;

        case ItemEntry.ItemType.ARMOR:
            item.icon = baseImages[1];
            break;

        case ItemEntry.ItemType.CONSUMABLE:
            item.icon = baseImages[4];
            break;

        case ItemEntry.ItemType.HELM:
            item.icon = baseImages[2];
            break;

        case ItemEntry.ItemType.WEAPON:
            item.icon = baseImages[0];
            break;
        }
    }
    ItemEntry Generate(int rarity, bool bought)
    {
        ItemEntry item = (ItemEntry)ScriptableObject.CreateInstance("ItemEntry");

        ItemEntry.ItemType type = typeList[rarity].GetRandomItem();

        item.ResetValues();
        item.bought    = bought;
        item.isRecipe  = true;
        item.itemName  = type.ToString();
        item.type      = type;
        item.icon      = baseImages[5];
        item.rarity    = (ItemEntry.Rarity)rarity;
        item.tintColor = Random.ColorHSV(0, 1, 0.5f, 1, 0, 1, 1, 1);

        ColorByRarity(item);

        int attempts = 1;

        while (attempts > 0)
        {
            ItemModifier selectedMod = null;
            switch (type)
            {
            case ItemEntry.ItemType.AMULET:
                selectedMod     = modAmulet[rarity].GetRandomItem();
                item.moneyValue = 30;
                break;

            case ItemEntry.ItemType.ARMOR:
                selectedMod     = modArmor[rarity].GetRandomItem();
                item.moneyValue = 20;
                break;

            case ItemEntry.ItemType.CONSUMABLE:
                selectedMod     = modConsumable[rarity].GetRandomItem();
                item.moneyValue = 0;
                break;

            case ItemEntry.ItemType.HELM:
                selectedMod     = modHelm[rarity].GetRandomItem();
                item.moneyValue = 10;
                break;

            case ItemEntry.ItemType.WEAPON:
                selectedMod     = modWeapon[rarity].GetRandomItem();
                item.moneyValue = 10;
                break;
            }

            if (selectedMod == null)
            {
                Debug.Log("Lucky you!");
                attempts++;
                continue;
            }

            item.moneyValue   += selectedMod.cost;
            item.healthMod    += selectedMod.health;
            item.manaMod      += selectedMod.mana;
            item.damageMod    += selectedMod.damage;
            item.armorMod     += selectedMod.armor;
            item.healthRegMod += selectedMod.healthReg;
            item.manaRegMod   += selectedMod.manaReg;
            item.magicResMod  += selectedMod.magicRes;
            item.critMod      += selectedMod.crit;
            item.lifestealMod += selectedMod.lifesteal;

            attempts--;
        }

        Debug.Log("Generated a recipe");

        return(item);
    }