Esempio n. 1
0
 private void SetParent()
 {
     if (base.state.Entity)
     {
         CoopPlayerRemoteSetup component = base.state.Entity.GetComponent <CoopPlayerRemoteSetup>();
         Item.EquipmentSlot    slot      = this._slot;
         Transform             transform;
         if (slot != Item.EquipmentSlot.RightHand)
         {
             if (slot != Item.EquipmentSlot.LeftHand)
             {
                 transform = null;
             }
             else
             {
                 transform = component.leftHand.ActiveItem;
             }
         }
         else
         {
             transform = component.rightHand.ActiveItem;
         }
         if (transform)
         {
             base.transform.parent        = transform;
             base.transform.localPosition = base.state.Position;
             base.transform.localRotation = base.state.Rotation;
         }
     }
     else
     {
         base.transform.parent = null;
     }
 }
Esempio n. 2
0
    //Right clicks
    public void FastEquip(Item newItem)
    {
        //get the slot this wants to go in
        Item.EquipmentSlot slot = newItem.myEquipSlot;

        inv.AddItem(currentEquipment[slot]); //add old item to inventory
        Equip(newItem);                      //save over old item
        inv.Remove(newItem);                 //remove from inventory
    }
Esempio n. 3
0
    public InventoryItemObject Unequip(Item.EquipmentSlot eSlot, ref Attributes playerAttributes)
    {
        InventoryItemObject oldItem = null;// new InventoryItemObject();

        // retrieve the slot that takes that type of item
        int slot = Convert.ToInt32(eSlot);

        if (_equipmentSlots[slot].GetItem() != null)
        {
            oldItem = _equipmentSlots[slot]?.GetInventoryItemObject();
        }

        // retrieve the old stats and remove them from the attributes
        if (_equipmentSlots[slot].GetItem()?.GetItemType() == Item.ItemType.Weapon)
        {
            foreach (Weapon.Stat stat in (_equipmentSlots[slot].GetItem() as Weapon).GetStats())
            {
                if (stat._isBasicStat)
                {
                    string enumString             = stat._stat.ToString();
                    Attributes.StatTypes statType = (Attributes.StatTypes)Enum.Parse(typeof(Attributes.StatTypes), enumString);
                    playerAttributes.DecrementStat(new Attributes.Stat(statType, (int)stat._value));
                }
                else
                {
                    Weapon.Stat weapStat = playerAttributes.GetWeaponStats().Find(x => x._stat == stat._stat);
                    weapStat -= stat;
                    playerAttributes.SetWeaponStat(weapStat);
                }
            }

            _equipmentSlots[slot].SetItemNull();
        }
        else if (_equipmentSlots[slot].GetItem()?.GetItemType() == Item.ItemType.Armor)
        {
            foreach (Armor.Stat stat in (_equipmentSlots[slot].GetItem() as Armor).GetStats())
            {
                if (stat._isBasicStat)
                {
                    string enumString             = stat._stat.ToString();
                    Attributes.StatTypes statType = (Attributes.StatTypes)Enum.Parse(typeof(Attributes.StatTypes), enumString);
                    playerAttributes.DecrementStat(new Attributes.Stat(statType, (int)stat._value));
                }
                else
                {
                    Armor.Stat armorStat = playerAttributes.GetArmorStats().Find(x => x._stat == stat._stat);
                    armorStat -= stat;
                    playerAttributes.SetArmorStat(armorStat);
                }
            }

            _equipmentSlots[slot].SetItemNull();
        }


        return(oldItem);
    }
Esempio n. 4
0
 public void UpdateUI(Item newItem, Item.EquipmentSlot slot)
 {
     if (newItem == null) //if new item is null then we are just equipping
     {
         equipSlots[slot].ClearSlot();
     }
     else
     {
         equipSlots[slot].AddEquipment(newItem);
     }
 }
Esempio n. 5
0
 bool CheckEquipSlot(Item.EquipmentSlot mouseItemEquipSlot, EquipSlot slot)
 {
     if (mouseItemEquipSlot != slot.slotType)
     {
         Debug.Log("WRONG EQUIP SLOT: " + slot.slotType + " looking for " + mouseItemEquipSlot);
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 6
0
 public void StripEquipment(Item.EquipmentSlot slot)
 {
     for (int i = 0; i < bodyParts.Count; i++)
     {
         if (bodyParts[i].weaponSlot == slot)
         {
             bodyParts[i].StripEquipment("Weapon");
         }
         else if (bodyParts[i].armorSlot == slot)
         {
             bodyParts[i].StripEquipment("Armor");
         }
     }
 }
Esempio n. 7
0
    public void Equip(Item newItem)
    {
        Item.EquipmentSlot slot = newItem.myEquipSlot;
        if (slot == Item.EquipmentSlot.Head)
        {
            Debug.LogError("Should not be equipping to head " + newItem.name);
        }

        currentEquipment[slot] = newItem;
        if (UI == null)
        {
            UI = CanvasUI.instance.GetComponent <EquipUI>();
        }
        UI.UpdateUI(newItem, newItem.myEquipSlot);
        SendToBodyPart(newItem);
    }
Esempio n. 8
0
 private void SetParent()
 {
     if (base.state.TargetPlayer)
     {
         CoopPlayerRemoteSetup component = base.state.TargetPlayer.GetComponent <CoopPlayerRemoteSetup>();
         Item.EquipmentSlot    slot      = this._slot;
         Transform             transform;
         if (slot != Item.EquipmentSlot.RightHand)
         {
             if (slot != Item.EquipmentSlot.LeftHand)
             {
                 transform = null;
             }
             else
             {
                 transform = component.leftHand.ActiveItem;
             }
         }
         else
         {
             coopClientHeldFirePos componentInChildren = component.rightHand.ActiveItem.GetComponentInChildren <coopClientHeldFirePos>();
             if (componentInChildren)
             {
                 transform = componentInChildren.transform;
             }
             else
             {
                 transform = component.rightHand.ActiveItem;
             }
         }
         if (base.entity && base.entity.isAttached && transform)
         {
             base.transform.parent        = transform;
             base.transform.localPosition = base.state.Position;
             base.transform.localRotation = base.state.Rotation;
         }
     }
     else
     {
         base.transform.parent = null;
     }
 }
Esempio n. 9
0
    public Item GetItem(Item.EquipmentSlot slot)
    {
        foreach (InventoryEquipmentSlot s in _equipmentSlots)
        {
            Item item = s.GetItem();
            if (item is Weapon)
            {
                if (slot == Item.EquipmentSlot.Weapon)
                {
                    return(item);
                }
            }
            if (((Armor)item)?.GetEquipmentSlot() == slot)
            {
                return(item);
            }
        }

        return(null);
    }
Esempio n. 10
0
 public void Unequip(Item.EquipmentSlot slot)
 {
     _equipment.Unequip(slot, ref _attributes);
     UpdateStatDisplay();
 }
Esempio n. 11
0
 public Item EquipmentFromSlot(Item.EquipmentSlot slot)
 {
     return(currentEquipment[slot]); //may be null, but I may not need this method?
 }
Esempio n. 12
0
 //may need to check for naked unequip
 public void Unequip(Item.EquipmentSlot slot)
 {
     currentEquipment[slot] = null;
     myBody.StripEquipment(slot);
     UI.UpdateUI(null, slot);
 }