public void OnPointerDown(PointerEventData eventData) { MinionIdentity minionIdentity = skillsScreen.CurrentlySelectedMinion as MinionIdentity; MinionResume component = minionIdentity.GetComponent <MinionResume>(); MinionResume.SkillMasteryConditions[] skillMasteryConditions = component.GetSkillMasteryConditions(skillID); bool flag = component.CanMasterSkill(skillMasteryConditions); if ((UnityEngine.Object)component != (UnityEngine.Object)null && !component.HasMasteredSkill(skillID) && flag) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Click", false)); } else { KFMOD.PlayOneShot(GlobalAssets.GetSound("Negative", false)); } }
public void OnPointerClick(PointerEventData eventData) { MinionIdentity minionIdentity = skillsScreen.CurrentlySelectedMinion as MinionIdentity; if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { MinionResume component = minionIdentity.GetComponent <MinionResume>(); if (DebugHandler.InstantBuildMode && component.AvailableSkillpoints < 1) { component.ForceAddSkillPoint(); } MinionResume.SkillMasteryConditions[] skillMasteryConditions = component.GetSkillMasteryConditions(skillID); bool flag = component.CanMasterSkill(skillMasteryConditions); if ((UnityEngine.Object)component != (UnityEngine.Object)null && !component.HasMasteredSkill(skillID) && flag) { component.MasterSkill(skillID); skillsScreen.RefreshAll(); } } }
public void Refresh(string skillID) { Skill skill = Db.Get().Skills.Get(skillID); if (skill == null) { Debug.LogWarning("DbSkills is missing skillId " + skillID); } else { Name.text = skill.Name; LocText name = Name; name.text = name.text + "\n(" + Db.Get().SkillGroups.Get(skill.skillGroup).Name + ")"; this.skillID = skillID; tooltip.SetSimpleTooltip(SkillTooltip(skill)); MinionIdentity minionIdentity = skillsScreen.CurrentlySelectedMinion as MinionIdentity; StoredMinionIdentity storedMinionIdentity = skillsScreen.CurrentlySelectedMinion as StoredMinionIdentity; MinionResume minionResume = null; if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { minionResume = minionIdentity.GetComponent <MinionResume>(); MinionResume.SkillMasteryConditions[] skillMasteryConditions = minionResume.GetSkillMasteryConditions(skillID); bool flag = minionResume.CanMasterSkill(skillMasteryConditions); if (!((UnityEngine.Object)minionResume == (UnityEngine.Object)null) && (minionResume.HasMasteredSkill(skillID) || flag)) { TitleBarBG.color = ((!minionResume.HasMasteredSkill(skillID)) ? header_color_can_assign : header_color_has_skill); hatImage.material = defaultMaterial; } else { TitleBarBG.color = header_color_disabled; hatImage.material = desaturatedMaterial; } } else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null) { if (storedMinionIdentity.HasMasteredSkill(skillID)) { TitleBarBG.color = header_color_has_skill; hatImage.material = defaultMaterial; } else { TitleBarBG.color = header_color_disabled; hatImage.material = desaturatedMaterial; } } hatImage.sprite = Assets.GetSprite(skill.badge); bool active = false; if ((UnityEngine.Object)minionResume != (UnityEngine.Object)null) { minionResume.AptitudeBySkillGroup.TryGetValue(skill.skillGroup, out float value); active = (value > 0f); } aptitudeBox.SetActive(active); traitDisabledIcon.SetActive((UnityEngine.Object)minionResume != (UnityEngine.Object)null && !minionResume.IsAbleToLearnSkill(skill.Id)); string text = string.Empty; List <string> list = new List <string>(); foreach (MinionIdentity item in Components.LiveMinionIdentities.Items) { MinionResume component = item.GetComponent <MinionResume>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.HasMasteredSkill(skillID)) { list.Add(component.GetProperName()); } } foreach (MinionStorage item2 in Components.MinionStorages.Items) { foreach (MinionStorage.Info item3 in item2.GetStoredMinionInfo()) { MinionStorage.Info current3 = item3; if (current3.serializedMinion != null) { StoredMinionIdentity storedMinionIdentity2 = current3.serializedMinion.Get <StoredMinionIdentity>(); if ((UnityEngine.Object)storedMinionIdentity2 != (UnityEngine.Object)null && storedMinionIdentity2.HasMasteredSkill(skillID)) { list.Add(storedMinionIdentity2.GetProperName()); } } } } masteryCount.gameObject.SetActive(list.Count > 0); foreach (string item4 in list) { text = text + "\n • " + item4; } masteryCount.SetSimpleTooltip((list.Count <= 0) ? UI.ROLES_SCREEN.WIDGET.NO_MASTERS_TOOLTIP.text : string.Format(UI.ROLES_SCREEN.WIDGET.NUMBER_OF_MASTERS_TOOLTIP, text)); masteryCount.GetComponentInChildren <LocText>().text = list.Count.ToString(); } }
public string DuplicantSkillString(Skill skill) { string text = string.Empty; MinionIdentity minionIdentity = skillsScreen.CurrentlySelectedMinion as MinionIdentity; if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { MinionResume component = minionIdentity.GetComponent <MinionResume>(); if ((UnityEngine.Object)component == (UnityEngine.Object)null) { return(string.Empty); } LocString cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.CAN_MASTER; if (!component.HasMasteredSkill(skill.Id)) { MinionResume.SkillMasteryConditions[] skillMasteryConditions = component.GetSkillMasteryConditions(skill.Id); if (!component.CanMasterSkill(skillMasteryConditions)) { bool flag = false; text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.CANNOT_MASTER; text += string.Format(cAN_MASTER, minionIdentity.GetProperName(), skill.Name); if (Array.Exists(skillMasteryConditions, (MinionResume.SkillMasteryConditions element) => element == MinionResume.SkillMasteryConditions.UnableToLearn)) { flag = true; Trait trait = null; string choreGroupID = Db.Get().SkillGroups.Get(skill.skillGroup).choreGroupID; if (!string.IsNullOrEmpty(choreGroupID)) { Traits component2 = minionIdentity.GetComponent <Traits>(); foreach (Trait trait2 in component2.TraitList) { if (trait2.disabledChoreGroups != null) { ChoreGroup[] disabledChoreGroups = trait2.disabledChoreGroups; foreach (ChoreGroup choreGroup in disabledChoreGroups) { if (choreGroup.Id == choreGroupID && trait == null) { trait = trait2; } } } } } text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.PREVENTED_BY_TRAIT; text += string.Format(cAN_MASTER, trait.Name); } if (!flag && Array.Exists(skillMasteryConditions, (MinionResume.SkillMasteryConditions element) => element == MinionResume.SkillMasteryConditions.MissingPreviousSkill)) { text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.REQUIRES_PREVIOUS_SKILLS; text += string.Format(cAN_MASTER); } if (!flag && Array.Exists(skillMasteryConditions, (MinionResume.SkillMasteryConditions element) => element == MinionResume.SkillMasteryConditions.NeedsSkillPoints)) { text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.REQUIRES_MORE_SKILL_POINTS; text += string.Format(cAN_MASTER); } } else { if (Array.Exists(skillMasteryConditions, (MinionResume.SkillMasteryConditions element) => element == MinionResume.SkillMasteryConditions.StressWarning)) { text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.STRESS_WARNING_MESSAGE; text += string.Format(cAN_MASTER, skill.Name, minionIdentity.GetProperName()); } if (Array.Exists(skillMasteryConditions, (MinionResume.SkillMasteryConditions element) => element == MinionResume.SkillMasteryConditions.SkillAptitude)) { text += "\n"; cAN_MASTER = UI.SKILLS_SCREEN.ASSIGNMENT_REQUIREMENTS.MASTERY.SKILL_APTITUDE; text += string.Format(cAN_MASTER, minionIdentity.GetProperName(), skill.Name); } } } } return(text); }
private void RefreshProgressBars() { if (currentlySelectedMinion != null && !currentlySelectedMinion.IsNull()) { MinionIdentity minionIdentity = currentlySelectedMinion as MinionIdentity; HierarchyReferences component = expectationsTooltip.GetComponent <HierarchyReferences>(); component.GetReference("Labels").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("MoraleBar").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("ExpectationBar").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("StoredMinion").gameObject.SetActive((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null); experienceProgressFill.gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null) { expectationsTooltip.SetSimpleTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, (currentlySelectedMinion as StoredMinionIdentity).GetStorageReason(), currentlySelectedMinion.GetProperName())); experienceBarTooltip.SetSimpleTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, (currentlySelectedMinion as StoredMinionIdentity).GetStorageReason(), currentlySelectedMinion.GetProperName())); EXPCount.text = string.Empty; duplicantLevelIndicator.text = UI.TABLESCREENS.NA; } else { MinionResume component2 = minionIdentity.GetComponent <MinionResume>(); float num = MinionResume.CalculatePreviousExperienceBar(component2.TotalSkillPointsGained); float num2 = MinionResume.CalculateNextExperienceBar(component2.TotalSkillPointsGained); float fillAmount = (component2.TotalExperienceGained - num) / (num2 - num); EXPCount.text = Mathf.RoundToInt(component2.TotalExperienceGained - num) + " / " + Mathf.RoundToInt(num2 - num); duplicantLevelIndicator.text = component2.AvailableSkillpoints.ToString(); experienceProgressFill.fillAmount = fillAmount; experienceBarTooltip.SetSimpleTooltip(string.Format(UI.SKILLS_SCREEN.EXPERIENCE_TOOLTIP, Mathf.RoundToInt(num2 - num) - Mathf.RoundToInt(component2.TotalExperienceGained - num))); AttributeInstance attributeInstance = Db.Get().Attributes.QualityOfLife.Lookup(component2); AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component2); float num3 = 0f; float num4 = 0f; if (!string.IsNullOrEmpty(hoveredSkillID) && !component2.HasMasteredSkill(hoveredSkillID)) { List <string> list = new List <string>(); List <string> list2 = new List <string>(); list.Add(hoveredSkillID); while (list.Count > 0) { for (int num5 = list.Count - 1; num5 >= 0; num5--) { if (!component2.HasMasteredSkill(list[num5])) { num3 += (float)(Db.Get().Skills.Get(list[num5]).tier + 1); if (component2.AptitudeBySkillGroup.ContainsKey(Db.Get().Skills.Get(list[num5]).skillGroup) && component2.AptitudeBySkillGroup[Db.Get().Skills.Get(list[num5]).skillGroup] > 0f) { num4 += 1f; } foreach (string priorSkill in Db.Get().Skills.Get(list[num5]).priorSkills) { list2.Add(priorSkill); } } } list.Clear(); list.AddRange(list2); list2.Clear(); } } float num6 = attributeInstance.GetTotalValue() + num4 / (attributeInstance2.GetTotalValue() + num3); float f = Mathf.Max(attributeInstance.GetTotalValue() + num4, attributeInstance2.GetTotalValue() + num3); while (moraleNotches.Count < Mathf.RoundToInt(f)) { GameObject gameObject = UnityEngine.Object.Instantiate(moraleNotch, moraleNotch.transform.parent); gameObject.SetActive(true); moraleNotches.Add(gameObject); } while (moraleNotches.Count > Mathf.RoundToInt(f)) { GameObject gameObject2 = moraleNotches[moraleNotches.Count - 1]; moraleNotches.Remove(gameObject2); UnityEngine.Object.Destroy(gameObject2); } for (int i = 0; i < moraleNotches.Count; i++) { if ((float)i < attributeInstance.GetTotalValue() + num4) { moraleNotches[i].GetComponentsInChildren <Image>()[1].color = moraleNotchColor; } else { moraleNotches[i].GetComponentsInChildren <Image>()[1].color = Color.clear; } } moraleProgressLabel.text = UI.SKILLS_SCREEN.MORALE + ": " + attributeInstance.GetTotalValue().ToString(); if (num4 > 0f) { LocText locText = moraleProgressLabel; locText.text = locText.text + " + " + GameUtil.ApplyBoldString(GameUtil.ColourizeString(moraleNotchColor, num4.ToString())); } while (expectationNotches.Count < Mathf.RoundToInt(f)) { GameObject gameObject3 = UnityEngine.Object.Instantiate(expectationNotch, expectationNotch.transform.parent); gameObject3.SetActive(true); expectationNotches.Add(gameObject3); } while (expectationNotches.Count > Mathf.RoundToInt(f)) { GameObject gameObject4 = expectationNotches[expectationNotches.Count - 1]; expectationNotches.Remove(gameObject4); UnityEngine.Object.Destroy(gameObject4); } for (int j = 0; j < expectationNotches.Count; j++) { if ((float)j < attributeInstance2.GetTotalValue() + num3) { if ((float)j < attributeInstance2.GetTotalValue()) { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = expectationNotchColor; } else { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = expectationNotchProspectColor; } } else { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = Color.clear; } } expectationsProgressLabel.text = UI.SKILLS_SCREEN.MORALE_EXPECTATION + ": " + attributeInstance2.GetTotalValue().ToString(); if (num3 > 0f) { LocText locText2 = expectationsProgressLabel; locText2.text = locText2.text + " + " + GameUtil.ApplyBoldString(GameUtil.ColourizeString(expectationNotchColor, num3.ToString())); } if (num6 < 1f) { expectationWarning.SetActive(true); moraleWarning.SetActive(false); } else { expectationWarning.SetActive(false); moraleWarning.SetActive(true); } string empty = string.Empty; Dictionary <string, float> dictionary = new Dictionary <string, float>(); string text = empty; empty = text + GameUtil.ApplyBoldString(UI.SKILLS_SCREEN.MORALE) + ": " + attributeInstance.GetTotalValue() + "\n"; for (int k = 0; k < attributeInstance.Modifiers.Count; k++) { dictionary.Add(attributeInstance.Modifiers[k].GetDescription(), attributeInstance.Modifiers[k].Value); } List <KeyValuePair <string, float> > list3 = dictionary.ToList(); list3.Sort((KeyValuePair <string, float> pair1, KeyValuePair <string, float> pair2) => pair2.Value.CompareTo(pair1.Value)); foreach (KeyValuePair <string, float> item in list3) { text = empty; empty = text + " • " + item.Key + ": " + ((!(item.Value > 0f)) ? UIConstants.ColorPrefixRed : UIConstants.ColorPrefixGreen) + item.Value.ToString() + UIConstants.ColorSuffix + "\n"; } empty += "\n"; text = empty; empty = text + GameUtil.ApplyBoldString(UI.SKILLS_SCREEN.MORALE_EXPECTATION) + ": " + attributeInstance2.GetTotalValue() + "\n"; for (int l = 0; l < attributeInstance2.Modifiers.Count; l++) { text = empty; empty = text + " • " + attributeInstance2.Modifiers[l].GetDescription() + ": " + ((!(attributeInstance2.Modifiers[l].Value > 0f)) ? UIConstants.ColorPrefixGreen : UIConstants.ColorPrefixRed) + attributeInstance2.Modifiers[l].GetFormattedString(component2.gameObject) + UIConstants.ColorSuffix + "\n"; } expectationsTooltip.SetSimpleTooltip(empty); } } }