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 }
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 }