Exemplo n.º 1
0
 public void OnSubmit(vItemSlot slot)
 {
     if (onSubmitSlot != null)
     {
         onSubmitSlot(slot);
     }
 }
Exemplo n.º 2
0
        public void OnSelect(vItemSlot slot)
        {
            if (itemtext != null)
            {
                if (slot.item == null)
                {
                    itemtext.text = "";
                }
                else if (slot.item.displayAttributes)
                {
                    text = new StringBuilder();
                    text.Append(slot.item.name + "\n");
                    text.AppendLine(slot.item.description);
                    if (slot.item.attributes != null)
                    {
                        for (int i = 0; i < slot.item.attributes.Count; i++)
                        {
                            var _text = InsertSpaceBeforeUpperCAse(slot.item.attributes[i].name.ToString());
                            text.AppendLine(_text + " : " + slot.item.attributes[i].value.ToString());
                        }
                    }

                    itemtext.text = text.ToString();
                }
            }

            if (onSelectSlot != null)
            {
                onSelectSlot(slot);
            }
        }
Exemplo n.º 3
0
        public void OnPickItem(vItemSlot slot)
        {
            if (onPickUpItemCallBack != null)
            {
                onPickUpItemCallBack(this, slot);
            }

            if (currentSelectedSlot.item != null && slot.item != currentSelectedSlot.item)
            {
                currentSelectedSlot.item.isInEquipArea = false;
                var item = currentSelectedSlot.item;
                if (item == slot.item)
                {
                    lastEquipedItem = item;
                }
                currentSelectedSlot.RemoveItem();
                onUnequipItem.Invoke(this, item);
            }

            if (slot.item != currentSelectedSlot.item)
            {
                currentSelectedSlot.AddItem(slot.item);
                onEquipItem.Invoke(this, currentSelectedSlot.item);
            }
            itemPicker.gameObject.SetActive(false);
        }
Exemplo n.º 4
0
 public void OnDeselect(vItemSlot slot)
 {
     if (equipSlots.Contains(slot as vEquipSlot))
     {
         currentSelectedSlot = null;
     }
 }
Exemplo n.º 5
0
 public void EnableOptions(vItemSlot slot)
 {
     if (slot == null || slot.item == null)
     {
         return;
     }
     useItemButton.interactable = itemsCanBeUsed.Contains(slot.item.type);
 }
Exemplo n.º 6
0
 public void OnSubmitSlot(vItemSlot slot)
 {
     if (itemPicker != null)
     {
         currentSelectedSlot = slot as vEquipSlot;
         itemPicker.gameObject.SetActive(true);
         itemPicker.CreateEquipmentWindow(inventory.items, currentSelectedSlot.itemType, slot.item, OnPickItem);
     }
 }
 public void OnSubmit(vItemSlot slot)
 {
     currentSelectedSlot = slot;
     if (slot.item)
     {
         var rect = slot.GetComponent <RectTransform>();
         optionWindow.transform.position = rect.position;
         optionWindow.gameObject.SetActive(true);
         optionWindow.EnableOptions(slot);
         currentSelectedSlot = slot;
     }
 }
 public void OnPickUpItemCallBack(vEquipArea area, vItemSlot slot)
 {
     for (int i = 0; i < equipAreas.Count; i++)
     {
         var sameSlots = equipAreas[i].equipSlots.FindAll(slotInArea => slotInArea != slot && slotInArea.item != null && slotInArea.item == slot.item);
         for (int a = 0; a < sameSlots.Count; a++)
         {
             equipAreas[i].RemoveItem(sameSlots[a]);
         }
     }
     CheckTwoHandItem(area, slot);
 }
        void CheckTwoHandItem(vEquipArea area, vItemSlot slot)
        {
            if (slot.item == null)
            {
                return;
            }
            var opposite = equipAreas.Find(_area => _area != null && area.equipPointName.Equals("LeftArm") && _area.currentEquipedItem != null);

            //var RightEquipmentController = changeEquipmentControllers.Find(equipCtrl => equipCtrl.equipArea != null && equipCtrl.equipArea.equipPointName.Equals("RightArm"));
            if (area.equipPointName.Equals("LeftArm"))
            {
                opposite = equipAreas.Find(_area => _area != null && area.equipPointName.Equals("RightArm") && _area.currentEquipedItem != null);
            }
            else if (!area.equipPointName.Equals("RightArm"))
            {
                return;
            }
            if (opposite != null && (slot.item.twoHandWeapon || opposite.currentEquipedItem.twoHandWeapon))
            {
                opposite.onUnequipItem.Invoke(opposite, slot.item);
                opposite.RemoveItem(slot as vEquipSlot);
            }
        }
Exemplo n.º 10
0
        public void OnSelectSlot(vItemSlot slot)
        {
            if (equipSlots.Contains(slot as vEquipSlot))
            {
                currentSelectedSlot = slot as vEquipSlot;
            }
            else
            {
                currentSelectedSlot = null;
            }

            onSelectEquipArea.Invoke(this);

            if (itemtext != null)
            {
                if (slot.item == null)
                {
                    itemtext.text = "";
                }
                else
                {
                    text = new StringBuilder();
                    text.Append(slot.item.name + "\n");
                    text.AppendLine(slot.item.description);
                    if (slot.item.attributes != null)
                    {
                        for (int i = 0; i < slot.item.attributes.Count; i++)
                        {
                            var _text = InsertSpaceBeforeUpperCAse(slot.item.attributes[i].name.ToString());
                            text.AppendLine(_text + " : " + slot.item.attributes[i].value.ToString());
                        }
                    }

                    itemtext.text = text.ToString();
                }
            }
        }
 public void OnSelectSlot(vItemSlot slot)
 {
     currentSelectedSlot = slot;
 }
Exemplo n.º 12
0
        public void CreateEquipmentWindow(List <vItem> items, OnSubmitSlot onPickUpItemCallBack = null, OnSelectSlot onSelectSlotCallBack = null, bool destroyAdictionSlots = true)
        {
            if (items.Count == 0)
            {
                if (itemtext)
                {
                    itemtext.text = "";
                }
                if (slots.Count > 0 && destroyAdictionSlots)
                {
                    for (int i = 0; i < slots.Count; i++)
                    {
                        Destroy(slots[i].gameObject);
                    }
                    slots.Clear();
                }
                return;
            }

            bool selecItem = false;

            onSubmitSlot = onPickUpItemCallBack;
            onSelectSlot = onSelectSlotCallBack;
            if (slots == null)
            {
                slots = new List <vItemSlot>();
            }
            var count = slots.Count;

            if (count < items.Count)
            {
                for (int i = count; i < items.Count; i++)
                {
                    var slot = Instantiate(slotPrefab) as vItemSlot;
                    slots.Add(slot);
                }
            }
            else if (count > items.Count)
            {
                for (int i = count - 1; i > items.Count - 1; i--)
                {
                    Destroy(slots[slots.Count - 1].gameObject);
                    slots.RemoveAt(slots.Count - 1);
                }
            }
            count = slots.Count;
            for (int i = 0; i < items.Count; i++)
            {
                vItemSlot slot = null;
                if (i < items.Count)
                {
                    slot = slots[i];
                    slot.AddItem(items[i]);
                    slot.CheckItem(items[i].isInEquipArea);
                    slot.onSubmitSlotCallBack = OnSubmit;
                    slot.onSelectSlotCallBack = OnSelect;
                    var rectTranform = slot.GetComponent <RectTransform>();
                    rectTranform.SetParent(contentWindow);
                    rectTranform.localPosition = Vector3.zero;

                    rectTranform.localScale = Vector3.one;
                    if (currentItem != null && currentItem == items[i])
                    {
                        selecItem = true;
                        SetSelectable(slot.gameObject);
                    }
                }
            }

            if (slots.Count > 0 && !selecItem)
            {
                StartCoroutine(SetSelectableHandle(slots[0].gameObject));
            }

            if (onCompleteSlotListCallBack != null)
            {
                onCompleteSlotListCallBack(slots);
            }
        }
Exemplo n.º 13
0
 public void OnDeselect(vItemSlot slot)
 {
     currentSelectedSlot = null;
 }