Пример #1
0
    private void AddEquipmentDrops(BattleEndWindow battleEndWindow)
    {
        //Get Equipment
        int   additionalDrops   = (int)(survivalLoopCount / 5);
        float rarityBoost       = 1 + (0.25f * survivalLoopCount);
        float nonStageEpicBoost = 1 + (0.4f * survivalLoopCount);
        float stageEpicBoost    = 1 + (0.25f * survivalLoopCount * 5);
        float affixLevelSkew    = 1.2f + (survivalLoopCount * 0.1f);
        int   equipmentDrops    = Random.Range(stageInfo.equipmentDropCountMin + additionalDrops, stageInfo.equipmentDropCountMax + 1 + additionalDrops);

        WeightList <RarityType> nonStageDropRarity = new WeightList <RarityType>();

        nonStageDropRarity.Add(RarityType.UNCOMMON, (int)(BASE_UNCOMMON_DROP_WEIGHT / rarityBoost));
        nonStageDropRarity.Add(RarityType.RARE, (int)(BASE_RARE_DROP_WEIGHT * rarityBoost));
        nonStageDropRarity.Add(RarityType.EPIC, (int)(BASE_EPIC_DROP_WEIGHT * nonStageEpicBoost));
        nonStageDropRarity.Add(RarityType.UNIQUE, (int)(BASE_UNIQUE_DROP_WEIGHT * nonStageEpicBoost));

        WeightList <RarityType> stageDropRarity = new WeightList <RarityType>();

        stageDropRarity.Add(RarityType.UNCOMMON, (int)(BASE_UNCOMMON_DROP_WEIGHT_STAGE_DROP / rarityBoost));
        stageDropRarity.Add(RarityType.RARE, (int)(BASE_RARE_DROP_WEIGHT_STAGE_DROP * rarityBoost));
        stageDropRarity.Add(RarityType.EPIC, (int)(BASE_EPIC_DROP_WEIGHT_STAGE_DROP * stageEpicBoost));

        if (stageInfo.equipmentDropList.Count == 0)
        {
            int boostedRarityDrops = System.Math.Max(equipmentDrops / 2, 1);
            for (int i = 0; i < equipmentDrops; i++)
            {
                RarityType rarity;
                if (i < boostedRarityDrops)
                {
                    rarity = stageDropRarity.ReturnWeightedRandom();
                }
                else
                {
                    rarity = nonStageDropRarity.ReturnWeightedRandom();
                }
                AddNonStagePoolDrop(affixLevelSkew, rarity);
            }
        }
        else
        {
            WeightList <string> weightList = Helpers.CreateWeightListFromWeightBases(stageInfo.equipmentDropList);
            int dropsFromStagePool         = System.Math.Max(equipmentDrops / 2, 1);
            for (int i = 0; i < dropsFromStagePool; i++)
            {
                string baseId = weightList.ReturnWeightedRandom();
                var    equip  = Equipment.CreateEquipmentFromBase(ResourceManager.Instance.GetEquipmentBase(baseId), stageLevel + survivalLoopCount);
                RollEquipmentRarity(equip, stageDropRarity.ReturnWeightedRandom(), affixLevelSkew);
                gainedEquipment.Add(equip);
            }

            for (int i = 0; i < equipmentDrops - dropsFromStagePool; i++)
            {
                RarityType rarity = nonStageDropRarity.ReturnWeightedRandom();
                AddNonStagePoolDrop(affixLevelSkew, rarity);
            }
        }
    }
Пример #2
0
 public ConsumableType GetRandomConsumable()
 {
     if (consumableWeightList == null)
     {
         consumableWeightList = new WeightList <ConsumableType>();
         consumableWeightList.Add(ConsumableType.AFFIX_REROLLER, 3000);
         consumableWeightList.Add(ConsumableType.AFFIX_CRAFTER, 900);
     }
     return(consumableWeightList.ReturnWeightedRandom());
 }
Пример #3
0
    public UniqueBase GetRandomUniqueBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null)
    {
        if (uniqueList == null)
        {
            LoadUniques();
        }

        WeightList <UniqueBase> possibleUniqueList = new WeightList <UniqueBase>();

        foreach (UniqueBase unique in uniqueList.Values)
        {
            if (group != null && unique.group != group)
            {
                continue;
            }

            if (slot != null && unique.equipSlot != slot)
            {
                continue;
            }

            if (unique.dropLevel <= ilvl)
            {
                possibleUniqueList.Add(unique, unique.spawnWeight);
            }
        }
        if (possibleUniqueList.Count == 0)
        {
            return(null);
        }
        return(possibleUniqueList.ReturnWeightedRandom());
    }
Пример #4
0
        public Tileset(TilesetLayer data)
        {
            hasTransitions = data.HasTransitions;
            flavorDensity  = data.FlavorDensity;
            groundTiles    = new WeightList <Drawable>();
            flavorObjects  = new WeightList <ISprite>();

            if (hasTransitions)
            {
                crossTransitions  = new WeightList <Drawable> [15];
                borderTransitions = new WeightList <Drawable> [15];
                for (int i = 0; i < 15; i++)
                {
                    crossTransitions[i]  = new WeightList <Drawable>();
                    borderTransitions[i] = new WeightList <Drawable>();
                }
            }

            if (data.FlavorObjects != null)
            {
                foreach (var flavor in data.FlavorObjects)
                {
                    var sprite = App.Resources.GetSprite(flavor.ResName);
                    flavorObjects.Add(sprite, flavor.Weight);
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Adds an item and its prob.
 /// </summary>
 /// <param name="item">Item code</param>
 /// <param name="prob">Item prob</param>
 public void AddItem(string item, int prob)
 {
     if (!string.IsNullOrEmpty(item) && prob > 0)
     {
         ItemProbs.Add(new KeyValuePair <string, int>(item, prob));
         TotalProb += prob;
         WeightList.Add(item, (uint)prob);
     }
 }
Пример #6
0
    public static WeightList <string> CreateWeightListFromWeightBases(List <WeightBase> weightBases)
    {
        WeightList <string> ret = new WeightList <string>();

        foreach (WeightBase weightBase in weightBases)
        {
            ret.Add(weightBase.idName, weightBase.weight);
        }
        return(ret);
    }
Пример #7
0
    public ArchetypeBase GetRandomArchetypeBase(int ilvl)
    {
        if (archetypeList == null)
        {
            LoadArchetypes();
        }

        WeightList <ArchetypeBase> possibleArchetypeList = new WeightList <ArchetypeBase>();

        foreach (ArchetypeBase archetype in archetypeList.Values)
        {
            if (archetype.dropLevel <= ilvl)
            {
                possibleArchetypeList.Add(archetype, archetype.spawnWeight);
            }
        }
        if (possibleArchetypeList.Count == 0)
        {
            return(null);
        }
        return(possibleArchetypeList.ReturnWeightedRandom());
    }
Пример #8
0
    public EquipmentBase GetRandomEquipmentBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null, float baseLevelSkew = 1f)
    {
        if (equipmentList == null)
        {
            LoadEquipment();
        }

        WeightList <EquipmentBase> possibleEquipList = new WeightList <EquipmentBase>();

        foreach (EquipmentBase equipment in equipmentList.Values)
        {
            if (group != null && equipment.group != group)
            {
                continue;
            }

            if (slot != null && equipment.equipSlot != slot)
            {
                continue;
            }

            if (equipment.dropLevel <= ilvl)
            {
                float weight = 1f;
                if (baseLevelSkew != 1f)
                {
                    weight *= Mathf.Lerp(1 / baseLevelSkew, baseLevelSkew, (float)equipment.dropLevel / ilvl);
                }

                possibleEquipList.Add(equipment, (int)(equipment.spawnWeight * weight));
            }
        }
        if (possibleEquipList.Count == 0)
        {
            return(null);
        }
        return(possibleEquipList.ReturnWeightedRandom());
    }
Пример #9
0
    public WeightList <AffixBase> GetPossibleAffixes(AffixType type, int ilvl, HashSet <GroupType> targetTypeTags, List <string> affixBonusTypeStrings, Dictionary <GroupType, float> weightModifiers, float affixLevelSkewFactor)
    {
        if (targetTypeTags == null)
        {
            targetTypeTags = new HashSet <GroupType>()
            {
                GroupType.NO_GROUP
            };
        }
        if (weightModifiers == null)
        {
            weightModifiers = new Dictionary <GroupType, float>();
        }

        Dictionary <string, AffixBase> affixList;

        switch (type)
        {
        case AffixType.PREFIX:
            affixList = prefixList;
            break;

        case AffixType.SUFFIX:
            affixList = suffixList;
            break;

        case AffixType.INNATE:
            affixList = innateList;
            break;

        case AffixType.ENCHANTMENT:
            affixList = enchantmentList;
            break;

        case AffixType.MONSTERMOD:
            affixList = monsterModList;
            break;

        default:
            affixList = null;
            break;
        }

        WeightList <AffixBase> possibleAffixList = new WeightList <AffixBase>();

        foreach (AffixBase affixBase in affixList.Values)
        {
            // check if affix type has already been applied to target
            if (affixBonusTypeStrings != null && affixBonusTypeStrings.Count > 0)
            {
                if (affixBonusTypeStrings.Contains(affixBase.AffixBonusTypeString))
                {
                    continue;
                }
            }

            //check if affix is drop only
            if (affixBase.groupTypes.Contains(GroupType.DROP_ONLY) && !targetTypeTags.Contains(GroupType.DROP_ONLY))
            {
                continue;
            }

            float weightMultiplier = 1.0f;
            int   baseWeight       = 0;

            if (affixBase.spawnLevel <= ilvl)
            {
                foreach (AffixWeight affixWeight in affixBase.spawnWeight)
                {
                    if (targetTypeTags.Contains(affixWeight.type) || affixWeight.type == GroupType.NO_GROUP)
                    {
                        baseWeight = affixWeight.weight;
                        break;
                    }
                }
                if (baseWeight > 0)
                {
                    foreach (GroupType groupTag in affixBase.groupTypes)
                    {
                        if (weightModifiers.ContainsKey(groupTag))
                        {
                            weightMultiplier *= weightModifiers[groupTag];
                        }
                    }

                    if (affixLevelSkewFactor != 1f)
                    {
                        weightMultiplier *= Mathf.Lerp(1 / affixLevelSkewFactor, affixLevelSkewFactor, (float)affixBase.spawnLevel / ilvl);
                    }

                    if (weightMultiplier == 0)
                    {
                        continue;
                    }
                    possibleAffixList.Add(affixBase, (int)(baseWeight * weightMultiplier));
                }
            }
        }

        return(possibleAffixList);
    }