Exemplo n.º 1
0
        private void RefreshCategories()
        {
            foreach (CategorySlot slot in slots)
            {
                slot.Hide();
            }

            PlayerCharacter player = parent_ui.GetPlayer();

            if (player != null)
            {
                int index = 0;
                List <GroupData> groups = player.Crafting.GetCraftGroups();

                foreach (GroupData group in groups)
                {
                    if (index < slots.Length)
                    {
                        CategorySlot     slot  = (CategorySlot)slots[index];
                        List <CraftData> items = CraftData.GetAllCraftableInGroup(parent_ui.GetPlayer(), group);
                        if (items.Count > 0)
                        {
                            slot.SetSlot(group);
                            index++;
                        }
                    }
                }

                CraftSubPanel.Get(GetPlayerID())?.Hide();
            }
        }
Exemplo n.º 2
0
        public override void Hide(bool instant = false)
        {
            base.Hide(instant);

            CancelSelection();
            if (animator != null)
            {
                animator.SetBool("Visible", IsVisible());
            }
            CraftSubPanel.Get(GetPlayerID())?.Hide();
        }
        public void CancelSelection()
        {
            ItemSlotPanel.CancelSelectionAll();
            CraftPanel.Get(player_id)?.CancelSelection();
            CraftSubPanel.Get(player_id)?.CancelSelection();
            ActionSelectorUI.Get(player_id)?.Hide();
            ActionSelector.Get(player_id)?.Hide();

            if (onCancelSelection != null)
            {
                onCancelSelection.Invoke();
            }
        }
        public override void DoAction(PlayerCharacter character, ItemSlot slot)
        {
            foreach (CraftData data in learn_list)
            {
                character.Crafting.LearnCraft(data.id);
            }

            TheAudio.Get().PlaySFX("learn", learn_audio);

            InventoryData inventory = slot.GetInventory();

            if (destroy_on_learn)
            {
                inventory.RemoveItemAt(slot.index, 1);
            }

            CraftSubPanel.Get(character.player_id)?.RefreshCraftPanel();
        }
Exemplo n.º 5
0
        protected override void RefreshPanel()
        {
            base.RefreshPanel();

            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                CraftStation station = player.Crafting.GetCraftStation();
                if (current_staton != station)
                {
                    current_staton = station;
                    RefreshCategories();
                }
            }

            //Gamepad auto controls
            PlayerControls controls    = PlayerControls.Get(GetPlayerID());
            CraftSubPanel  sub_panel   = CraftSubPanel.Get(GetPlayerID());
            UISlotPanel    focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && focus_panel != sub_panel && !TheUI.Get().IsBlockingPanelOpened() &&
                controls.IsGamePad() && player != null && !player.Crafting.IsBuildMode())
            {
                Focus();
                CraftInfoPanel.Get(GetPlayerID())?.Hide();
            }
            if (focus_panel == this)
            {
                selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1);

                UISlot slot = GetSelectSlot();
                if (prev_slot != slot || !sub_panel.IsVisible())
                {
                    OnClick(slot);
                    sub_panel.selection_index = 0;
                    prev_slot = slot;
                }
            }
        }
Exemplo n.º 6
0
        private void OnClick(UISlot uislot)
        {
            if (uislot != null)
            {
                CategorySlot cslot = (CategorySlot)uislot;

                for (int i = 0; i < slots.Length; i++)
                {
                    slots[i].UnselectSlot();
                }

                if (cslot.group == CraftSubPanel.Get(GetPlayerID())?.GetCurrentCategory())
                {
                    CraftSubPanel.Get(GetPlayerID())?.Hide();
                }
                else
                {
                    selected_slot = uislot.index;
                    uislot.SelectSlot();
                    CraftSubPanel.Get(GetPlayerID())?.ShowCategory(cslot.group);
                }
            }
        }
Exemplo n.º 7
0
 public void CancelSubSelection()
 {
     CraftSubPanel.Get(GetPlayerID())?.CancelSelection();
 }
Exemplo n.º 8
0
 private void OnCancel(UISlot slot)
 {
     Toggle();
     CraftSubPanel.Get(GetPlayerID())?.Hide();
     UISlotPanel.UnfocusAll();
 }
Exemplo n.º 9
0
 private void OnAccept(UISlot slot)
 {
     CraftSubPanel.Get(GetPlayerID())?.Focus();
 }