Esempio n. 1
0
    public override void InitializeBuilding(Dictionary <string, UpgradePurchases> purchases)
    {
        Heroes.Clear();
        EventHeroes.Clear();
        GraveIndexes.Clear();

        Reset();

        for (int i = RosterSlotUpgrades.Count - 1; i >= 0; i--)
        {
            if (purchases[RosterSlotUpgrades[i].TreeId].PurchasedUpgrades.Contains(RosterSlotUpgrades[i].UpgradeCode))
            {
                RosterSlots = RosterSlotUpgrades[i].NumberOfSlots;
                break;
            }
        }

        for (int i = RecruitSlotUpgrades.Count - 1; i >= 0; i--)
        {
            if (purchases[RecruitSlotUpgrades[i].TreeId].PurchasedUpgrades.Contains(RecruitSlotUpgrades[i].UpgradeCode))
            {
                RecruitSlots = RecruitSlotUpgrades[i].NumberOfSlots;
                break;
            }
        }

        for (int i = RecruitExperienceUpgrades.Count - 1; i >= 0; i--)
        {
            if (purchases[RecruitExperienceUpgrades[i].TreeId].PurchasedUpgrades.Contains(RecruitExperienceUpgrades[i].UpgradeCode))
            {
                CurrentRecruitMaxLevel = RecruitExperienceUpgrades[i].Level;
                break;
            }
        }
    }
Esempio n. 2
0
    public void RestockBonus(List <int> rosterIds, Estate estate, string bonusClass, int bonusAmount)
    {
        EventHeroes.Clear();
        GraveIndexes.Clear();

        #region Clear unrecruited heroes
        if (EventHeroes.Count > 0)
        {
            for (int i = 0; i < EventHeroes.Count; i++)
            {
                if (rosterIds.Contains(EventHeroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(EventHeroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(EventHeroes[i].RosterId);
            }
        }
        #endregion

        #region Create bonus recruits
        for (int i = 0; i < bonusAmount; i++)
        {
            RecruitUpgrade experienceUpgrade = null;

            if (CurrentRecruitMaxLevel > 0)
            {
                for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                {
                    if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                        RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                    {
                        experienceUpgrade = RecruitExperienceUpgrades[j];
                        break;
                    }
                }
            }
            int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
            string heroClass = DarkestDungeonManager.Data.HeroClasses[bonusClass].StringId;
            string heroName  = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
            var    newHero   = experienceUpgrade == null ?
                               new Hero(id, heroClass, heroName) :
                               new Hero(id, heroClass, heroName, experienceUpgrade);
            EventHeroes.Add(newHero);
            rosterIds.Remove(id);
            GeneratePurchaseInfo(newHero, estate);
        }
        #endregion
    }
Esempio n. 3
0
    public void RestockFromGrave(List <int> rosterIds, Estate estate, int bonusAmount)
    {
        EventHeroes.Clear();
        GraveIndexes.Clear();

        #region Clear unrecruited heroes
        if (EventHeroes.Count > 0)
        {
            for (int i = 0; i < EventHeroes.Count; i++)
            {
                if (rosterIds.Contains(EventHeroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(EventHeroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(EventHeroes[i].RosterId);
            }
        }
        #endregion

        bonusAmount = Mathf.Min(estate.Graveyard.Records.Count, bonusAmount);
        var deadRecruitsRecords = new List <DeathRecord>(estate.Graveyard.Records);
        var heroClasses         = DarkestDungeonManager.Data.HeroClasses.Values.ToList();

        #region Create dead recruits
        for (int i = 0; i < bonusAmount; i++)
        {
            int    id         = rosterIds[Random.Range(0, rosterIds.Count)];
            var    deadRecord = deadRecruitsRecords[Random.Range(0, deadRecruitsRecords.Count)];
            string heroClass  = heroClasses.Find(deadClass => deadClass.IndexId == deadRecord.HeroClassIndex).StringId;
            var    newHero    = new Hero(id, heroClass, deadRecord);
            EventHeroes.Add(newHero);
            rosterIds.Remove(id);
            GeneratePurchaseInfo(newHero, estate);
            GraveIndexes.Add(estate.Graveyard.Records.IndexOf(deadRecord));
            deadRecruitsRecords.Remove(deadRecord);
        }
        #endregion
    }
Esempio n. 4
0
    public void ClearDeadRecruits(List <int> rosterIds, Estate estate)
    {
        EventHeroes.Clear();
        GraveIndexes.Clear();

        #region Clear unrecruited heroes
        if (EventHeroes.Count > 0)
        {
            for (int i = 0; i < EventHeroes.Count; i++)
            {
                if (rosterIds.Contains(EventHeroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(EventHeroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(EventHeroes[i].RosterId);
            }
        }
        #endregion
    }
Esempio n. 5
0
    public void RestockHeroes(List <int> rosterIds, Estate estate)
    {
        var heroClasses = DarkestDungeonManager.Data.HeroClasses.Keys.ToList();

        Heroes.AddRange(EventHeroes);
        EventHeroes.Clear();
        GraveIndexes.Clear();
        #region Clear unrecruited heroes
        if (Heroes != null && Heroes.Count > 0)
        {
            for (int i = 0; i < Heroes.Count; i++)
            {
                if (rosterIds.Contains(Heroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(Heroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(Heroes[i].RosterId);
            }
        }
        #endregion
        #region Create new recruits
        Heroes = new List <Hero>();
        if (DarkestDungeonManager.RaidManager.Quest != null && DarkestDungeonManager.RaidManager.Quest.Goal.Id == "tutorial_final_room")
        {
            for (int i = 0; i < firstHeroClasses.Length; i++)
            {
                int id      = rosterIds[Random.Range(0, rosterIds.Count)];
                var newHero = new Hero(id, firstHeroClasses[i],
                                       LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString()));
                Heroes.Add(newHero);
                rosterIds.Remove(id);
                GeneratePurchaseInfo(newHero, estate);
            }
        }
        else
        {
            for (int i = 0; i < RecruitSlots; i++)
            {
                RecruitUpgrade experienceUpgrade = null;

                if (CurrentRecruitMaxLevel > 0)
                {
                    for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                    {
                        if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                            RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                        {
                            experienceUpgrade = RecruitExperienceUpgrades[j];
                            break;
                        }
                    }
                }
                int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
                string heroClass = heroClasses[Random.Range(0, DarkestDungeonManager.Data.HeroClasses.Count)];
                string heroName  = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
                var    newHero   = experienceUpgrade == null ?
                                   new Hero(id, heroClass, heroName) :
                                   new Hero(id, heroClass, heroName, experienceUpgrade);
                Heroes.Add(newHero);
                rosterIds.Remove(id);
                GeneratePurchaseInfo(newHero, estate);
            }
        }
        #endregion
        #region Add recruits for minimum of one party
        int abominations = DarkestDungeonManager.Campaign.Heroes.FindAll(hero =>
                                                                         hero.Class == "abomination").Count + Heroes.FindAll(hero => hero.Class == "abomination").Count;
        int additionalHeroes = 4 - DarkestDungeonManager.Campaign.Heroes.Count - Heroes.Count + abominations;
        if (abominations > 3)
        {
            return;
        }
        for (int i = 0; i < additionalHeroes; i++)
        {
            RecruitUpgrade experienceUpgrade = null;

            if (CurrentRecruitMaxLevel > 0)
            {
                for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                {
                    if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                        RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                    {
                        experienceUpgrade = RecruitExperienceUpgrades[j];
                        break;
                    }
                }
            }
            int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
            string heroClass = "abomination";
            while (heroClass == "abomination")
            {
                heroClass = heroClasses[Random.Range(0, DarkestDungeonManager.Data.HeroClasses.Count)];
            }

            string heroName = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
            var    newHero  = experienceUpgrade == null ?
                              new Hero(id, heroClass, heroName) :
                              new Hero(id, heroClass, heroName, experienceUpgrade);
            Heroes.Add(newHero);
            rosterIds.Remove(id);
            GeneratePurchaseInfo(newHero, estate);
        }
        #endregion
    }