Exemple #1
0
    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);
    }
Exemple #2
0
    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);
    }
Exemple #3
0
 public int GetUpgradedWeaponLevel(int rosterId, string classId)
 {
     if (HeroPurchases.ContainsKey(rosterId))
     {
         return(HeroPurchases[rosterId][classId + ".weapon"].PurchasedUpgrades.Count + 1);
     }
     return(1);
 }
Exemple #4
0
 public bool GetUpgradedCampingStatus(int rosterId, string skillId)
 {
     if (HeroPurchases.ContainsKey(rosterId))
     {
         return(HeroPurchases[rosterId][skillId].PurchasedUpgrades.Contains("0"));
     }
     return(false);
 }
Exemple #5
0
 public int GetUpgradedSkillLevel(int rosterId, string classId, string skillId)
 {
     if (HeroPurchases.ContainsKey(rosterId))
     {
         return(HeroPurchases[rosterId][classId + "." + skillId].PurchasedUpgrades.Count - 1);
     }
     return(-1);
 }
Exemple #6
0
    public int PickRosterId()
    {
        int rosterId = rosterIds[Random.Range(0, rosterIds.Count)];

        rosterIds.Remove(rosterId);
        HeroPurchases.Add(rosterId, new Dictionary <string, UpgradePurchases>());
        return(rosterId);
    }
Exemple #7
0
    public void ReturnRosterId(int id)
    {
        if (!RosterIds.Contains(id))
        {
            RosterIds.Add(id);
        }

        if (HeroPurchases.ContainsKey(id))
        {
            HeroPurchases.Remove(id);
        }
    }