Ejemplo n.º 1
0
    public void SetLoot(LootConfig _loot)
    {
        if (_loot == null)
        {
            Destroy(this);
            return;
        }

        loot  = _loot;
        crate = Instantiate(_loot.WorldObject);

        Tile t = gameObject.GetComponent <Tile>();

        crate.transform.position = t.GetPosition();
        crate.transform.SetParent(t.transform, true);
        LootContentConfig content = M_Weightable.GetWeighted(loot.Drops);


        int amount = (int)content.BaseAmount.Value();

        if (content.Item.Type == ItemTypes.dust)
        {
            amount = Constants.GetDustForProgress(amount, WorldExtender.Instance.GetGetDifficulty());
        }

        item_lootable = new ItemInInventory(content.Item, amount);
    }
Ejemplo n.º 2
0
    void LoadLootWeapon(XmlReader reader, WeaponConfig weaponConf)
    {
        LootConfig lootConf = new LootConfig();

        if (reader.HasAttributes)
        {
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "giveAtWave")
                {
                    lootConf.giveAtWave = int.Parse(reader.Value);
                }
                else if (reader.Name == "fromWave")
                {
                    lootConf.fromWave = int.Parse(reader.Value);
                }
                else if (reader.Name == "toWave")
                {
                    lootConf.toWave = int.Parse(reader.Value);
                }
                else if (reader.Name == "lootRate")
                {
                    lootConf.rate = float.Parse(reader.Value);
                }
                else if (reader.Name == "increaseRate")
                {
                    lootConf.increaseRate = float.Parse(reader.Value);
                }
            }
        }
        weaponConf.lootConf = lootConf;
    }
Ejemplo n.º 3
0
 public Loot(LootConfig config)
 {
     name        = config.LootName;
     description = config.LootDescription;
     creditValue = config.CreditValue;
     lootType    = config.LootType;
     icon        = config.Icon;
     itemDictKey = config.ItemDictKey;
 }
Ejemplo n.º 4
0
    public static void AddLoot(Tile target, EnemyDropCategory Category)
    {
        LootConfig conf = LootBalance.GetBalance().GetLootConfig(Category);

        if (conf != null && target.GetComponent <Tile_Loot>() == null)
        {
            target.gameObject.AddComponent <Tile_Loot>().SetLoot(conf);
        }
    }
Ejemplo n.º 5
0
    public LootConfig GetLootConfig(LootCategory cat)
    {
        List <LootConfig> configs = LootConfigs.Where(lc => lc.Category == cat).ToList();

        /*      List<WeightedRegion> configs = Regions.Where( r =>  ..... ) ).ToList();
         *
         *      WeightedRegion wr = WeightableFactory.GetWeighted(configs);*/
        LootConfig conf = M_Math.GetRandomObject(configs);

        return(conf);
    }
Ejemplo n.º 6
0
 public void DisplayLoot(LootConfig config)
 {
     lootImage.sprite = config.Icon;
     if (config.LootName == "Credits")
     {
         lootName.text = $"{config.LootName} : {((Credits)config).GetCreditValue()}";
     }
     else
     {
         lootName.text = config.LootName;
     }
 }
Ejemplo n.º 7
0
    public WeaponConfig GetUnLockWeapon(int wave)
    {
        foreach (WeaponConfig wConf in weaponConfTable)
        {
            LootConfig lConf = wConf.lootConf;
            if (wave == lConf.giveAtWave)
            {
                return(wConf);
            }
        }

        return(null);
    }
Ejemplo n.º 8
0
    public LootConfig RollForLoot()
    {
        LootConfig droppedLoot = null;

        float roll = Random.Range(0f, 1f);

        if (roll >= 1f - dropRate)
        {
            droppedLoot = SelectLoot();
        }

        return(droppedLoot);
    }
Ejemplo n.º 9
0
    private void SetLoot(bool success)
    {
        if (success)
        {
            ContractConfig contract = session.ActiveContract;
            contract.Flags |= ContractFlags.isCompleted;

            // Get LootFactory list from active contract
            List <LootFactory> lootFactories = contract.LootDrops;

            // Special (guaranteed) loot drops
            List <LootConfig> receivedRewards = new List <LootConfig>();
            foreach (LootConfig loot in contract.SpecialLootDrops)
            {
                receivedRewards.Add(loot);
            }

            // Loot rolls
            foreach (LootFactory factory in lootFactories)
            {
                // TODO: Determine min and max rarity
                LootConfig droppedLoot = factory.DropLoot(LootRarity.Common, LootRarity.Rare);
                if (droppedLoot)
                {
                    receivedRewards.Add(droppedLoot);
                }
            }


            // TODO SortLoot(receivedRewards);

            for (int i = 0; i < receivedRewards.Count; i++)
            {
                RunResultsLootRow newLoot = Instantiate(lootRowPrefab, lootGrid);
                newLoot.DisplayLoot(receivedRewards[i]);

                if (receivedRewards[i].LootType == LootType.Currency)
                {
                    player.AddToCredits(receivedRewards[i].CreditValue);
                }
                else
                {
                    player.AddToInventory(receivedRewards[i].Create());
                }
            }
        }
        else
        {
            // TODO Penalty? Give reduced credit reward?
        }
    }
Ejemplo n.º 10
0
    public List <WeaponConfig> GetPossibleLootWeapons(int wave)
    {
        List <WeaponConfig> wConfList = new List <WeaponConfig>();

        foreach (WeaponConfig wConf in weaponConfTable)
        {
            LootConfig lConf = wConf.lootConf;
            if (wave >= lConf.fromWave && wave <= lConf.toWave)
            {
                wConfList.Add(wConf);
            }
        }

        return(wConfList);
    }
Ejemplo n.º 11
0
    public override LootConfig DropLoot(LootRarity minRarity, LootRarity maxRarity)
    {
        LootConfig droppedLoot = null;
        LootRarity poolRarity  = maxRarity;     // Prioritize higher rarity drops

        while (poolRarity >= minRarity && poolRarity >= 0)
        {
            droppedLoot = lootPools[(int)poolRarity]?.RollForLoot();
            if (droppedLoot)
            {
                return(droppedLoot);     // return as soon as a loot has been selected
            }

            poolRarity--;
        }

        return(droppedLoot);             // If no loot drops, returns null
    }
Ejemplo n.º 12
0
    public void LoadInventory(InventoryData data)
    {
        if (data == null)
        {
            return;
        }

        credits = data.credits;

        for (int i = 0; i < data.playerInventory.Count; i++)
        {
            LootConfig config = ItemDict.GetItem(data.playerInventory[i]);
            Loot       loot   = config.Create();

            playerInventory.Add(loot);
            if (loot.GetLootType() == LootType.Equipment)
            {
                Equipment equipment = (Equipment)loot;
                equipment.SetStatModValueFromSave(data.playerInventoryStats[i]);
            }
        }
    }
Ejemplo n.º 13
0
 public void Initialize(LootConfig config)
 {
     this.config = config;
 }