public void Initialize(ComplexFabricator target)
    {
        if ((Object)target == (Object)null)
        {
            Debug.LogError("ComplexFabricator provided was null.");
        }
        else
        {
            targetFab = target;
            base.gameObject.SetActive(true);
            recipeMap = new Dictionary <GameObject, ComplexRecipe>();
            recipeToggles.ForEach(delegate(GameObject rbi)
            {
                Object.Destroy(rbi.gameObject);
            });
            recipeToggles.Clear();
            GridLayoutGroup component = recipeGrid.GetComponent <GridLayoutGroup>();
            switch (targetFab.sideScreenStyle)
            {
            case StyleSetting.ListResult:
            case StyleSetting.ListInput:
            case StyleSetting.ListInputOutput:
            {
                component.constraintCount = 1;
                GridLayoutGroup gridLayoutGroup2 = component;
                Vector2         cellSize2        = component.cellSize;
                gridLayoutGroup2.cellSize = new Vector2(262f, cellSize2.y);
                break;
            }

            case StyleSetting.ClassicFabricator:
                component.constraintCount       = 128;
                component.cellSize              = new Vector2(78f, 96f);
                buttonScrollContainer.minHeight = 100f;
                break;

            case StyleSetting.ListQueueHybrid:
                component.constraintCount       = 1;
                component.cellSize              = new Vector2(264f, 64f);
                buttonScrollContainer.minHeight = 66f;
                break;

            default:
            {
                component.constraintCount = 3;
                GridLayoutGroup gridLayoutGroup = component;
                Vector2         cellSize        = component.cellSize;
                gridLayoutGroup.cellSize = new Vector2(116f, cellSize.y);
                break;
            }
            }
            int             num     = 0;
            ComplexRecipe[] recipes = targetFab.GetRecipes();
            ComplexRecipe[] array   = recipes;
            foreach (ComplexRecipe recipe in array)
            {
                bool flag = false;
                if (DebugHandler.InstantBuildMode)
                {
                    flag = true;
                }
                else if (recipe.RequiresTechUnlock() && recipe.IsRequiredTechUnlocked())
                {
                    flag = true;
                }
                else if (target.GetRecipeQueueCount(recipe) != 0)
                {
                    flag = true;
                }
                else if (AnyRecipeRequirementsDiscovered(recipe))
                {
                    flag = true;
                }
                else if (HasAnyRecipeRequirements(recipe))
                {
                    flag = true;
                }
                if (flag)
                {
                    num++;
                    Tuple <Sprite, Color> uISprite  = Def.GetUISprite(recipe.ingredients[0].material, "ui", false);
                    Tuple <Sprite, Color> uISprite2 = Def.GetUISprite(recipe.results[0].material, "ui", false);
                    KToggle    newToggle            = null;
                    GameObject entryGO;
                    switch (target.sideScreenStyle)
                    {
                    case StyleSetting.ListInputOutput:
                    case StyleSetting.GridInputOutput:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButtonMultiple, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        HierarchyReferences           component2  = newToggle.GetComponent <HierarchyReferences>();
                        ComplexRecipe.RecipeElement[] ingredients = recipe.ingredients;
                        foreach (ComplexRecipe.RecipeElement recipeElement in ingredients)
                        {
                            GameObject gameObject = Util.KInstantiateUI(component2.GetReference("FromIconPrefab").gameObject, component2.GetReference("FromIcons").gameObject, true);
                            gameObject.GetComponent <Image>().sprite = Def.GetUISprite(recipeElement.material, "ui", false).first;
                            gameObject.GetComponent <Image>().color  = Def.GetUISprite(recipeElement.material, "ui", false).second;
                            gameObject.gameObject.name = recipeElement.material.Name;
                        }
                        ComplexRecipe.RecipeElement[] results = recipe.results;
                        foreach (ComplexRecipe.RecipeElement recipeElement2 in results)
                        {
                            GameObject gameObject2 = Util.KInstantiateUI(component2.GetReference("ToIconPrefab").gameObject, component2.GetReference("ToIcons").gameObject, true);
                            gameObject2.GetComponent <Image>().sprite = Def.GetUISprite(recipeElement2.material, "ui", false).first;
                            gameObject2.GetComponent <Image>().color  = Def.GetUISprite(recipeElement2.material, "ui", false).second;
                            gameObject2.gameObject.name = recipeElement2.material.Name;
                        }
                        break;
                    }

                    case StyleSetting.ListQueueHybrid:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButtonQueueHybrid, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        recipeMap.Add(entryGO, recipe);
                        Image image = entryGO.GetComponentsInChildrenOnly <Image>()[2];
                        if (recipe.nameDisplay == ComplexRecipe.RecipeNameDisplay.Ingredient)
                        {
                            image.sprite = uISprite.first;
                            image.color  = uISprite.second;
                        }
                        else
                        {
                            image.sprite = uISprite2.first;
                            image.color  = uISprite2.second;
                        }
                        entryGO.GetComponentInChildren <LocText>().text = recipe.GetUIName();
                        bool flag2 = HasAllRecipeRequirements(recipe);
                        image.material = ((!flag2) ? Assets.UIPrefabs.TableScreenWidgets.DesaturatedUIMaterial : Assets.UIPrefabs.TableScreenWidgets.DefaultUIMaterial);
                        RefreshQueueCountDisplay(entryGO, targetFab);
                        entryGO.GetComponent <HierarchyReferences>().GetReference <MultiToggle>("DecrementButton").onClick = delegate
                        {
                            target.DecrementRecipeQueueCount(recipe, false);
                            RefreshQueueCountDisplay(entryGO, target);
                        };
                        entryGO.GetComponent <HierarchyReferences>().GetReference <MultiToggle>("IncrementButton").onClick = delegate
                        {
                            target.IncrementRecipeQueueCount(recipe);
                            RefreshQueueCountDisplay(entryGO, target);
                        };
                        entryGO.gameObject.SetActive(true);
                        break;
                    }

                    default:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButton, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        Image componentInChildrenOnly = newToggle.gameObject.GetComponentInChildrenOnly <Image>();
                        if (target.sideScreenStyle == StyleSetting.GridInput || target.sideScreenStyle == StyleSetting.ListInput)
                        {
                            componentInChildrenOnly.sprite = uISprite.first;
                            componentInChildrenOnly.color  = uISprite.second;
                        }
                        else
                        {
                            componentInChildrenOnly.sprite = uISprite2.first;
                            componentInChildrenOnly.color  = uISprite2.second;
                        }
                        break;
                    }
                    }
                    if (targetFab.sideScreenStyle == StyleSetting.ClassicFabricator)
                    {
                        newToggle.GetComponentInChildren <LocText>().text = recipe.results[0].material.ProperName();
                    }
                    else if (targetFab.sideScreenStyle != StyleSetting.ListQueueHybrid)
                    {
                        newToggle.GetComponentInChildren <LocText>().text = string.Format(UI.UISIDESCREENS.REFINERYSIDESCREEN.RECIPE_FROM_TO_WITH_NEWLINES, recipe.ingredients[0].material.ProperName(), recipe.results[0].material.ProperName());
                    }
                    ToolTip component3 = entryGO.GetComponent <ToolTip>();
                    component3.toolTipPosition       = ToolTip.TooltipPosition.Custom;
                    component3.parentPositionAnchor  = new Vector2(0f, 0.5f);
                    component3.tooltipPivot          = new Vector2(1f, 1f);
                    component3.tooltipPositionOffset = new Vector2(-24f, 20f);
                    component3.ClearMultiStringTooltip();
                    component3.AddMultiStringTooltip(recipe.GetUIName(), styleTooltipHeader);
                    component3.AddMultiStringTooltip(recipe.description, styleTooltipBody);
                    newToggle.onClick += delegate
                    {
                        ToggleClicked(newToggle);
                    };
                    entryGO.SetActive(true);
                    recipeToggles.Add(entryGO);
                }
            }
            if (recipeToggles.Count > 0)
            {
                LayoutElement component4 = buttonScrollContainer.GetComponent <LayoutElement>();
                float         num2       = (float)num;
                Vector2       sizeDelta  = recipeButtonQueueHybrid.rectTransform().sizeDelta;
                component4.minHeight = Mathf.Min(451f, 2f + num2 * sizeDelta.y);
                subtitleLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.SUBTITLE);
                noRecipesDiscoveredLabel.gameObject.SetActive(false);
            }
            else
            {
                subtitleLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.NORECIPEDISCOVERED);
                noRecipesDiscoveredLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.NORECIPEDISCOVERED_BODY);
                noRecipesDiscoveredLabel.gameObject.SetActive(true);
                LayoutElement component5 = buttonScrollContainer.GetComponent <LayoutElement>();
                Vector2       sizeDelta2 = noRecipesDiscoveredLabel.rectTransform.sizeDelta;
                component5.minHeight = sizeDelta2.y + 10f;
            }
            RefreshIngredientAvailabilityVis();
        }
    }
Exemple #2
0
    public void RefreshHat(string hat)
    {
        HierarchyReferences component = GetComponent <HierarchyReferences>();

        component.GetReference("selectedHat").GetComponent <Image>().sprite = Assets.GetSprite((!string.IsNullOrEmpty(hat)) ? hat : "hat_role_none");
    }
Exemple #3
0
    private GameObject SpawnSlider(SliderValue value)
    {
        GameObject          gameObject = Util.KInstantiateUI(sliderPropertyPrefab, base.gameObject, true);
        HierarchyReferences component  = gameObject.GetComponent <HierarchyReferences>();

        component.GetReference <Image>("BottomIcon").sprite = Assets.GetSprite(value.bottomSprite);
        component.GetReference <Image>("TopIcon").sprite    = Assets.GetSprite(value.topSprite);
        KSlider           slider     = component.GetReference <KSlider>("Slider");
        KNumberInputField inputField = component.GetReference <KNumberInputField>("InputField");

        gameObject.GetComponent <ToolTip>().SetSimpleTooltip(value.tooltip);
        slider.minValue     = value.minValue;
        slider.maxValue     = value.maxValue;
        inputField.minValue = 0f;
        inputField.maxValue = 99999f;
        inputFields.Add(inputField.gameObject);
        value.slider            = slider;
        value.inputField        = inputField;
        value.row               = gameObject;
        slider.onReleaseHandle += delegate
        {
            slider.value            = Mathf.Round(slider.value * 10f) / 10f;
            inputField.currentValue = slider.value;
            inputField.SetDisplayValue(inputField.currentValue.ToString());
            if (value.onValueChanged != null)
            {
                value.onValueChanged(slider.value);
            }
        };
        slider.onDrag += delegate
        {
            slider.value            = Mathf.Round(slider.value * 10f) / 10f;
            inputField.currentValue = slider.value;
            inputField.SetDisplayValue(inputField.currentValue.ToString());
            if (value.onValueChanged != null)
            {
                value.onValueChanged(slider.value);
            }
        };
        slider.onMove += delegate
        {
            slider.value            = Mathf.Round(slider.value * 10f) / 10f;
            inputField.currentValue = slider.value;
            inputField.SetDisplayValue(inputField.currentValue.ToString());
            if (value.onValueChanged != null)
            {
                value.onValueChanged(slider.value);
            }
        };
        inputField.onEndEdit += delegate
        {
            float num = Mathf.Clamp(Mathf.Round(inputField.currentValue), inputField.minValue, inputField.maxValue);
            inputField.SetDisplayValue(num.ToString());
            slider.value = Mathf.Round(num);
            if (value.onValueChanged != null)
            {
                value.onValueChanged(num);
            }
        };
        component.GetReference <LocText>("UnitLabel").text = value.unitString;
        return(gameObject);
    }
Exemple #4
0
    private void PopulateElements(object data = null)
    {
        refreshHandle.ClearScheduler();
        refreshHandle = UIScheduler.Instance.Schedule("RefreshToDoList", 0.1f, PopulateElements, null, null);
        ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate();

        ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = choreConsumer.GetLastPreconditionSnapshot();
        if (lastPreconditionSnapshot.doFailedContextsNeedSorting)
        {
            lastPreconditionSnapshot.failedContexts.Sort();
            lastPreconditionSnapshot.doFailedContextsNeedSorting = false;
        }
        pooledList.AddRange(lastPreconditionSnapshot.failedContexts);
        pooledList.AddRange(lastPreconditionSnapshot.succeededContexts);
        Chore.Precondition.Context choreB = default(Chore.Precondition.Context);
        MinionTodoChoreEntry       minionTodoChoreEntry = null;
        int         num       = 0;
        Schedulable component = DetailsScreen.Instance.target.GetComponent <Schedulable>();
        string      arg       = string.Empty;
        Schedule    schedule  = component.GetSchedule();

        if (schedule != null)
        {
            ScheduleBlock block = schedule.GetBlock(Schedule.GetBlockIdx());
            arg = block.name;
        }
        currentScheduleBlockLabel.SetText(string.Format(UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CURRENT_SCHEDULE_BLOCK, arg));
        choreTargets.Clear();
        bool flag = false;

        activeChoreEntries = 0;
        for (int num2 = pooledList.Count - 1; num2 >= 0; num2--)
        {
            Chore.Precondition.Context context = pooledList[num2];
            if (context.chore != null)
            {
                Chore.Precondition.Context context2 = pooledList[num2];
                if (!context2.chore.target.isNull)
                {
                    Chore.Precondition.Context context3 = pooledList[num2];
                    if (!((UnityEngine.Object)context3.chore.target.gameObject == (UnityEngine.Object)null) && pooledList[num2].IsPotentialSuccess())
                    {
                        Chore.Precondition.Context context4 = pooledList[num2];
                        if ((UnityEngine.Object)context4.chore.driver == (UnityEngine.Object)choreConsumer.choreDriver)
                        {
                            currentTask.Apply(pooledList[num2]);
                            minionTodoChoreEntry = currentTask;
                            choreB = pooledList[num2];
                            num    = 0;
                            flag   = true;
                        }
                        else if (!flag && activeChoreEntries != 0 && GameUtil.AreChoresUIMergeable(pooledList[num2], choreB))
                        {
                            num++;
                            minionTodoChoreEntry.SetMoreAmount(num);
                        }
                        else
                        {
                            ChoreConsumer obj = choreConsumer;
                            Chore.Precondition.Context context5            = pooledList[num2];
                            HierarchyReferences        hierarchyReferences = PriorityGroupForPriority(obj, context5.chore);
                            MinionTodoChoreEntry       choreEntry          = GetChoreEntry(hierarchyReferences.GetReference <RectTransform>("EntriesContainer"));
                            choreEntry.Apply(pooledList[num2]);
                            minionTodoChoreEntry = choreEntry;
                            choreB = pooledList[num2];
                            num    = 0;
                            flag   = false;
                        }
                    }
                }
            }
        }
        pooledList.Recycle();
        for (int num3 = choreEntries.Count - 1; num3 >= activeChoreEntries; num3--)
        {
            choreEntries[num3].gameObject.SetActive(false);
        }
        foreach (Tuple <PriorityScreen.PriorityClass, int, HierarchyReferences> priorityGroup in priorityGroups)
        {
            RectTransform reference = priorityGroup.third.GetReference <RectTransform>("EntriesContainer");
            priorityGroup.third.gameObject.SetActive(reference.childCount > 0);
        }
    }
Exemple #5
0
    private GameObject SpawnSelector(SelectorValue selector)
    {
        GameObject          gameObject       = Util.KInstantiateUI(selectorPropertyPrefab, base.gameObject, true);
        HierarchyReferences component        = gameObject.GetComponent <HierarchyReferences>();
        GameObject          panel            = component.GetReference("ScrollPanel").gameObject;
        GameObject          gameObject2      = component.GetReference("Content").gameObject;
        InputField          filterInputField = component.GetReference <InputField>("Filter");
        KButton             reference        = component.GetReference <KButton>("Button");

        reference.onClick += delegate
        {
            panel.SetActive(!panel.activeSelf);
            if (panel.activeSelf)
            {
                panel.GetComponent <KScrollRect>().verticalNormalizedPosition = 1f;
                filterInputField.ActivateInputField();
            }
        };
        GameObject gameObject3 = component.GetReference("optionPrefab").gameObject;

        selector.row           = gameObject;
        selector.optionButtons = new List <KeyValuePair <object, GameObject> >();
        if (selector.filters != null)
        {
            GameObject clearFilterButton = Util.KInstantiateUI(gameObject3, gameObject2, false);
            clearFilterButton.GetComponentInChildren <LocText>().text      = UI.SANDBOXTOOLS.FILTERS.BACK;
            clearFilterButton.GetComponentsInChildren <Image>()[1].enabled = false;
            clearFilterButton.GetComponent <KButton>().onClick            += delegate
            {
                selector.currentFilter = null;
                selector.optionButtons.ForEach(delegate(KeyValuePair <object, GameObject> test)
                {
                    if (test.Key is SelectorValue.SearchFilter)
                    {
                        test.Value.SetActive((test.Key as SelectorValue.SearchFilter).parentFilter == null);
                    }
                    else
                    {
                        test.Value.SetActive(false);
                    }
                });
                clearFilterButton.SetActive(false);
                panel.GetComponent <KScrollRect>().verticalNormalizedPosition = 1f;
            };
            SelectorValue.SearchFilter[] filters = selector.filters;
            foreach (SelectorValue.SearchFilter filter in filters)
            {
                GameObject gameObject4 = Util.KInstantiateUI(gameObject3, gameObject2, false);
                gameObject4.SetActive(filter.parentFilter == null);
                gameObject4.GetComponentInChildren <LocText>().text = filter.Name;
                if (filter.icon != null)
                {
                    gameObject4.GetComponentsInChildren <Image>()[1].sprite = filter.icon.first;
                    gameObject4.GetComponentsInChildren <Image>()[1].color  = filter.icon.second;
                }
                gameObject4.GetComponent <KButton>().onClick += delegate
                {
                    selector.currentFilter = filter;
                    clearFilterButton.SetActive(true);
                    selector.optionButtons.ForEach(delegate(KeyValuePair <object, GameObject> test)
                    {
                        if (!(test.Key is SelectorValue.SearchFilter))
                        {
                            test.Value.SetActive(selector.runCurrentFilter(test.Key));
                        }
                        else if ((test.Key as SelectorValue.SearchFilter).parentFilter == null)
                        {
                            test.Value.SetActive(false);
                        }
                        else
                        {
                            test.Value.SetActive((test.Key as SelectorValue.SearchFilter).parentFilter == filter);
                        }
                    });
                    panel.GetComponent <KScrollRect>().verticalNormalizedPosition = 1f;
                };
                selector.optionButtons.Add(new KeyValuePair <object, GameObject>(filter, gameObject4));
            }
        }
        object[] options = selector.options;
        foreach (object option in options)
        {
            GameObject gameObject5 = Util.KInstantiateUI(gameObject3, gameObject2, true);
            gameObject5.GetComponentInChildren <LocText>().text = selector.getOptionName(option);
            gameObject5.GetComponent <KButton>().onClick       += delegate
            {
                selector.onValueChanged(option);
                panel.SetActive(false);
            };
            Tuple <Sprite, Color> tuple = selector.getOptionSprite(option);
            gameObject5.GetComponentsInChildren <Image>()[1].sprite = tuple.first;
            gameObject5.GetComponentsInChildren <Image>()[1].color  = tuple.second;
            selector.optionButtons.Add(new KeyValuePair <object, GameObject>(option, gameObject5));
            if (option is SelectorValue.SearchFilter)
            {
                gameObject5.SetActive((option as SelectorValue.SearchFilter).parentFilter == null);
            }
            else
            {
                gameObject5.SetActive(false);
            }
        }
        selector.button = reference;
        filterInputField.onValueChanged.AddListener(delegate(string filterString)
        {
            List <KeyValuePair <object, GameObject> > list = new List <KeyValuePair <object, GameObject> >();
            selector.optionButtons.ForEach(delegate(KeyValuePair <object, GameObject> test)
            {
                if (test.Key is SelectorValue.SearchFilter)
                {
                    test.Value.SetActive((test.Key as SelectorValue.SearchFilter).Name.ToUpper().Contains(filterString.ToUpper()));
                }
            });
            object[] options2 = selector.options;
            foreach (object option2 in options2)
            {
                list = selector.optionButtons.FindAll((KeyValuePair <object, GameObject> match) => match.Key == option2);
                foreach (KeyValuePair <object, GameObject> item in list)
                {
                    if (filterString == string.Empty)
                    {
                        item.Value.SetActive(false);
                    }
                    else
                    {
                        item.Value.SetActive(selector.filterOptionFunction(filterString, option2));
                    }
                }
            }
            panel.GetComponent <KScrollRect>().verticalNormalizedPosition = 1f;
        });
        inputFields.Add(filterInputField.gameObject);
        panel.SetActive(false);
        return(gameObject);
    }
 /// <summary>
 /// Refreshes one pinned critter entry.
 /// </summary>
 /// <param name="refs">The row to refresh.</param>
 /// <param name="available">The quantity of the critter available.</param>
 private void RefreshLine(HierarchyReferences refs, int available)
 {
     refs.GetReference <LocText>("ValueLabel").SetText(GameUtil.GetFormattedSimple(
                                                           available));
 }
Exemple #7
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);
         }
     }
 }
Exemple #8
0
    private void ApplyThoughtSprite(HierarchyReferences active_bubble, Sprite sprite, string target)
    {
        Image reference = active_bubble.GetReference <Image>(target);

        reference.sprite = sprite;
    }
Exemple #9
0
    private void AddExistingSaveFile(string savename, List <SaveGameFileDetails> fileDetailsList)
    {
        HierarchyReferences savenameRow  = savenameRowPool.GetFreeElement(saveButtonRoot, true);
        KButton             headerButton = savenameRow.GetReference <RectTransform>("Button").GetComponent <KButton>();

        headerButton.ClearOnClick();
        LocText       headerTitle         = savenameRow.GetReference <RectTransform>("HeaderTitle").GetComponent <LocText>();
        LocText       component           = savenameRow.GetReference <RectTransform>("SaveTitle").GetComponent <LocText>();
        LocText       component2          = savenameRow.GetReference <RectTransform>("HeaderDate").GetComponent <LocText>();
        RectTransform saveDetailsRow      = savenameRow.GetReference <RectTransform>("SaveDetailsRow");
        LocText       component3          = savenameRow.GetReference <RectTransform>("SaveDetailsBaseName").GetComponent <LocText>();
        RectTransform savefileRowTemplate = savenameRow.GetReference <RectTransform>("SavefileRowTemplate");

        fileDetailsList.Sort((SaveGameFileDetails x, SaveGameFileDetails y) => y.FileDate.CompareTo(x.FileDate));
        LocText             locText             = headerTitle;
        SaveGameFileDetails saveGameFileDetails = fileDetailsList[0];

        locText.text   = saveGameFileDetails.BaseName;
        component.text = savename;
        LocText             locText2             = component2;
        string              format               = "{0:H:mm:ss} - " + Localization.GetFileDateFormat(0);
        SaveGameFileDetails saveGameFileDetails2 = fileDetailsList[0];

        locText2.text = string.Format(format, saveGameFileDetails2.FileDate);
        LocText             locText3             = component3;
        LocString           bASE_NAME            = UI.FRONTEND.LOADSCREEN.BASE_NAME;
        SaveGameFileDetails saveGameFileDetails3 = fileDetailsList[0];

        locText3.text = $"{bASE_NAME}: {saveGameFileDetails3.BaseName}";
        for (int i = 0; i < savenameRow.transform.childCount; i++)
        {
            GameObject gameObject = savenameRow.transform.GetChild(i).gameObject;
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null && gameObject.name.Contains("Clone"))
            {
                UnityEngine.Object.Destroy(gameObject);
            }
        }
        bool active = true;

        foreach (SaveGameFileDetails fileDetails2 in fileDetailsList)
        {
            SaveGameFileDetails fileDetails   = fileDetails2;
            RectTransform       rectTransform = UnityEngine.Object.Instantiate(savefileRowTemplate, savenameRow.transform);
            HierarchyReferences component4    = rectTransform.GetComponent <HierarchyReferences>();
            KButton             component5    = rectTransform.GetComponent <KButton>();
            RectTransform       reference     = component4.GetReference <RectTransform>("NewestLabel");
            RectTransform       reference2    = component4.GetReference <RectTransform>("AutoLabel");
            LocText             component6    = component4.GetReference <RectTransform>("SaveText").GetComponent <LocText>();
            LocText             component7    = component4.GetReference <RectTransform>("DateText").GetComponent <LocText>();
            reference.gameObject.SetActive(active);
            active = false;
            reference2.gameObject.SetActive(fileDetails.FileInfo.isAutoSave);
            component6.text     = Path.GetFileNameWithoutExtension(fileDetails.FileName);
            component7.text     = string.Format("{0:H:mm:ss} - " + Localization.GetFileDateFormat(0), fileDetails.FileDate);
            component5.onClick += delegate
            {
                onClick(fileDetails.FileName, savename);
            };
            component5.onDoubleClick += delegate
            {
                onClick(fileDetails.FileName, savename);
                Load();
            };
            fileButtonMap.Add(fileDetails.FileName, component5);
        }
        headerButton.onClick += delegate
        {
            bool activeSelf = saveDetailsRow.gameObject.activeSelf;
            bool flag       = (UnityEngine.Object)headerButton == (UnityEngine.Object)currentExpanded;
            if (flag)
            {
                SetChildrenActive(savenameRow, !activeSelf);
            }
            else if (!activeSelf && !flag)
            {
                SetChildrenActive(savenameRow, true);
            }
            if ((UnityEngine.Object)currentExpanded != (UnityEngine.Object)null && !flag)
            {
                SetHeaderButtonActive(currentExpanded, false);
            }
            currentExpanded = headerButton;
            SetHeaderButtonActive(currentExpanded, true);
            headerTitle.transform.parent.gameObject.SetActive(true);
            savefileRowTemplate.gameObject.SetActive(false);
            Action <string, string> action2 = onClick;
            SaveGameFileDetails     saveGameFileDetails5 = fileDetailsList[0];
            action2(saveGameFileDetails5.FileName, savename);
        };
        headerButton.onDoubleClick += delegate
        {
            Action <string, string> action = onClick;
            SaveGameFileDetails     saveGameFileDetails4 = fileDetailsList[0];
            action(saveGameFileDetails4.FileName, savename);
            LoadingOverlay.Load(DoLoad);
        };
        savenameRow.transform.SetAsLastSibling();
    }