Пример #1
0
        public virtual void EquipItem(vEquipArea equipArea, vItem item)
        {
            onEquipItem.Invoke(equipArea, item);
            if (item != equipArea.currentEquipedItem)
            {
                return;
            }

            var equipPoint = equipPoints.Find(ep => ep.equipPointName == equipArea.equipPointName);

            if (equipPoint != null && item != null && equipPoint.equipmentReference.item != item)
            {
                equipTimer = item.enableDelayTime;

                var type = item.type;
                if (type != vItemType.Consumable)
                {
                    if (!inventory.isOpen)
                    {
                        animator.SetBool("FlipEquip", equipArea.equipPointName.Contains("Left"));
                        animator.CrossFade(item.EnableAnim, 0.25f);
                    }
                    equipPoint.area = equipArea;
                    StartCoroutine(EquipItemRoutine(equipPoint, item));
                }
            }
        }
        public void UnequipWeapon(vEquipArea equipArea, vItem item)
        {
            if (holders.Length == 0 || item == null)
            {
                return;
            }
            if ((itemManager.inventory != null) && holderAreas.ContainsKey(equipArea.equipPointName))
            {
                var holder = holderAreas[equipArea.equipPointName].Find(h => item.id == h.itemID);
                if (holder)
                {
                    // Check if EquipArea contains unequipped item
                    var containsItem = equipArea.ValidSlots.Find(slot => slot.item == item) != null;
                    if (debugMode)
                    {
                        Debug.Log(containsItem ? "Hold: " + item.name : "Hide :" + item.name + " Holder");
                    }

                    // Hide or unhide holder and weapon if contains item
                    if (containsItem)
                    {
                        //var immediate = itemManager.playItemAnimation && !string.IsNullOrEmpty(item.DisableAnim);
                        holder.SetActiveHolder(containsItem);
                        holder.SetActiveWeapon(containsItem);
                        //StartCoroutine(UnequipRoutine(item.disableDelayTime, immediate,
                        //       () => { holder.SetActiveHolder(containsItem); }, () => { holder.SetActiveWeapon(containsItem); }, item.name));
                    }
                    else
                    {
                        holder.SetActiveHolder(false);
                        holder.SetActiveWeapon(false);
                    }
                }
            }
        }
Пример #3
0
        public virtual void EquipItem(vEquipArea equipArea, vItem item)
        {
            onEquipItem.Invoke(equipArea, item);
            if (item != equipArea.currentEquipedItem)
            {
                return;
            }

            var equipPoint = equipPoints.Find(ep => ep.equipPointName == equipArea.equipPointName);

            if (equipPoint != null && item != null && equipPoint.equipmentReference.item != item)
            {
                equipTimer = item.equipDelayTime;

                var type = item.type;
                if (type != vItemType.Consumable)
                {
                    if (!inventory.isOpen)
                    {
                        animator.SetInteger("EquipItemID", equipArea.equipPointName.Contains("Right") ? item.EquipID : -item.EquipID);
                        animator.SetTrigger("EquipItem");
                    }
                    equipPoint.area = equipArea;
                    StartCoroutine(EquipItemRoutine(equipPoint, item));
                }
            }
        }
Пример #4
0
        public virtual void CloseInventory()
        {
            if(isOpen)
            {
               if(! firstWindow.gameObject.activeSelf)
                {
                    for (int i = windows.Count - 1; i > 0; i--)
                    {
                        if (windows[i].ContainsPop_up())
                            windows[i].RemoveLastPop_up();
                        windows[i].gameObject.SetActive(false);

                    }
                }
            
                windows.Clear();
                currentEquipArea = null;
                currentWindow = null;
                firstWindow.gameObject.SetActive(false);
                isOpen = false;
                onOpenCloseInventory.Invoke(false);
                Time.timeScale = originalTimeScale;
                if (updatedTimeScale)
                    updatedTimeScale = false;
            }
         
        }
Пример #5
0
 private void CheckIsEquipped(vEquipArea arg0, vItem arg1)
 {
     for (int i = 0; i < itemChecks.Count; i++)
     {
         CheckEvent check = itemChecks[i];
         CheckItem(check);
     }
 }
        public void EquipWeapon(vEquipArea equipArea, vItem item)
        {
            if (item == null)
            {
                return;
            }
            var slotsInArea = equipArea.ValidSlots;

            if (slotsInArea != null && slotsInArea.Count > 0 && holderAreas.ContainsKey(equipArea.equipPointName))
            {
                // Check All Holders to Display
                for (int i = 0; i < slotsInArea.Count; i++)
                {
                    if (slotsInArea[i].item != null)
                    {
                        var holder = holderAreas[equipArea.equipPointName].Find(h => slotsInArea[i].item && slotsInArea[i].item.id == h.itemID &&
                                                                                ((equipArea.currentEquippedItem != null &&
                                                                                  equipArea.currentEquippedItem != item &&
                                                                                  equipArea.currentEquippedItem != slotsInArea[i].item &&
                                                                                  equipArea.currentEquippedItem.id != item.id) || equipArea.currentEquippedItem == null));

                        if (holder)
                        {
                            holder.SetActiveHolder(true);
                            holder.SetActiveWeapon(true);
                            if (debugMode)
                            {
                                Debug.Log("Hold: " + slotsInArea[i].item);
                            }
                        }
                    }
                }
                // Check Current Item to Equip with time
                if (equipArea.currentEquippedItem != null && equipArea.currentEquippedItem == item)
                {
                    var holder = holderAreas[equipArea.equipPointName].Find(h => h.itemID == equipArea.currentEquippedItem.id);
                    if (holder)
                    {
                        // Unhide Holder and hide Equiped weapon
                        var immediate = (equipArea.currentEquippedItem != item || itemManager.playItemAnimation) &&
                                        !string.IsNullOrEmpty(equipArea.currentEquippedItem.EnableAnim);

                        if (debugMode)
                        {
                            Debug.Log("UnHold: " + item.name);
                        }
                        holder.SetActiveHolder(true);
                        holder.SetActiveWeapon(false);
                        //StartCoroutine(EquipRoutine(equipArea.currentEquipedItem.enableDelayTime, immediate,
                        //   () => { holder.SetActiveHolder(true); }, () => { holder.SetActiveWeapon(false); }, item.name));
                    }
                }
            }
        }
Пример #7
0
 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].UnequipItem(sameSlots[a]);
         }
     }
     CheckTwoHandItem(area, slot);
 }
Пример #8
0
 private void CheckIsEquipped(vEquipArea arg0, vItem arg1)
 {
     for (int i = 0; i < itemIDEvents.Count; i++)
     {
         CheckItemIDEvent check = itemIDEvents[i];
         CheckItemID(check);
     }
     for (int i = 0; i < itemTypeEvents.Count; i++)
     {
         CheckItemTypeEvent check = itemTypeEvents[i];
         CheckItemType(check);
     }
 }
        /// <summary>
        /// Load inventory items and occupied equipSlots
        /// </summary>
        /// <param name="itemManager"></param>
        public static void LoadInventory(this vItemManager itemManager)
        {
            string json = LoadInventoryJasonText();

            if (!string.IsNullOrEmpty(json))
            {
                InventoryData data = new InventoryData();
                JsonUtility.FromJsonOverwrite(json, data);
                itemManager.items = data.GetItems(itemManager.itemListData);
                vEquipArea[] equipAreas = itemManager.inventory.equipAreas;

                for (int i = 0; i < equipAreas.Length; i++)
                {
                    if (i < data.equipAreas.Count)
                    {
                        vEquipArea    area     = equipAreas[i];
                        EquipAreaData areaData = data.equipAreas[i];

                        area.indexOfEquippedItem = areaData.indexOfSelectedSlot;

                        for (int e = 0; e < equipAreas[i].equipSlots.Count; e++)
                        {
                            if (e < areaData.slotsData.Count)
                            {
                                SlotData   slotData = areaData.slotsData[e];
                                vEquipSlot slot     = equipAreas[i].equipSlots[e];
                                itemManager.temporarilyIgnoreItemAnimation = true;
                                if (slotData.hasItem)
                                {
                                    area.AddItemToEquipSlot(e, itemManager.items[slotData.indexOfItem]);
                                }
                                else
                                {
                                    area.RemoveItemOfEquipSlot(e);
                                }
                            }
                        }
                    }
                }
            }
            itemManager.inventory.UpdateInventory();
            itemManager.temporarilyIgnoreItemAnimation = false;
            itemManager.onLoadItems.Invoke();
        }
        public void UnequipWeapon(vEquipArea equipArea, vItem item)
        {
            if (holders.Length == 0 || item == null)
            {
                return;
            }

            if ((itemManager.inventory != null) && holderAreas.ContainsKey(equipArea.equipPointName))
            {
                var holder = holderAreas[equipArea.equipPointName].Find(h => item.id == h.itemID);
                if (holder)
                {
                    // Check if EquipArea contains unequipped item
                    var containsItem = equipArea.ValidSlots.Find(slot => slot.item == item) != null;
                    // Hide or unhide holder and weapon if contains item
                    StartCoroutine(UnequipRoutine(item.unequipDelayTime, (itemManager.inventory != null && itemManager.inventory.isOpen),
                                                  () => { holder.SetActiveHolder(containsItem); }, () => { holder.SetActiveWeapon(containsItem); }));
                }
            }
        }
Пример #11
0
 void ChangeEquipmentDisplay(vEquipArea equipArea, vItem item, bool removeItem = true)
 {
     if (changeEquipmentControllers.Count > 0)
     {
         var changeEquipControl = changeEquipmentControllers.Find(changeEquip => changeEquip.equipArea != null && changeEquip.equipArea.equipPointName == equipArea.equipPointName && changeEquip.display != null);
         if (changeEquipControl != null)
         {
             if (removeItem && changeEquipControl.display.item == item)
             {
                 changeEquipControl.display.RemoveItem();
                 //changeEquipControl.display.ItemIdentifier();
             }
             else if (equipArea.currentEquipedItem == item)
             {
                 changeEquipControl.display.AddItem(item);
                 changeEquipControl.display.ItemIdentifier(changeEquipControl.equipArea.indexOfEquipedItem + 1, true);
             }
         }
     }
 }
Пример #12
0
        public virtual void UnequipItem(vEquipArea equipArea, vItem item)
        {
            onUnequipItem.Invoke(equipArea, item);

            //if (item != equipArea.lastEquipedItem) return;
            var equipPoint = equipPoints.Find(ep => ep.equipPointName == equipArea.equipPointName && ep.equipmentReference.item != null && ep.equipmentReference.item == item);

            if (equipPoint != null && item != null)
            {
                equipTimer = item.disableDelayTime;
                var type = item.type;
                if (type != vItemType.Consumable)
                {
                    if (!inventory.isOpen && !inEquip && equipPoint.equipmentReference.equipedObject.activeInHierarchy)
                    {
                        animator.SetBool("FlipEquip", equipArea.equipPointName.Contains("Left"));
                        animator.CrossFade(item.DisableAnim, 0.25f);
                    }
                    StartCoroutine(UnequipItemRoutine(equipPoint, item));
                }
            }
        }
Пример #13
0
        public virtual void UnequipItem(vEquipArea equipArea, vItem item)
        {
            onUnequipItem.Invoke(equipArea, item);

            //if (item != equipArea.lastEquipedItem) return;
            var equipPoint = equipPoints.Find(ep => ep.equipPointName == equipArea.equipPointName && ep.equipmentReference.item != null && ep.equipmentReference.item == item);

            if (equipPoint != null && item != null)
            {
                equipTimer = item.unequipDelayTime;
                var type = item.type;
                if (type != vItemType.Consumable)
                {
                    if (!inventory.isOpen && !inEquip && equipPoint.equipmentReference.equipedObject.activeInHierarchy)
                    {
                        animator.SetInteger("EquipItemID", equipArea.equipPointName.Contains("Right") ? item.EquipID : -item.EquipID);
                        animator.SetTrigger("EquipItem");
                    }
                    StartCoroutine(UnequipItemRoutine(equipPoint, item));
                }
            }
        }
Пример #14
0
        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.UnequipItem(slot as vEquipSlot);
            }
        }
        public void EquipWeapon(vEquipArea equipArea, vItem item)
        {
            var slotsInArea = equipArea.ValidSlots;

            if (slotsInArea != null && slotsInArea.Count > 0 && holderAreas.ContainsKey(equipArea.equipPointName))
            {
                // Check All Holders to Display
                for (int i = 0; i < slotsInArea.Count; i++)
                {
                    if (slotsInArea[i].item != null)
                    {
                        var holder = holderAreas[equipArea.equipPointName].Find(h => slotsInArea[i].item && slotsInArea[i].item.id == h.itemID &&
                                                                                ((equipArea.currentEquipedItem &&
                                                                                  equipArea.currentEquipedItem != item &&
                                                                                  equipArea.currentEquipedItem != slotsInArea[i].item &&
                                                                                  equipArea.currentEquipedItem.id != item.id) || !equipArea.currentEquipedItem));

                        if (holder)
                        {
                            holder.SetActiveHolder(true);
                            holder.SetActiveWeapon(true);
                        }
                    }
                }
                // Check Current Item to Equip with time
                if (equipArea.currentEquipedItem != null)
                {
                    var holder = holderAreas[equipArea.equipPointName].Find(h => h.itemID == equipArea.currentEquipedItem.id);
                    if (holder)
                    {
                        // Unhide Holder and hide Equiped weapon
                        StartCoroutine(EquipRoutine(equipArea.currentEquipedItem.equipDelayTime, (itemManager.inventory != null && itemManager.inventory.isOpen),
                                                    () => { holder.SetActiveHolder(true); }, () => { holder.SetActiveWeapon(false); }));
                    }
                }
            }
        }
Пример #16
0
 public EquipedItemInfo(vItem item, vEquipArea area)
 {
     this.item = item;
     this.area = area;
 }
Пример #17
0
 /// <summary>
 /// Assign the EquipArea of the Slot that you're selected
 /// </summary>
 /// <param name="equipArea"></param>
 protected virtual void SetCurrentSelectedArea(vEquipArea equipArea)
 {
     currentEquipArea = equipArea;
 }
Пример #18
0
 /// <summary>
 /// Event to trigger when you equip an Item
 /// </summary>
 /// <param name="equipArea"></param>
 /// <param name="item"></param>
 public virtual void OnEquipItem(vEquipArea equipArea, vItem item)
 {
     onEquipItem.Invoke(equipArea, item);
     ChangeEquipmentDisplay(equipArea, item, false);
 }
Пример #19
0
 public void UnequipItem(vEquipArea equipArea, vItem item)
 {
     onUnequipItem.Invoke(equipArea, item);
     ChangeEquipmentDisplay(equipArea, item);
 }
Пример #20
0
 void SelectArea(vEquipArea equipArea)
 {
     currentEquipArea = equipArea;
 }
Пример #21
0
        public virtual void ControlWindowsInput()
        {
            // enable first window
            if ((windows.Count == 0 || windows[windows.Count - 1] == firstWindow))
            {
                if (!firstWindow.gameObject.activeSelf && openInventory.GetButtonDown() && canEquip)
                {
                    firstWindow.gameObject.SetActive(true);
                    isOpen = true;
                    onOpenCloseInventory.Invoke(true);

                    if (!updatedTimeScale)
                    {
                        updatedTimeScale  = true;
                        originalTimeScale = Time.timeScale;
                    }
                    Time.timeScale = timeScaleWhileIsOpen;
                }

                else if (firstWindow.gameObject.activeSelf && (openInventory.GetButtonDown() || cancel.GetButtonDown()))
                {
                    currentEquipArea = null;
                    firstWindow.gameObject.SetActive(false);
                    isOpen = false;
                    onOpenCloseInventory.Invoke(false);

                    Time.timeScale = originalTimeScale;
                    if (updatedTimeScale)
                    {
                        updatedTimeScale = false;
                    }
                }
            }
            if (!isOpen)
            {
                return;
            }
            // disable current window
            if ((windows.Count > 0 && windows[windows.Count - 1] != firstWindow) && cancel.GetButtonDown())
            {
                currentEquipArea = null;
                if (windows[windows.Count - 1].ContainsPop_up())
                {
                    windows[windows.Count - 1].RemoveLastPop_up();
                    return;
                }
                else
                {
                    windows[windows.Count - 1].gameObject.SetActive(false);
                    windows.RemoveAt(windows.Count - 1);// remove last window of the window list
                    if (windows.Count > 0)
                    {
                        windows[windows.Count - 1].gameObject.SetActive(true);
                        currentWindow = windows[windows.Count - 1];
                    }
                    else
                    {
                        currentWindow = null; // clear currentWindow if  window list count == 0
                    }
                }
            }
            // check if currenWindow  that was closed
            if (currentWindow != null && !currentWindow.gameObject.activeSelf)
            {
                // remove currentWindow of the window list
                if (windows.Contains(currentWindow))
                {
                    windows.Remove(currentWindow);
                }
                // set currentWindow if window list have more windows
                if (windows.Count > 0)
                {
                    windows[windows.Count - 1].gameObject.SetActive(true);
                    currentWindow = windows[windows.Count - 1];
                }
                else
                {
                    currentWindow = null;// clear currentWindow if  window list count == 0
                }
            }
        }
Пример #22
0
        public virtual void ControlWindowsInput()
        {
            // enable first window
            if ((windows.Count == 0 || windows[windows.Count - 1] == firstWindow))
            {
                if (!firstWindow.gameObject.activeSelf && openInventory.GetButtonDown() && canEquip)
                {                  
                    OpenInventory();
                    return;
                }

                else if (firstWindow.gameObject.activeSelf && (openInventory.GetButtonDown() || cancel.GetButtonDown()))
                {                   
                    CloseInventory();
                    return;
                }
            }
            if (!isOpen) return;
            // disable current window
            if(openInventory.GetButtonDown())
            {              
                CloseInventory();
                return;
            }
            if ((windows.Count > 0 && windows[windows.Count - 1] != firstWindow) && cancel.GetButtonDown())
            {
                currentEquipArea = null;
                if (windows[windows.Count - 1].ContainsPop_up())
                {
                    windows[windows.Count - 1].RemoveLastPop_up();
                    return;
                }
                else
                {
                    windows[windows.Count - 1].gameObject.SetActive(false);
                    windows.RemoveAt(windows.Count - 1);// remove last window of the window list
                    if (windows.Count > 0)
                    {
                        windows[windows.Count - 1].gameObject.SetActive(true);
                        currentWindow = windows[windows.Count - 1];
                    }
                    else
                        currentWindow = null; // clear currentWindow if  window list count == 0        
                }
            }
            // check if currenWindow  that was closed
            if (currentWindow != null && !currentWindow.gameObject.activeSelf)
            {
                // remove currentWindow of the window list
                if (windows.Contains(currentWindow))
                    windows.Remove(currentWindow);
                // set currentWindow if window list have more windows
                if (windows.Count > 0)
                {
                    windows[windows.Count - 1].gameObject.SetActive(true);
                    currentWindow = windows[windows.Count - 1];
                }
                else
                    currentWindow = null;// clear currentWindow if  window list count == 0        
            }
        }
 public void OnSelectArea(vEquipArea area)
 {
     equipArea = area;
 }