private string GetNegativeArmorAndAttackPowerComparisons(Equipment equipment)
    {
        var output       = "";
        var oldEquipment = GetEquippedGear(equipment);
        int numberChange = 0;

        if (equipment.armor != 0 || (oldEquipment != null && oldEquipment.armor != 0))
        {
            if (equipment.armor > 0 && oldEquipment == null)
            {
                numberChange = equipment.armor;
            }
            else if (oldEquipment != null && oldEquipment.armor > 0)
            {
                numberChange = equipment.armor - oldEquipment.armor;
            }
            if (numberChange < 0)
            {
                output += numberChange.ToString() + " Armor\n";
            }
        }
        if (!(equipment is Weapon))
        {
            return(output);
        }
        var weapon    = equipment as Weapon;
        var oldWeapon = oldEquipment as Weapon;

        numberChange = EquipmentNamer.GetAttackPowerNumberFromItem(weapon) - EquipmentNamer.GetAttackPowerNumberFromItem(oldWeapon);
        if (numberChange < 0)
        {
            output += numberChange.ToString() + " Attack\n";
        }
        return(output);
    }
示例#2
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);
    }
示例#3
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());
        }
    }
    //public void Initialize(string name, string description, string type, Inventory inventory, int number, int quality, string icon, Item item) {
    public void Initialize(Item item, Inventory inventory)
    {
        if (images.Count == 0)
        {
            images.Clear();
            var imagesTemp = Resources.LoadAll <Sprite>("Icons");
            foreach (var image in imagesTemp)
            {
                images[image.name] = image;
            }
        }
        cost = Shop.Appraise(item);
        if (costArea != null)
        {
            costText.text = cost.ToString();
            costArea.SetActive(false);
        }
        this.item   = item;
        name        = item.name;
        description = item.description;
        if (item is Weapon)
        {
            attackPower = ((Weapon)item).attackPower;
        }
        type                 = GetItemType(item);
        subtype              = GetItemSubtype(item);
        this.inventory       = inventory;
        details              = inventory.inventoryDetails;
        foldoutBackground    = inventory.inventoryDetailsBackground;
        descriptionText      = inventory.inventoryDetailsDescriptionText;
        statTextContainer    = inventory.inventoryDetailsStatTextContainer;
        statResultsContainer = inventory.inventoryDetailsStatResultsContainer;
        number               = inventory.items.IndexOf(item);
        if (GetComponent <ShopItemController>() != null)
        {
            number = GetComponent <ShopItemController>().shop.goods.IndexOf(item);
        }
        if (item is Equipment)
        {
            quality = ((Equipment)item).quality;
        }
        image.sprite = images[item.icon];
        var canvas = GetComponentInParent <Canvas>();
        //hoverOffset = new Vector3(GetComponent<RectTransform>().sizeDelta.x * canvas.GetComponent<CanvasScaler>().referencePixelsPerUnit, 0, 0);
        var rect = RectTransformUtility.PixelAdjustRect(GetComponent <RectTransform>(), canvas);

        hoverOffset = new Vector3(rect.width * 1.485f * Screen.width / 1600, 0, 0);
        var tooltip = GetComponent <DuloGames.UI.UITooltipShow>();

        tooltip.contentLines = new DuloGames.UI.UITooltipLineContent[] {
            new DuloGames.UI.UITooltipLineContent(),
            new DuloGames.UI.UITooltipLineContent(),
            new DuloGames.UI.UITooltipLineContent(),
            new DuloGames.UI.UITooltipLineContent(),
            new DuloGames.UI.UITooltipLineContent(),
            new DuloGames.UI.UITooltipLineContent()
            // name
            // type
            // stats
            // positive comparison stats
            // negative comparison stats
            // flavor text
        };
        tooltip.contentLines[0].LineStyle = DuloGames.UI.UITooltipLines.LineStyle.Title;
        tooltip.contentLines[0].Content   = name;
        tooltip.contentLines[1].LineStyle = DuloGames.UI.UITooltipLines.LineStyle.Description;
        if (item is Equipment)
        {
            Equipment equipment = item as Equipment;
            tooltip.contentLines[1].Content = "L" + equipment.level + " " + qualityDisplayTypes[equipment.quality] + displayTypes[type];
        }
        else
        {
            tooltip.contentLines[1].Content = displayTypes[type];
        }
        tooltip.contentLines[2].LineStyle       = DuloGames.UI.UITooltipLines.LineStyle.Custom;
        tooltip.contentLines[2].CustomLineStyle = "ItemAttribute";
        tooltip.contentLines[2].Content         = description.Replace("{{AttackPower}}", EquipmentNamer.GetAttackPowerNumberFromItem(item).ToString() + " Attack");
        tooltip.contentLines[3].LineStyle       = DuloGames.UI.UITooltipLines.LineStyle.Custom;
        tooltip.contentLines[3].CustomLineStyle = "ItemStat";
        tooltip.contentLines[3].Content         = GetPositiveComparisonStats();
        tooltip.contentLines[4].LineStyle       = DuloGames.UI.UITooltipLines.LineStyle.Custom;
        tooltip.contentLines[4].CustomLineStyle = "ItemNegativeStat";
        tooltip.contentLines[4].Content         = GetNegativeComparisonStats();
        tooltip.contentLines[5].LineStyle       = DuloGames.UI.UITooltipLines.LineStyle.Custom;
        tooltip.contentLines[5].CustomLineStyle = "ItemDescription";
        tooltip.contentLines[5].Content         = item.flavorText;
    }