示例#1
0
    private void AddPickups()
    {
        if (pickups.Count == 0)
        {
            return;
        }
        float totalLootValue = lootValue * levelIndexMultiplier;
        int   iterations     = 9999;

        while (totalLootValue > 0 && iterations > 0)
        {
            iterations--;
            pickups = RandomUtil.ShuffleHostList(pickups.Cast <IGeneratedHostInhabitant>().ToList()).Cast <IPickup>().ToList();
            IPickup pickup = pickups.Find(p => p.GetLootValue() <= totalLootValue);
            if (pickup == null)
            {
                break;
            }
            if (!GetSpawnDirectory(out Directory directory, pickup as IGeneratedHostInhabitant))
            {
                continue;
            }
            PickupHandler.I.CreatePickup(directory.transform, pickup);
            totalLootValue -= pickup.GetLootValue();
        }
    }
示例#2
0
    public void CreatePickups(ILootDropper lootDropper)
    {
        List <IPickup> possiblePickups       = lootDropper.GetPickups();
        float          currentLootValueTotal = lootDropper.GetChallengeRating() * HostHandler.I.currentHost.lootValueMultiplier;
        bool           canAfford             = true;

        while (canAfford)
        {
            canAfford = false;
            if (possiblePickups.Count == 0)
            {
                continue;
            }
            IPickup pickup = possiblePickups[UnityEngine.Random.Range(0, possiblePickups.Count)];
            if (pickup.GetLootValue() > currentLootValueTotal)
            {
                continue;
            }
            canAfford              = true;
            currentLootValueTotal -= pickup.GetLootValue();
            possiblePickups.Remove(pickup);
            CreatePickup(lootDropper.GetTransform().parent, pickup);
        }
    }