Пример #1
0
    public void ChangeArticle(string id, bool playClickSound = false)
    {
        Debug.Assert(id != null);
        if (playClickSound)
        {
            KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false));
        }
        if (contentContainerPool == null)
        {
            Init();
        }
        SubEntry subEntry = null;

        if (!CodexCache.entries.ContainsKey(id))
        {
            subEntry = null;
            subEntry = CodexCache.FindSubEntry(id);
            if (subEntry != null && !subEntry.disabled)
            {
                id = subEntry.parentEntryID.ToUpper();
            }
        }
        ICodexWidget codexWidget = null;

        CodexCache.entries[id].GetFirstWidget();
        RectTransform rectTransform = null;

        if (subEntry != null)
        {
            foreach (ContentContainer contentContainer2 in CodexCache.entries[id].contentContainers)
            {
                if (contentContainer2 == subEntry.contentContainers[0])
                {
                    codexWidget = contentContainer2.content[0];
                    break;
                }
            }
        }
        if (!CodexCache.entries.ContainsKey(id) || CodexCache.entries[id].disabled)
        {
            id = "PAGENOTFOUND";
        }
        int    num  = 0;
        string text = string.Empty;

        while (contentContainers.transform.childCount > 0)
        {
            while (!string.IsNullOrEmpty(text) && CodexCache.entries[activeEntryID].contentContainers[num].lockID == text)
            {
                num++;
            }
            GameObject gameObject = contentContainers.transform.GetChild(0).gameObject;
            int        num2       = 0;
            while (gameObject.transform.childCount > 0)
            {
                GameObject gameObject2 = gameObject.transform.GetChild(0).gameObject;
                Type       key;
                if (gameObject2.name == "PrefabContentLocked")
                {
                    text = CodexCache.entries[activeEntryID].contentContainers[num].lockID;
                    key  = typeof(CodexContentLockedIndicator);
                }
                else
                {
                    key = CodexCache.entries[activeEntryID].contentContainers[num].content[num2].GetType();
                }
                ContentUIPools[key].ClearElement(gameObject2);
                num2++;
            }
            contentContainerPool.ClearElement(contentContainers.transform.GetChild(0).gameObject);
            num++;
        }
        bool flag = CodexCache.entries[id] is CategoryEntry;

        activeEntryID = id;
        if (CodexCache.entries[id].contentContainers == null)
        {
            CodexCache.entries[id].contentContainers = new List <ContentContainer>();
        }
        bool   flag2 = false;
        string a     = string.Empty;

        for (int i = 0; i < CodexCache.entries[id].contentContainers.Count; i++)
        {
            ContentContainer contentContainer = CodexCache.entries[id].contentContainers[i];
            if (!string.IsNullOrEmpty(contentContainer.lockID) && !Game.Instance.unlocks.IsUnlocked(contentContainer.lockID))
            {
                if (a != contentContainer.lockID)
                {
                    GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject;
                    ConfigureContentContainer(contentContainer, gameObject3, flag && flag2);
                    a = contentContainer.lockID;
                    GameObject gameObject4 = ContentUIPools[typeof(CodexContentLockedIndicator)].GetFreeElement(gameObject3, true).gameObject;
                }
            }
            else
            {
                GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject;
                ConfigureContentContainer(contentContainer, gameObject3, flag && flag2);
                flag2 = !flag2;
                if (contentContainer.content != null)
                {
                    foreach (ICodexWidget item in contentContainer.content)
                    {
                        GameObject gameObject5 = ContentUIPools[item.GetType()].GetFreeElement(gameObject3, true).gameObject;
                        item.Configure(gameObject5, displayPane, textStyles);
                        if (item == codexWidget)
                        {
                            rectTransform = gameObject5.rectTransform();
                        }
                    }
                }
            }
        }
        string text2 = string.Empty;
        string text3 = id;
        int    num3  = 0;

        while (text3 != CodexCache.FormatLinkID("HOME") && num3 < 10)
        {
            num3++;
            if (text3 != null)
            {
                text2 = ((!(text3 != id)) ? text2.Insert(0, CodexCache.entries[text3].name) : text2.Insert(0, CodexCache.entries[text3].name + " > "));
                text3 = CodexCache.entries[text3].parentId;
            }
            else
            {
                text3 = CodexCache.entries[CodexCache.FormatLinkID("HOME")].id;
                text2 = text2.Insert(0, CodexCache.entries[text3].name + " > ");
            }
        }
        currentLocationText.text = ((!(text2 == string.Empty)) ? text2 : CodexCache.entries["HOME"].name);
        if (history.Count == 0)
        {
            history.Add(activeEntryID);
        }
        else if (history[history.Count - 1] != activeEntryID)
        {
            if (history.Count > 1 && history[history.Count - 2] == activeEntryID)
            {
                history.RemoveAt(history.Count - 1);
            }
            else
            {
                history.Add(activeEntryID);
            }
        }
        if (history.Count > 1)
        {
            backButton.text = UI.FormatAsLink(string.Format(UI.CODEX.BACK_BUTTON, UI.StripLinkFormatting(CodexCache.entries[history[history.Count - 2]].name)), CodexCache.entries[history[history.Count - 2]].id);
        }
        else
        {
            backButton.text = UI.StripLinkFormatting(GameUtil.ColourizeString(Color.grey, string.Format(UI.CODEX.BACK_BUTTON, CodexCache.entries["HOME"].name)));
        }
        if ((UnityEngine.Object)rectTransform != (UnityEngine.Object)null)
        {
            if (scrollToTargetRoutine != null)
            {
                StopCoroutine(scrollToTargetRoutine);
            }
            scrollToTargetRoutine = StartCoroutine(ScrollToTarget(rectTransform));
        }
        else
        {
            displayScrollRect.content.SetLocalPosition(Vector3.zero);
        }
    }
Пример #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);
     }
 }
Пример #3
0
    private string HoverPersonalPriority(object widget_go_obj)
    {
        GameObject gameObject = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(gameObject) as PrioritizationGroupTableColumn;
        ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
        string     text       = null;
        TableRow   widgetRow  = GetWidgetRow(gameObject);

        switch (widgetRow.rowType)
        {
        case TableRow.RowType.Header:
        {
            string text2 = UI.JOBSSCREEN.HEADER_TOOLTIP.ToString();
            text2 = text2.Replace("{Job}", choreGroup.Name);
            string text3 = UI.JOBSSCREEN.HEADER_DETAILS_TOOLTIP.ToString();
            text3 = text3.Replace("{Description}", choreGroup.description);
            HashSet <string> hashSet = new HashSet <string>();
            foreach (ChoreType choreType in choreGroup.choreTypes)
            {
                hashSet.Add(choreType.Name);
            }
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;
            foreach (string item in hashSet)
            {
                stringBuilder.Append(item);
                if (num < hashSet.Count - 1)
                {
                    stringBuilder.Append(", ");
                }
                num++;
            }
            text3 = text3.Replace("{ChoreList}", stringBuilder.ToString());
            return(text2.Replace("{Details}", text3));
        }

        case TableRow.RowType.Default:
            text = UI.JOBSSCREEN.NEW_MINION_ITEM_TOOLTIP.ToString();
            break;

        case TableRow.RowType.Minion:
        case TableRow.RowType.StoredMinon:
            text = UI.JOBSSCREEN.ITEM_TOOLTIP.ToString();
            text = text.Replace("{Name}", widgetRow.name);
            break;
        }
        ToolTip             componentInChildren = gameObject.GetComponentInChildren <ToolTip>();
        IAssignableIdentity identity            = widgetRow.GetIdentity();
        MinionIdentity      minionIdentity      = identity as MinionIdentity;

        if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
        {
            IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
            int    personalPriority = priorityManager.GetPersonalPriority(choreGroup);
            string newValue         = GetPriorityStr(personalPriority);
            string priorityValue    = GetPriorityValue(personalPriority);
            if (priorityManager.IsChoreGroupDisabled(choreGroup))
            {
                Trait  trait     = null;
                Traits component = minionIdentity.GetComponent <Traits>();
                foreach (Trait trait2 in component.TraitList)
                {
                    if (trait2.disabledChoreGroups != null)
                    {
                        ChoreGroup[] disabledChoreGroups = trait2.disabledChoreGroups;
                        foreach (ChoreGroup choreGroup2 in disabledChoreGroups)
                        {
                            if (choreGroup2.IdHash == choreGroup.IdHash)
                            {
                                trait = trait2;
                                break;
                            }
                        }
                        if (trait != null)
                        {
                            break;
                        }
                    }
                }
                text = UI.JOBSSCREEN.TRAIT_DISABLED.ToString();
                text = text.Replace("{Name}", minionIdentity.GetProperName());
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Trait}", trait.Name);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
            }
            else
            {
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Priority}", newValue);
                text = text.Replace("{PriorityValue}", priorityValue);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
                if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
                {
                    text = "\n" + UI.JOBSSCREEN.MINION_SKILL_TOOLTIP.ToString();
                    text = text.Replace("{Name}", minionIdentity.GetProperName());
                    text = text.Replace("{Attribute}", choreGroup.attribute.Name);
                    AttributeInstance attributeInstance        = minionIdentity.GetAttributes().Get(choreGroup.attribute);
                    float             totalValue               = attributeInstance.GetTotalValue();
                    TextStyleSetting  tooltipTextStyle_Ability = TooltipTextStyle_Ability;
                    text += GameUtil.ColourizeString(tooltipTextStyle_Ability.textColor, totalValue.ToString());
                    componentInChildren.AddMultiStringTooltip(text, null);
                }
                componentInChildren.AddMultiStringTooltip(UI.HORIZONTAL_RULE + "\n" + GetUsageString(), null);
            }
        }
        else if ((UnityEngine.Object)(identity as StoredMinionIdentity) != (UnityEngine.Object)null)
        {
            componentInChildren.AddMultiStringTooltip(string.Format(UI.JOBSSCREEN.CANNOT_ADJUST_PRIORITY, identity.GetProperName(), (identity as StoredMinionIdentity).GetStorageReason()), null);
        }
        return(string.Empty);
    }
Пример #4
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);
         }
     }
 }