Example #1
0
 private void DisplayBuildings(RetiredColonyData data, GameObject container)
 {
     for (int num = container.transform.childCount - 1; num >= 0; num--)
     {
         UnityEngine.Object.Destroy(container.transform.GetChild(num).gameObject);
     }
     data.buildings.Sort(delegate(Tuple <string, int> a, Tuple <string, int> b)
     {
         if (a.second > b.second)
         {
             return(1);
         }
         if (a.second == b.second)
         {
             return(0);
         }
         return(-1);
     });
     data.buildings.Reverse();
     foreach (Tuple <string, int> building in data.buildings)
     {
         GameObject          prefab     = Assets.GetPrefab(building.first);
         GameObject          gameObject = Util.KInstantiateUI(buildingPrefab, container, true);
         HierarchyReferences component  = gameObject.GetComponent <HierarchyReferences>();
         component.GetReference <LocText>("NameLabel").SetText(GameUtil.ApplyBoldString(prefab.GetProperName()));
         component.GetReference <LocText>("CountLabel").SetText(string.Format(UI.RETIRED_COLONY_INFO_SCREEN.BUILDING_COUNT, building.second.ToString()));
         Tuple <Sprite, Color> uISprite = Def.GetUISprite(prefab, "ui", false);
         component.GetReference <Image>("Portrait").sprite = uISprite.first;
     }
 }
Example #2
0
 public void Refresh()
 {
     if (minion != null)
     {
         portrait.SetIdentityObject(minion, true);
         string         empty          = string.Empty;
         MinionIdentity minionIdentity = minion as MinionIdentity;
         hatDropDown.gameObject.SetActive(true);
         if ((Object)minionIdentity != (Object)null)
         {
             MinionResume component              = minionIdentity.GetComponent <MinionResume>();
             int          availableSkillpoints   = component.AvailableSkillpoints;
             int          totalSkillPointsGained = component.TotalSkillPointsGained;
             masteryPoints.text = ((availableSkillpoints <= 0) ? "0" : GameUtil.ApplyBoldString(GameUtil.ColourizeString(new Color(0.5f, 1f, 0.5f, 1f), availableSkillpoints.ToString())));
             AttributeInstance attributeInstance  = Db.Get().Attributes.QualityOfLife.Lookup(component);
             AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component);
             morale.text = $"{attributeInstance.GetTotalValue()}/{attributeInstance2.GetTotalValue()}";
             RefreshToolTip(component);
             List <IListableOption> list = new List <IListableOption>();
             foreach (KeyValuePair <string, bool> item in component.MasteryBySkillID)
             {
                 if (item.Value)
                 {
                     list.Add(new SkillListable(item.Key));
                 }
             }
             hatDropDown.Initialize(list, OnHatDropEntryClick, hatDropDownSort, hatDropEntryRefreshAction, false, minion);
             empty = ((!string.IsNullOrEmpty(component.TargetHat)) ? component.TargetHat : component.CurrentHat);
         }
         else
         {
             StoredMinionIdentity storedMinionIdentity = minion as StoredMinionIdentity;
             ToolTip component2 = GetComponent <ToolTip>();
             component2.ClearMultiStringTooltip();
             component2.AddMultiStringTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, storedMinionIdentity.GetStorageReason(), minion.GetProperName()), null);
             empty = ((!string.IsNullOrEmpty(storedMinionIdentity.targetHat)) ? storedMinionIdentity.targetHat : storedMinionIdentity.currentHat);
             masteryPoints.text = UI.TABLESCREENS.NA;
             morale.text        = UI.TABLESCREENS.NA;
         }
         SetColor((skillsScreen.CurrentlySelectedMinion != minion) ? unselected_color : selected_color);
         HierarchyReferences component3 = GetComponent <HierarchyReferences>();
         RefreshHat(empty);
         component3.GetReference("openButton").gameObject.SetActive((Object)minionIdentity != (Object)null);
     }
 }
Example #3
0
 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);
         }
     }
 }