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); }
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; }
public Loot(LootConfig config) { name = config.LootName; description = config.LootDescription; creditValue = config.CreditValue; lootType = config.LootType; icon = config.Icon; itemDictKey = config.ItemDictKey; }
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); } }
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); }
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; } }
public WeaponConfig GetUnLockWeapon(int wave) { foreach (WeaponConfig wConf in weaponConfTable) { LootConfig lConf = wConf.lootConf; if (wave == lConf.giveAtWave) { return(wConf); } } return(null); }
public LootConfig RollForLoot() { LootConfig droppedLoot = null; float roll = Random.Range(0f, 1f); if (roll >= 1f - dropRate) { droppedLoot = SelectLoot(); } return(droppedLoot); }
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? } }
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); }
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 }
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]); } } }
public void Initialize(LootConfig config) { this.config = config; }