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); }
private void InitializeCampingSkills(int bonusSkills = 0) { CurrentCampingSkills = new CampingSkill[HeroClass.CampingSkills.Count]; var availableGeneralSkills = HeroClass.CampingSkills.FindAll(skill => skill.Classes.Count > 4); int generalSkillsRequired = HeroClass.Generation.NumberOfSharedCampingSkills; foreach (var skill in availableGeneralSkills.OrderBy(x => RandomSolver.NextDouble()) .Take(Mathf.Min(generalSkillsRequired, availableGeneralSkills.Count))) { int skillIndex = HeroClass.CampingSkills.IndexOf(skill); CurrentCampingSkills[skillIndex] = skill; } var availableSpecificSkills = HeroClass.CampingSkills.FindAll(skill => skill.Classes.Count <= 4); int specificSkillsRequired = HeroClass.Generation.NumberOfSpecificCampingSkills + bonusSkills; foreach (var skill in availableSpecificSkills.OrderBy(x => RandomSolver.NextDouble()) .Take(Mathf.Min(specificSkillsRequired, availableSpecificSkills.Count))) { int skillIndex = HeroClass.CampingSkills.IndexOf(skill); CurrentCampingSkills[skillIndex] = skill; } var availableGeneratedSkills = new List <CampingSkill>(CurrentCampingSkills); availableGeneratedSkills.RemoveAll(skill => skill == null); SelectedCampingSkills = availableGeneratedSkills.OrderBy(x => RandomSolver.NextDouble()) .Take(Mathf.Min(4, availableGeneratedSkills.Count)).ToList(); }
public Hero(int heroIndex, PhotonPlayer player) : base(DarkestDungeonManager.Data.HeroClasses[(string)player.CustomProperties["HC" + heroIndex]]) { RandomSolver.SetRandomSeed((int)player.CustomProperties["HS" + heroIndex]); InitializeHeroInfo(0, (string)player.CustomProperties["HN" + heroIndex], (string)player.CustomProperties["HC" + heroIndex], 0, 30); InitializeEquipment(1, 1); InitializeQuirks(); CurrentCombatSkills = new CombatSkill[HeroClass.CombatSkills.Count]; for (int i = 0; i < CurrentCombatSkills.Length; i++) { CurrentCombatSkills[i] = HeroClass.CombatSkills[i]; } var playerSkillFlags = (PlayerSkillFlags)player.CustomProperties["HF" + heroIndex]; SelectedCombatSkills = new List <CombatSkill>(); for (int i = 0; i < CurrentCombatSkills.Length; i++) { if ((playerSkillFlags & (PlayerSkillFlags)Mathf.Pow(2, i + 1)) != PlayerSkillFlags.Empty) { SelectedCombatSkills.Add(CurrentCombatSkills[i]); } } CurrentCampingSkills = new CampingSkill[HeroClass.CampingSkills.Count]; SelectedCampingSkills = new List <CampingSkill>(); }
public Hero(string classId, string generatedName) : base(DarkestDungeonManager.Data.HeroClasses[classId]) { InitializeHeroInfo(0, generatedName, classId, 0, 30); InitializeEquipment(1, 1); InitializeQuirks(); InitializeCombatSkills(HeroClass.CombatSkills.Count); CurrentCampingSkills = new CampingSkill[HeroClass.CampingSkills.Count]; SelectedCampingSkills = new List <CampingSkill>(); }
public void UpdateSkill(Hero hero, CampingSkill campingSkill) { Skill = campingSkill; if (hero.SelectedCampingSkills.Contains(campingSkill)) { skillIcon.sprite = DarkestDungeonManager.Data.Sprites["camp_skill_" + Skill.Id]; SetDisabledState(); } else { ResetSkill(); } }
public static bool IsCampingSkillUsable(FormationUnit performer, CampingSkill skill) { int skillUsageCount = 0; for (int i = 0; i < performer.CombatInfo.SkillsUsedThisTurn.Count; i++) { if (performer.CombatInfo.SkillsUsedThisTurn[i] == skill.Id) { skillUsageCount++; } } if (skillUsageCount >= skill.Limit) { return(false); } if (skill.TimeCost > RaidSceneManager.Raid.CampingTimeLeft) { return(false); } for (int i = 0; i < skill.Effects.Count; i++) { switch (skill.Effects[i].Selection) { case CampTargetType.Self: return(true); case CampTargetType.Individual: case CampTargetType.PartyOther: if (RaidSceneManager.HeroParty.Units.Count > 1) { return(true); } break; default: break; } } return(false); }
public Hero(Estate estate, SaveHeroData saveHeroData) : base(saveHeroData) { InitializeHeroInfo(saveHeroData.RosterId, saveHeroData.Name, saveHeroData.HeroClass, saveHeroData.ResolveLevel, saveHeroData.StressLevel); Status = saveHeroData.Status; InActivity = saveHeroData.InActivity; MissingDuration = saveHeroData.MissingDuration; Resolve.CurrentXP = saveHeroData.ResolveXP; if (!estate.PickRosterId(RosterId)) { Debug.LogError("Missing id " + RosterId + " in estate from hero " + HeroName); } InitializeEquipment(estate.GetUpgradedWeaponLevel(RosterId, HeroClass.StringId), estate.GetUpgradedArmorLevel(RosterId, HeroClass.StringId)); if (saveHeroData.LeftTrinketId != "") { Trinket trinket = (Trinket)DarkestDungeonManager.Data.Items["trinket"][saveHeroData.LeftTrinketId]; Equip(trinket, TrinketSlot.Left); } if (saveHeroData.RightTrinketId != "") { Trinket trinket = (Trinket)DarkestDungeonManager.Data.Items["trinket"][saveHeroData.RightTrinketId]; Equip(trinket, TrinketSlot.Right); } foreach (var quirkEntry in saveHeroData.Quirks) { quirkData.Add(quirkEntry); ApplyQuirk(quirkEntry.Quirk); } CurrentCombatSkills = new CombatSkill[7]; SelectedCombatSkills = new List <CombatSkill>(); for (int i = 0; i < 7; i++) { CurrentCombatSkills[i] = HeroClass.CombatSkillVariants.Find(skill => skill.Id == HeroClass.CombatSkills[i].Id && skill.Level == estate.GetUpgradedSkillLevel(RosterId, HeroClass.StringId, HeroClass.CombatSkills[i].Id)); } foreach (int skillIndex in saveHeroData.SelectedCombatSkillIndexes) { if (CurrentCombatSkills[skillIndex] != null) { SelectedCombatSkills.Add(CurrentCombatSkills[skillIndex]); } } CurrentCampingSkills = new CampingSkill[HeroClass.CampingSkills.Count]; SelectedCampingSkills = new List <CampingSkill>(); for (int i = 0; i < CurrentCampingSkills.Length; i++) { if (estate.GetUpgradedCampingStatus(RosterId, HeroClass.CampingSkills[i].Id)) { CurrentCampingSkills[i] = HeroClass.CampingSkills[i]; } } foreach (int skillIndex in saveHeroData.SelectedCampingSkillIndexes) { if (CurrentCampingSkills[skillIndex] != null) { SelectedCampingSkills.Add(CurrentCampingSkills[skillIndex]); } } if (saveHeroData.Trait != "") { var heroTrait = DarkestDungeonManager.Data.Traits.Find(trait => trait.Id == saveHeroData.Trait); if (heroTrait != null) { ApplyTrait(heroTrait); } } GetPairedAttribute(AttributeType.HitPoints).CurrentValue = saveHeroData.CurrentHp; }