コード例 #1
0
    void UpdateRarity(ref Item_OffensiveStats item)
    {
        GameDifficulty _gameDifficulty = GameManager.Singleton.gameData.GetGameDifficulty();

        float maxValue = 100;

        foreach (RaritiesPerGameDifficuty.RarityData currentRarity in item.raritiesPerDifficulty[(int)_gameDifficulty].rarities)
        {
            currentRarity.SetRarityBounds(ref maxValue);
        }

        float rarityRoll = Random.Range(0, 10001) / 100f;

        foreach (RaritiesPerGameDifficuty.RarityData currentRarity in item.raritiesPerDifficulty[(int)_gameDifficulty].rarities)
        {
            if (rarityRoll >= currentRarity.minValue && rarityRoll <= currentRarity.maxValue)
            {
                ItemRarityData rarityData = raritiesDatas[(int)currentRarity.itemRarity];

                item.rarityStr = rarityData.name;
                item.name     += " (" + item.rarityStr + ")";

                rarityData.statAlteration.GenerateFinalValue();

                item.statAlteration = rarityData.statAlteration;
                SetItemPrices(ref item, rarityData);
                break;
            }
        }
    }
コード例 #2
0
    public void SetItemPrices(ref Item_OffensiveStats item, ItemRarityData rarity)
    {
        float sellPriceGap;
        float buyPriceGap;

        sellPriceGap = rarity.maxSellPrice - rarity.minSellPrice;
        buyPriceGap  = rarity.maxBuyPrice - rarity.minBuyPrice;

        item.sellPrice = Mathf.FloorToInt(rarity.minSellPrice + (sellPriceGap * item.statAlteration.finalValue) / item.statAlteration.maxValue);
        item.buyPrice  = Mathf.CeilToInt(rarity.minBuyPrice + (buyPriceGap * item.statAlteration.finalValue) / item.statAlteration.maxValue);
    }