Esempio n. 1
0
    protected override void OnDragTool(int cell, int distFromOrigin)
    {
        PrioritySetting lastSelectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
        int             num = 0;

        for (int i = 0; i < 39; i++)
        {
            GameObject gameObject = Grid.Objects[cell, i];
            if ((Object)gameObject != (Object)null)
            {
                if ((bool)gameObject.GetComponent <Pickupable>())
                {
                    ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;
                    while (objectLayerListItem != null)
                    {
                        GameObject gameObject2 = objectLayerListItem.gameObject;
                        objectLayerListItem = objectLayerListItem.nextItem;
                        if (!((Object)gameObject2 == (Object)null) && !((Object)gameObject2.GetComponent <MinionIdentity>() != (Object)null) && TryPrioritizeGameObject(gameObject2, lastSelectedPriority))
                        {
                            num++;
                        }
                    }
                }
                else if (TryPrioritizeGameObject(gameObject, lastSelectedPriority))
                {
                    num++;
                }
            }
        }
        if (num > 0)
        {
            PriorityScreen.PlayPriorityConfirmSound(lastSelectedPriority);
        }
    }
Esempio n. 2
0
 private void OnClick()
 {
     if (playSelectionSound)
     {
         PriorityScreen.PlayPriorityConfirmSound(priority);
     }
     if (onClick != null)
     {
         onClick(priority);
     }
 }
 protected override void OnPrefabInit()
 {
     elementsWithTag.Clear();
     base.OnPrefabInit();
     ConsumeMouseScroll = true;
     for (int i = 0; i < 3; i++)
     {
         MaterialSelector materialSelector = Util.KInstantiateUI <MaterialSelector>(MaterialSelectorTemplate, base.gameObject, false);
         materialSelector.selectorIndex = i;
         MaterialSelectors.Add(materialSelector);
     }
     MaterialSelectors[0].gameObject.SetActive(true);
     MaterialSelectorTemplate.SetActive(false);
     ResearchRequired.SetActive(false);
     priorityScreen = Util.KInstantiateUI <PriorityScreen>(priorityScreenPrefab.gameObject, priorityScreenParent, false);
     priorityScreen.InstantiateButtons(OnPriorityClicked, true);
     Game.Instance.Subscribe(-107300940, delegate
     {
         RefreshSelectors();
     });
 }
        protected override void OnDragTool(int cell, int distFromOrigin)
        {
            PrioritySetting selectedPriority  = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
            int             prioritiesChanged = 0;

            for (int index = 0; index < 40; ++index)
            {
                GameObject gameObject = Grid.Objects[cell, index];

                if (gameObject != null)
                {
                    if (gameObject.GetComponent <Pickupable>())
                    {
                        ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;

                        while (objectLayerListItem != null)
                        {
                            GameObject currentObject = objectLayerListItem.gameObject;
                            objectLayerListItem = objectLayerListItem.nextItem;

                            if (currentObject != null && !(currentObject.GetComponent <MinionIdentity>() != null && TryPrioritizeGameObject(currentObject, selectedPriority)))
                            {
                                ++prioritiesChanged;
                            }
                        }
                    }

                    else if (TryPrioritizeGameObject(gameObject, selectedPriority))
                    {
                        ++prioritiesChanged;
                    }
                }
            }

            if (prioritiesChanged > 0)
            {
                PriorityScreen.PlayPriorityConfirmSound(selectedPriority);
            }
        }
        public static void Prefix(PriorityScreen __instance, Action <PrioritySetting> on_click, bool playSelectionSound)
        {
            var buttonPrefab   = (PriorityButton)Traverse.Create(__instance).Field("buttonPrefab_basic").GetValue();
            var priorityButton = Util.KInstantiateUI <PriorityButton>(
                buttonPrefab.gameObject,
                buttonPrefab.transform.parent.gameObject
                );

            priorityButton.playSelectionSound = playSelectionSound;
            priorityButton.onClick            = on_click;
            priorityButton.text.text          = "0";
            priorityButton.priority           = new PrioritySetting(
                PriorityZero.PriorityZeroClass,
                PriorityZero.PriorityZeroValue
                );

            priorityButton.tooltip.SetSimpleTooltip(string.Format(UI.PRIORITYSCREEN.BASIC, 0));

            var buttonsField = Traverse.Create(__instance).Field("buttons_basic");
            var buttons      = (List <PriorityButton>)buttonsField.GetValue();

            buttons.Insert(0, priorityButton);
            buttonsField.SetValue(buttons);
        }
Esempio n. 6
0
 private static void Postfix(PriorityScreen __instance)
 {
     __instance.SetScreenPriority(new PrioritySetting(PriorityScreen.PriorityClass.basic, DefaultPriorityState.StateManager.State.DefaultToolPriority), false);
 }