コード例 #1
0
    public static Equipment GenerateEquipment(int level, int quality)
    {
        int[] stat1            = { 0, 2, 3, 5, 7, 9, 12, 15 };
        int[] stat2            = { 0, 0, 2, 3, 4, 5, 6, 7 };
        int[] stat3            = { 0, 0, 0, 0, 2, 2, 3, 4 };
        var   statPreAdjusted1 = (float)stat1[quality];
        var   statPreAdjusted2 = (float)stat2[quality];
        var   statPreAdjusted3 = (float)stat3[quality];

        for (int i = 1; i < level; i++)
        {
            statPreAdjusted1 *= 1.1f;
            statPreAdjusted2 *= 1.1f;
            statPreAdjusted3 *= 1.1f;
        }
        var       statAdjusted1 = (int)statPreAdjusted1;
        var       statAdjusted2 = (int)statPreAdjusted2;
        var       statAdjusted3 = (int)statPreAdjusted3;
        int       armor         = 100 + (21 * level);
        Equipment item          = null;
        int       roll          = Random.Range(0, 12);

        if (roll == 1)
        {
            item = GenerateArmorForShop(level, armor);
        }
        else if (roll == 2 && quality > 0)
        {
            item = GenerateNecklace();
        }
        else if (roll == 3 && quality > 0)
        {
            item = GenerateBelt();
        }
        else if (roll == 4 && quality > 0)
        {
            item = GenerateCloak();
        }
        else if (roll == 5 && quality > 0)
        {
            item = GenerateEarring();
        }
        else if (roll == 6)
        {
            item = GenerateHat(armor);
        }
        else if (roll == 7)
        {
            item = GenerateShoes(armor);
        }
        else if (roll > 7 && quality > 0)
        {
            item = GenerateBracelet();
        }
        else   // if (roll == 0)
        {
            int roll2 = Random.Range(0, 3);
            switch (roll2)
            {
            case 0:
                item = GenerateWand(level);
                break;

            case 1:
            default:
                item = GenerateSword(level);
                break;

            case 2:
                item = GenerateBow(level);
                break;
            }
        }
        if (statAdjusted1 > 0)
        {
            BuffRandomStatForShop(item, statAdjusted1);
        }
        if (statAdjusted2 > 0)
        {
            BuffRandomStatForShop(item, statAdjusted2);
        }
        if (statAdjusted3 > 0)
        {
            BuffRandomStatForShop(item, statAdjusted3);
        }
        if (quality >= 2)
        {
            BuffRandomSecondaryStatForShop(item, statAdjusted1);
        }
        if (quality >= 3)
        {
            BuffRandomSecondaryStatForShop(item, statAdjusted2);
        }

        item.description += GetDescriptionText(item);
        item.level        = level;
        item.quality      = quality;
        EquipmentNamer.NameEquipment(item);
        return(item);
    }
コード例 #2
0
    public void DropEquipment(Character attacker, int quality)
    {
        int[] stat1            = { 0, 2, 3, 5, 7, 9, 12, 15 };
        int[] stat2            = { 0, 0, 2, 3, 4, 5, 6, 7 };
        int[] stat3            = { 0, 0, 0, 0, 2, 2, 3, 4 };
        var   statPreAdjusted1 = (float)stat1[quality];
        var   statPreAdjusted2 = (float)stat2[quality];
        var   statPreAdjusted3 = (float)stat3[quality];

        intendedLevel = 1;
        if (GetComponent <MonsterScaler>() != null && GetComponent <MonsterScaler>().level > 1)
        {
            intendedLevel = GetComponent <MonsterScaler>().level;
        }
        else if (GetComponent <Chest>() != null && attacker.GetComponent <ExperienceGainer>().level > 1)
        {
            intendedLevel = attacker.GetComponent <ExperienceGainer>().level;
        }
        for (int i = 1; i < intendedLevel; i++)
        {
            statPreAdjusted1 *= 1.1f;
            statPreAdjusted2 *= 1.1f;
            statPreAdjusted3 *= 1.1f;
        }
        var       statAdjusted1 = (int)statPreAdjusted1;
        var       statAdjusted2 = (int)statPreAdjusted2;
        var       statAdjusted3 = (int)statPreAdjusted3;
        int       armor         = 100 + (21 * intendedLevel);
        Equipment item          = null;

        if (SceneInitializer.instance != null && SceneInitializer.instance.inside && LevelGen.dungeonData != null)
        {
            item = DropItemForLootAffinities(attacker, armor, quality);
        }
        else
        {
            item = DropItemDefault(attacker, armor, quality);
        }
        if (statAdjusted1 > 0)
        {
            BuffRandomStat(item, statAdjusted1);
        }
        if (statAdjusted2 > 0)
        {
            BuffRandomStat(item, statAdjusted2);
        }
        if (statAdjusted3 > 0)
        {
            BuffRandomStat(item, statAdjusted3);
        }
        if (quality >= 2)
        {
            BuffRandomSecondaryStat(item, statAdjusted1);
        }
        if (quality >= 3)
        {
            BuffRandomSecondaryStat(item, statAdjusted2);
        }
        if (item == null)
        {
            return;
        }

        item.description += GetDescriptionText(item);
        item.level        = intendedLevel;
        item.quality      = quality;
        EquipmentNamer.NameEquipment(item);
        var pc = attacker.GetComponent <PlayerCharacter>();

        if (item is Armor && pc.armor == null)
        {
            pc.armor = (Armor)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Hat && pc.hat == null)
        {
            pc.hat = (Hat)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Shoes && pc.shoes == null)
        {
            pc.shoes = (Shoes)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Belt && pc.belt == null)
        {
            pc.belt = (Belt)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Cloak && pc.cloak == null)
        {
            pc.cloak = (Cloak)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Earring && pc.earring == null)
        {
            pc.earring = (Earring)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Necklace && pc.necklace == null)
        {
            pc.necklace = (Necklace)item;
            pc.ModifyStats(null, item);
            pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
        }
        else if (item is Bracelet)
        {
            EquipBraceletIfPossible(item, pc);
        }
        else
        {
            pc.inventory.items.Add(item);
            DropsArea.AddItemDrop(item);
            StartCoroutine(pc.inventory.RefreshInABit());
        }
    }