Exemple #1
0
 private void SelectSlot()
 {
     DeselectAllInvSlots();
     _selectedInvSlot = _allInvSlots[_invSlotIndex];
     ToggleInvHint(true);
     ActivateSelectedInvSlotBoarder();
 }
Exemple #2
0
    void AddItem(GameObject itemObj, int itemID, string itemType, string itemDescription, Sprite icon)
    {
        for (int i = 0; i < enabledSlots; i++)
        {
            if (slot[i].GetComponent <InvSlot>().empty)
            {
                InvSlot invSlot = slot[i].GetComponent <InvSlot>();
                itemObj.GetComponent <Item>().pickedUp = true;

                invSlot.item        = itemObj;
                invSlot.icon        = icon;
                invSlot.type        = itemType;
                invSlot.ID          = itemID;
                invSlot.description = itemDescription;

                itemObj.transform.SetParent(slot[i].transform);
                itemObj.SetActive(false);

                invSlot.empty = false;
                invSlot.UpdateSlot();

                return;
            }
        }
    }
Exemple #3
0
        private void choose(InvSlot slot)
        {
            int startIndex = CurrentPage * SpacesPerPage + CurrentChoice;

            MenuManager.Instance.AddMenu(new SellChosenMenu(new List <InvSlot>()
            {
                slot
            }, startIndex, action), true);
        }
    public void AddItemToSlot(Item itemToAdd)
    {
        InvSlot emptySlot = GetEmptySlot();

        if (emptySlot)
        {
            emptySlot.AddItem(itemToAdd);
        }
    }
 public void UnlinkToSlot()
 {
     if (_slot != null)
     {
         _slot.UnregisterAction(UpdateRepresentedItem);
     }
     _slot = null;
     UpdateRepresentedItem();
 }
 public void LinkToSlot(InvSlot slot)
 {
     _slot = slot;
     if (slot != null)
     {
         slot.RegisterAction(UpdateRepresentedItem);
     }
     UpdateRepresentedItem();
 }
        private void choose(InvSlot slot)
        {
            int startIndex = CurrentChoiceTotal;

            MenuManager.Instance.AddMenu(new DepositChosenMenu(new List <InvSlot>()
            {
                slot
            }, startIndex), true);
        }
        private void choose(InvSlot slot)
        {
            int startIndex = CurrentChoiceTotal;

            MenuManager.Instance.RemoveMenu();
            action(new List <InvSlot>()
            {
                slot
            });
        }
Exemple #9
0
        public static void InvSlot_LateUpdate(InvSlot __instance, Text ___itemText)
        {
            CustomItem custom = __instance.item?.GetHook <CustomItem>();

            if (custom != null)
            {
                ___itemText.enabled = true;
                CustomTooltip tooltip = custom.GetCountString();
                ___itemText.text  = tooltip.Text ?? string.Empty;
                ___itemText.color = tooltip.Color ?? Color.white;
            }
        }
Exemple #10
0
    protected void StackOnSlot(InvSlot slot)
    {
        int missing = slot.invItem.item.maxStackCount - slot.invItem.count;

        while (missing > 0 && invItem.count > 0)
        {
            slot.invItem.count++;
            invItem.count--;
            missing--;
        }
        UpdateCount();
        slot.UpdateCount();
    }
Exemple #11
0
    //private int _itemIdCount; // ID that indicated each item's place in the Items List
    //private InvSlotContent _selectedInvSlotContent;
    //private int _wearablesIndex;
    //public List<InvSlotContent> InventoryList = new List<InvSlotContent>();
    //private List<GameObject> _allItems = new List<GameObject>();
    //private List<GameObject> _wearables = new List<GameObject>();

    private void Awake()
    {
        for (int i = 0; i < ItemsContainer.transform.childCount; i++)
        {
            ItemsContainer.transform.GetChild(i).gameObject.AddComponent <InvSlot>();
            _allInvSlots.Add(ItemsContainer.transform.GetChild(i).gameObject.GetComponent <InvSlot>());
        }
        HandEquipment    = _allInvSlots[_allInvSlots.Count - 2];
        BodyEquipment    = _allInvSlots[_allInvSlots.Count - 1];
        _selectedInvSlot = _allInvSlots[_invSlotIndex];
        AddItem(new InvSlotContent(Axe));
        AddItem(new InvSlotContent(PickAxe));
    }
Exemple #12
0
    public override void _Ready()
    {
        invGrid  = (GridContainer)GetNode("inv_grid");
        Tooltip  = (Tooltip)GetNode("tooltip_layer/tooltip_panel");
        invSlots = new InvSlot[20];
        for (int i = 0; i < invSlots.Length; i++)
        {
            invSlots[i]       = new InvSlot();
            invSlots[i].Theme = invGrid.Theme;
            invGrid.AddChild(invSlots[i]);
        }

        Instance = this;
    }
Exemple #13
0
 public void Swap(InvSlot slot)
 {
     if ((slot.invItem.item == null || CheckRestrictions(slot.invItem.item)) && (invItem.item == null || slot.CheckRestrictions(invItem.item)))
     {
         if (slot.invItem.item == invItem.item && slot.invItem.count < slot.invItem.item.maxStackCount)
         {
             StackOnSlot(slot);
         }
         else
         {
             slot.ReplaceItem(this.ReplaceItem(slot.invItem));
         }
     }
 }
Exemple #14
0
    private void SwapItems(InvSlot invSlot, string bodyPart)
    {
        InvSlotContent tempInvSlotContent = invSlot.InvSlotContent;

        invSlot.ResetInvSlot();
        if (bodyPart == "Body")
        {
            AssignBodyEquipment();
        }
        else if (bodyPart == "Hand")
        {
            AssigHandEquipment();
        }
        AddItem(tempInvSlotContent);
    }
Exemple #15
0
    private void UpdateUI()
    {
        Debug.Log("UPDATING UI");

        ClearUI();

        foreach (Item item in inventory)
        {
            GameObject inst = Instantiate(slot_prefab, inv_cont.transform);
            InvSlot    inv  = inst.GetComponent <InvSlot>();
            inv.item      = item;
            inv.icon      = item.icon;
            inv.text.text = item.name;
            inv.inventory = this;
        }
    }
    public void Subscribe(InvSlot slot)
    {
        provider = slot;
        slot.Connect(nameof(InvSlot.OccupantSet), this, nameof(OnOccupantSet));

        if (!(provider.Occupant is null))
        {
            OnOccupantSet((Node)provider.Occupant);
        }

        slot.Connect(nameof(InvSlot.TranslationSet), this, nameof(SetLTranslation));
        //Default position is where it is in this scene.
        //Otherwise, configure ourselves based on the Slot.
        if (provider.Translation.HasValue)
        {
            SetLTranslation(provider.Translation.Value);
        }
        else
        {
            provider.Translation = Translation;
        }
    }
Exemple #17
0
    public InvItem(Item item, int count, InvSlot slot)
    {
        this.Slot        = slot;
        this.Item        = item;
        this.Count       = count;
        this.Texture     = item.GetIcon();
        this.HintTooltip = item.Name;
        this.MarginLeft  = 12;
        this.MarginTop   = 12;

        this.Connect("mouse_entered", this, nameof(OnMouseEntered));
        this.Connect("mouse_exited", this, nameof(OnMouseExited));

        countLabel = new Label();
        countLabel.SetAlign(Label.AlignEnum.Right);
        countLabel.SetValign(Label.VAlign.Bottom);
        countLabel.AnchorRight  = 1;
        countLabel.MarginRight  = 2;
        countLabel.AnchorBottom = 1;
        countLabel.MarginBottom = 2;
        countLabel.AddColorOverride("font_color", new Color(0, 0, 0, 1));
        countLabel.AddFontOverride("font", ResourceLoader.Load("res://assets/ui/small_font.tres") as Font);
        AddChild(countLabel);
    }
Exemple #18
0
        public static void InvSlot_SetColor(InvSlot __instance)
        {
            // set default color
            __instance.toolbarNumText.color = new Color32(255, 237, 0, 255);

            InvItem combiner = __instance.mainGUI.targetItem ?? __instance.database.invInterface.draggedInvItem;

            if (combiner is null)
            {
                return;
            }
            InvItem combinee = __instance.curItemList[__instance.slotNumber];

            CustomItem custom = combiner.GetHook <CustomItem>();

            if (!(custom is IItemCombinable combinable))
            {
                return;
            }

            if (__instance.slotType == "Player" || __instance.slotType == "Toolbar" || __instance.slotType == "Chest" || __instance.slotType == "NPCChest")
            {
                if (combinee.invItemName != null && combiner.itemType == ItemTypes.Combine)
                {
                    if (combiner.CombineItems(combinee, __instance.slotNumber, string.Empty, __instance.agent) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(0, __instance.br, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                        __instance.myImage.sprite  = __instance.invBoxCanUse;
                    }
                    else if ((__instance.slotType != "Toolbar" || __instance.mainGUI.openedInventory) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(__instance.br, 0, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, __instance.fadedItemAlpha);
                        __instance.myImage.sprite  = __instance.invBoxNormal;
                        __instance.toolbarNumTextGo.SetActive(false);
                    }

                    if (__instance.slotType != "NPCChest" && __instance.slotType != "Chest")
                    {
                        CustomTooltip tooltip = combinable.CombineTooltip(combinee);
                        __instance.toolbarNumTextGo.SetActive(true);
                        __instance.toolbarNumText.text  = tooltip.Text ?? string.Empty;
                        __instance.toolbarNumText.color = tooltip.Color ?? new Color32(255, 237, 0, 255);
                    }
                }
                else if (__instance.slotType != "NPCChest" && (combinee.invItemName != null || combiner.itemType != ItemTypes.Combine))
                {
                    __instance.myImage.color = __instance.overSlot
                                                ? (Color) new Color32(0, __instance.br, __instance.br, __instance.standardAlpha)
                                                : (Color) new Color32(__instance.br, __instance.br, __instance.br, __instance.standardAlpha);

                    __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                    __instance.myImage.sprite  = __instance.invBoxNormal;
                    if (__instance.slotType == "Toolbar")
                    {
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                if (__instance.mainGUI.curSelected == __instance.mySelectable && __instance.agent.controllerType != "Keyboard")
                {
                    __instance.invInterface.OnSelectionBox(__instance.slotType, __instance.tr.position);
                }
            }
        }
Exemple #19
0
 public override void OnPointerExit(PointerEventData eventData)
 {
     overSlot = null;
     base.OnPointerExit(eventData);
 }
Exemple #20
0
 public override void OnPointerEnter(PointerEventData eventData)
 {
     overSlot = this;
     base.OnPointerEnter(eventData);
 }
Exemple #21
0
        protected static void InvSlot_SetColor(InvSlot __instance, Text ___itemText)
        {
            __instance.toolbarNumTextGo.SetActive(false);
            InvItem targetItem = __instance.mainGUI.targetItem ?? __instance.database.invInterface.draggedInvItem;

            if (targetItem == null)
            {
                return;
            }
            InvItem thisItem = __instance.curItemList[__instance.slotNumber];

            CustomItem cItem = RogueLibs.Instance.Items.Find(i => i.Id == targetItem.invItemName);

            if (cItem?.CombineTooltip == null)
            {
                return;
            }

            if (targetItem != null && (__instance.slotType == "Player" || __instance.slotType == "Toolbar" || __instance.slotType == "Chest" || __instance.slotType == "NPCChest"))
            {
                if (thisItem.invItemName != null && targetItem.itemType == "Combine")
                {
                    if (targetItem.CombineItems(thisItem, __instance.slotNumber, string.Empty, __instance.agent) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(0, __instance.br, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                        __instance.myImage.sprite  = __instance.invBoxCanUse;

                        if (__instance.slotType != "NPCChest" && __instance.slotType != "Chest")
                        {
                            string result = cItem.CombineTooltip(targetItem, targetItem.agent, thisItem) ?? string.Empty;
                            __instance.toolbarNumTextGo.SetActive(result != string.Empty);
                            __instance.toolbarNumText.text = result;
                        }
                    }
                    else if ((!(__instance.slotType == "Toolbar") || __instance.mainGUI.openedInventory) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(__instance.br, 0, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, __instance.fadedItemAlpha);
                        __instance.myImage.sprite  = __instance.invBoxNormal;
                        ___itemText.color          = __instance.whiteTransparent;
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                else if (__instance.slotType != "NPCChest" && (thisItem.invItemName != null || targetItem.itemType != "Combine"))
                {
                    __instance.myImage.color = __instance.overSlot
                                                ? (Color) new Color32(0, __instance.br, __instance.br, __instance.standardAlpha)
                                                : (Color) new Color32(__instance.br, __instance.br, __instance.br, __instance.standardAlpha);

                    __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                    __instance.myImage.sprite  = __instance.invBoxNormal;
                    if (__instance.slotType == "Toolbar")
                    {
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                if (__instance.mainGUI.curSelected == __instance.mySelectable && __instance.agent.controllerType != "Keyboard")
                {
                    __instance.invInterface.OnSelectionBox(__instance.slotType, __instance.tr.position);
                }
            }
        }