public bool BuyUpgrade(string treeId, Hero hero, TownUpgrade upgrade, float discount, bool isFree) { if (!isFree && !CanPayPrice(upgrade.Cost, discount)) { return(false); } if (!HeroPurchases.ContainsKey(hero.RosterId)) { HeroPurchases.Add(hero.RosterId, new Dictionary <string, UpgradePurchases>()); } if (!HeroPurchases[hero.RosterId].ContainsKey(treeId)) { HeroPurchases[hero.RosterId].Add(treeId, new UpgradePurchases(treeId, upgrade.Code)); } else { if (HeroPurchases[hero.RosterId][treeId].PurchasedUpgrades.Contains(upgrade.Code)) { return(false); } HeroPurchases[hero.RosterId][treeId].PurchasedUpgrades.Add(upgrade.Code); } if (!isFree) { RemoveCurrency(upgrade.Cost, discount); } DarkestSoundManager.PlayOneShot("event:/ui/town/buy"); return(true); }
public bool BuyUpgrade(CampingSkill skill, Hero hero, float discount) { if (!CanPayPrice(skill.CurrencyCost, discount)) { return(false); } if (!HeroPurchases.ContainsKey(hero.RosterId)) { return(false); } if (!HeroPurchases[hero.RosterId].ContainsKey(skill.Id)) { return(false); } if (HeroPurchases[hero.RosterId][skill.Id].PurchasedUpgrades.Contains("0")) { return(false); } HeroPurchases[hero.RosterId][skill.Id].PurchasedUpgrades.Add("0"); RemoveCurrency(skill.CurrencyCost, discount); DarkestSoundManager.PlayOneShot("event:/ui/town/buy"); return(true); }
public int GetUpgradedWeaponLevel(int rosterId, string classId) { if (HeroPurchases.ContainsKey(rosterId)) { return(HeroPurchases[rosterId][classId + ".weapon"].PurchasedUpgrades.Count + 1); } return(1); }
public bool GetUpgradedCampingStatus(int rosterId, string skillId) { if (HeroPurchases.ContainsKey(rosterId)) { return(HeroPurchases[rosterId][skillId].PurchasedUpgrades.Contains("0")); } return(false); }
public int GetUpgradedSkillLevel(int rosterId, string classId, string skillId) { if (HeroPurchases.ContainsKey(rosterId)) { return(HeroPurchases[rosterId][classId + "." + skillId].PurchasedUpgrades.Count - 1); } return(-1); }
public int PickRosterId() { int rosterId = rosterIds[Random.Range(0, rosterIds.Count)]; rosterIds.Remove(rosterId); HeroPurchases.Add(rosterId, new Dictionary <string, UpgradePurchases>()); return(rosterId); }
public void ReturnRosterId(int id) { if (!RosterIds.Contains(id)) { RosterIds.Add(id); } if (HeroPurchases.ContainsKey(id)) { HeroPurchases.Remove(id); } }