Ejemplo n.º 1
0
    public void EquipItem(EquipArea equipArea, Item 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 != ItemType.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));
            }
        }
    }
Ejemplo n.º 2
0
 public void OnPickUpItemCallBack(EquipArea area, ItemSlot 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);
 }
Ejemplo n.º 3
0
 void ChangeEquipmentDisplay(EquipArea equipArea, Item 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);
             }
         }
     }
 }
Ejemplo n.º 4
0
    public void UnequipWeapon(EquipArea equipArea, Item 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)
            {
                holder.equipDelayTime = item.equipDelayTime;
                //Check if Equip area contains unequipped item
                var containsItem = equipArea.ValidSlots.Find(slot => slot.item == item) != null;
                //Hide or unhide holder and weapon if contains item
                StartCoroutine(UnequipRoutine(holder, containsItem, containsItem, (itemManager.inventory != null && itemManager.inventory.isOpen)));
            }
        }
    }
Ejemplo n.º 5
0
    void CheckTwoHandItem(EquipArea area, ItemSlot 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 EquipSlot);
        }
    }
Ejemplo n.º 6
0
    public void EquipWeapon(EquipArea equipArea, Item item)
    {
        var slotsInArea = equipArea.ValidSlots;

        if (slotsInArea != null && slotsInArea.Count > 0 && holderAreas.ContainsKey(equipArea.equipPointName))
        {
            //Check All Holders to Show
            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)
                {
                    holder.equipDelayTime = equipArea.currentEquipedItem.equipDelayTime;
                    // Unhide Holder and hide Equiped weapon
                    StartCoroutine(EquipRoutine(holder, true, false, (itemManager.inventory != null && itemManager.inventory.isOpen)));
                }
            }
        }
    }
Ejemplo n.º 7
0
 public void UnequipItem(EquipArea equipArea, Item item)
 {
     onUnequipItem.Invoke(equipArea, item);
     ChangeEquipmentDisplay(equipArea, item);
 }
Ejemplo n.º 8
0
 public void EquipItem(EquipArea equipArea, Item item)
 {
     onEquipItem.Invoke(equipArea, item);
     ChangeEquipmentDisplay(equipArea, item, false);
 }
Ejemplo n.º 9
0
 void SelectArea(EquipArea equipArea)
 {
     currentEquipArea = equipArea;
 }
Ejemplo n.º 10
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
            }
        }
    }