コード例 #1
0
 private void EquipBraceletIfPossible(Equipment item, PlayerCharacter pc)
 {
     if (!(item is Bracelet bracelet))
     {
         return;
     }
     for (int i = 0; i < pc.bracelets.Length; i++)
     {
         if (pc.bracelets[i] == null)
         {
             pc.bracelets[i] = bracelet;
             pc.ModifyStats(null, item);
             pc.GetComponent <HotbarUser>().CmdRefreshAbilityInfo();
             return;
         }
     }
     PlayerCharacter.localPlayer.inventory.items.Add(item);
     DropsArea.AddItemDrop(item);
     StartCoroutine(pc.inventory.RefreshInABit());
 }
コード例 #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());
        }
    }