/// <summary>
        /// Generates the tool tip text for the specified Duplicant row.
        /// </summary>
        /// <returns>The tool tip text to display for allowing or disallowing.</returns>
        private string GetTooltip()
        {
            string text = "";

            // UNITY WHY
            if (targetIdentity != null && !targetIdentity.IsNull())
            {
                if (currentState == AllowableState.Allowed)
                {
                    text = string.Format(STRINGS.UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.
                                         UNASSIGN_TOOLTIP, targetIdentity.GetProperName());
                }
                else
                {
                    text = string.Format(STRINGS.UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.
                                         ASSIGN_TO_TOOLTIP, targetIdentity.GetProperName());
                }
            }
            return(text);
        }
Пример #2
0
        /// <summary>
        /// Fired by the rows when a row is clicked in the UI.
        /// </summary>
        /// <param name="identity">The Duplicant (or "public") that was selected or
        /// deselected.</param>
        internal void OnRowClicked(IAssignableIdentity identity)
        {
            if (identity != null && !identity.IsNull())
            {
#if DEBUG
                PUtil.LogDebug("Selected row " + identity.GetProperName());
#endif
                if (identity is MinionAssignablesProxy trueDupe)
                {
                    // Actual Duplicant
                    int prefabID = trueDupe.TargetInstanceID;
                    if (profile.IsPublicAllowed())
                    {
                        ConvertPublicToExplicit();
                    }
                    if (profile.IsAllowed(prefabID))
                    {
                        profile.RemoveDuplicant(prefabID);
                    }
                    else
                    {
                        profile.AddDuplicant(prefabID);
                    }
                }
                else
                {
                    // "Public"
                    if (profile.IsPublicAllowed())
                    {
                        profile.DisallowAll();
                    }
                    else
                    {
                        profile.AllowAll();
                    }
                }
                // Cheaper than a full rebuild
                foreach (var row in allowRows)
                {
                    row.Value.Refresh();
                }
            }
        }
Пример #3
0
    private string GetTooltip()
    {
        ToolTip component = GetComponent <ToolTip>();

        component.ClearMultiStringTooltip();
        if (targetIdentity != null && !targetIdentity.IsNull())
        {
            switch (currentState)
            {
            case AssignableState.Selected:
                component.AddMultiStringTooltip(string.Format(UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.UNASSIGN_TOOLTIP, targetIdentity.GetProperName()), null);
                break;

            case AssignableState.Disabled:
                component.AddMultiStringTooltip(string.Format(UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.DISABLED_TOOLTIP, targetIdentity.GetProperName()), null);
                break;

            default:
                component.AddMultiStringTooltip(string.Format(UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.ASSIGN_TO_TOOLTIP, targetIdentity.GetProperName()), null);
                break;
            }
        }
        return(string.Empty);
    }
Пример #4
0
 private void SetPortraitAnimator(IAssignableIdentity identity)
 {
     if (identity != null && !identity.IsNull())
     {
         if ((UnityEngine.Object)animController == (UnityEngine.Object)null)
         {
             animController = Util.KInstantiateUI(Assets.GetPrefab(new Tag("FullMinionUIPortrait")), duplicantAnimAnchor.gameObject, false).GetComponent <KBatchedAnimController>();
             animController.gameObject.SetActive(true);
             KCanvasScaler kCanvasScaler = UnityEngine.Object.FindObjectOfType <KCanvasScaler>();
             animController.animScale = baseCharacterScale * (1f / kCanvasScaler.GetCanvasScale());
             ScreenResize instance = ScreenResize.Instance;
             instance.OnResize = (System.Action)Delegate.Combine(instance.OnResize, new System.Action(OnResize));
         }
         string       value     = string.Empty;
         Accessorizer component = animController.GetComponent <Accessorizer>();
         for (int num = component.GetAccessories().Count - 1; num >= 0; num--)
         {
             component.RemoveAccessory(component.GetAccessories()[num].Get());
         }
         MinionIdentity       minionIdentity       = identity as MinionIdentity;
         StoredMinionIdentity storedMinionIdentity = identity as StoredMinionIdentity;
         Accessorizer         accessorizer         = null;
         if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
         {
             accessorizer = minionIdentity.GetComponent <Accessorizer>();
             foreach (ResourceRef <Accessory> accessory in accessorizer.GetAccessories())
             {
                 component.AddAccessory(accessory.Get());
             }
             value = minionIdentity.GetComponent <MinionResume>().CurrentHat;
         }
         else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null)
         {
             foreach (ResourceRef <Accessory> accessory2 in storedMinionIdentity.accessories)
             {
                 component.AddAccessory(accessory2.Get());
             }
             value = storedMinionIdentity.currentHat;
         }
         HashedString name = "anim_idle_healthy_kanim";
         idle_anim = Assets.GetAnim(name);
         if ((UnityEngine.Object)idle_anim != (UnityEngine.Object)null)
         {
             animController.AddAnimOverrides(idle_anim, 0f);
         }
         animController.Queue("idle_default", KAnim.PlayMode.Loop, 1f, 0f);
         AccessorySlot hat = Db.Get().AccessorySlots.Hat;
         animController.SetSymbolVisiblity(hat.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false);
         animController.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, string.IsNullOrEmpty(value) ? true : false);
         animController.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false);
         KAnim.Build.Symbol source_symbol  = null;
         KAnim.Build.Symbol source_symbol2 = null;
         if ((bool)accessorizer)
         {
             source_symbol  = accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol;
             source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol;
         }
         else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null)
         {
             source_symbol  = storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol;
             source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol;
         }
         animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HairAlways.targetSymbolId, source_symbol, 1);
         animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, source_symbol2, 1);
     }
 }
Пример #5
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);
         }
     }
 }