Esempio n. 1
0
 private void ChangePersonalPriority(IPersonalPriorityManager priority_mgr, ChoreGroup chore_group, int delta, bool wrap_around)
 {
     if (priority_mgr.IsChoreGroupDisabled(chore_group))
     {
         KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false));
     }
     else
     {
         int personalPriority = priority_mgr.GetPersonalPriority(chore_group);
         personalPriority += delta;
         if (wrap_around)
         {
             personalPriority %= 6;
             if (personalPriority < 0)
             {
                 personalPriority += 6;
             }
         }
         personalPriority = Mathf.Clamp(personalPriority, 0, 5);
         priority_mgr.SetPersonalPriority(chore_group, personalPriority);
         if (delta > 0)
         {
             KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false));
         }
         else
         {
             KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false));
         }
     }
 }
Esempio n. 2
0
    private void ChangeColumnPriority(object widget_go_obj, int new_priority)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType != 0)
            {
                Debug.Assert(false);
            }
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
            foreach (TableRow row in rows)
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(row);
                if (priorityManager != null)
                {
                    priorityManager.SetPersonalPriority(choreGroup, new_priority);
                    GameObject widget = row.GetWidget(prioritizationGroupTableColumn);
                    UpdateWidget(widget, choreGroup, priorityManager);
                }
            }
        }
    }
Esempio n. 3
0
    private void ChangeRowPriority(object widget_go_obj, int delta)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType == TableRow.RowType.Header)
            {
                Debug.Assert(false);
            }
            else
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
                foreach (TableColumn value in columns.Values)
                {
                    PrioritizationGroupTableColumn prioritizationGroupTableColumn = value as PrioritizationGroupTableColumn;
                    if (prioritizationGroupTableColumn != null)
                    {
                        ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup;
                        GameObject widget      = widgetRow.GetWidget(prioritizationGroupTableColumn);
                        ChangePersonalPriority(priorityManager, chore_group, delta, false);
                        UpdateWidget(widget, chore_group, priorityManager);
                    }
                }
            }
        }
    }
Esempio n. 4
0
    private void LoadValue(IAssignableIdentity minion, GameObject widget_go)
    {
        if (!((UnityEngine.Object)widget_go == (UnityEngine.Object)null))
        {
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
            TableRow   widgetRow  = GetWidgetRow(widget_go);
            switch (widgetRow.rowType)
            {
            case TableRow.RowType.Header:
                InitializeHeader(choreGroup, widget_go);
                break;

            case TableRow.RowType.Default:
            case TableRow.RowType.Minion:
            case TableRow.RowType.StoredMinon:
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
                bool flag = priorityManager.IsChoreGroupDisabled(choreGroup);
                HierarchyReferences component = widget_go.GetComponent <HierarchyReferences>();
                KImage kImage = component.GetReference("FG") as KImage;
                kImage.raycastTarget = flag;
                ToolTip toolTip = component.GetReference("FGToolTip") as ToolTip;
                toolTip.enabled = flag;
                break;
            }
            }
            IPersonalPriorityManager priorityManager2 = GetPriorityManager(widgetRow);
            if (priorityManager2 != null)
            {
                UpdateWidget(widget_go, choreGroup, priorityManager2);
            }
        }
    }
Esempio n. 5
0
    private IPersonalPriorityManager GetPriorityManager(TableRow row)
    {
        IPersonalPriorityManager result = null;

        switch (row.rowType)
        {
        case TableRow.RowType.Default:
            result = Immigration.Instance;
            break;

        case TableRow.RowType.Minion:
        {
            MinionIdentity minionIdentity = row.GetIdentity() as MinionIdentity;
            if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
            {
                result = minionIdentity.GetComponent <ChoreConsumer>();
            }
            break;
        }

        case TableRow.RowType.StoredMinon:
            result = (row.GetIdentity() as StoredMinionIdentity);
            break;
        }
        return(result);
    }
    public void ApplyDefaultPersonalPriorities(GameObject minion)
    {
        IPersonalPriorityManager instance  = Instance;
        IPersonalPriorityManager component = minion.GetComponent <ChoreConsumer>();

        foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources)
        {
            int personalPriority = instance.GetPersonalPriority(resource);
            component.SetPersonalPriority(resource, personalPriority);
        }
    }
Esempio n. 7
0
    private void UpdateWidget(GameObject widget_go, ChoreGroup chore_group, IPersonalPriorityManager priority_mgr)
    {
        int  fgIndex = 0;
        int  value   = 0;
        bool flag    = priority_mgr.IsChoreGroupDisabled(chore_group);

        if (!flag)
        {
            value = priority_mgr.GetPersonalPriority(chore_group);
        }
        value = Mathf.Clamp(value, 0, 5);
        for (int i = 0; i < JobsTableScreen.priorityInfo.Count - 1; i++)
        {
            PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[i];
            if (priorityInfo.priority == value)
            {
                fgIndex = i;
                break;
            }
        }
        OptionSelector component  = widget_go.GetComponent <OptionSelector>();
        int            num        = priority_mgr?.GetAssociatedSkillLevel(chore_group) ?? 0;
        Color32        fillColour = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, 128);

        if (num > 0)
        {
            float num2 = (float)(num - skillLevelLow);
            num2      /= (float)(skillLevelHigh - skillLevelLow);
            fillColour = Color32.Lerp(skillOutlineColourLow, skillOutlineColourHigh, num2);
        }
        component.ConfigureItem(flag, new OptionSelector.DisplayOptionInfo
        {
            bgOptions  = null,
            fgOptions  = prioritySprites,
            bgIndex    = 0,
            fgIndex    = fgIndex,
            fillColour = fillColour
        });
        ToolTip componentInChildren = widget_go.transform.GetComponentInChildren <ToolTip>();

        if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null)
        {
            componentInChildren.toolTip      = HoverPersonalPriority(widget_go);
            componentInChildren.forceRefresh = true;
        }
    }
Esempio n. 8
0
    private void ChangePersonalPriority(object widget_go_obj, int delta)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType == TableRow.RowType.Header)
            {
                Debug.Assert(false);
            }
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup;
            IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
            ChangePersonalPriority(priorityManager, chore_group, delta, true);
            UpdateWidget(widget_go, chore_group, priorityManager);
        }
    }
Esempio n. 9
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);
    }