IEnumerator UnequipItemRoutine(EquipPoint equipPoint, vItem item) { if (!inEquip) { inventory.canEquip = false; inEquip = true; if (equipPoint != null && equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null) { var equipment = equipPoint.equipmentReference.equipedObject.GetComponent <vIEquipment>(); if (equipment != null) { equipment.OnUnequip(item); } if (!inventory.isOpen) { while (equipTimer > 0) { equipTimer -= Time.deltaTime; yield return(new WaitForEndOfFrame()); } } Destroy(equipPoint.equipmentReference.equipedObject); equipPoint.equipmentReference.item = null; } inEquip = false; inventory.canEquip = true; } }
void CheckTwoHandItem(EquipPoint equipPoint, vItem item) { if (item == null) { return; } var opposite = equipPoints.Find(ePoint => ePoint.area != null && ePoint.equipPointName.Equals("LeftArm") && ePoint.area.currentEquipedItem != null); if (equipPoint.equipPointName.Equals("LeftArm")) { opposite = equipPoints.Find(ePoint => ePoint.area != null && ePoint.equipPointName.Equals("RightArm") && ePoint.area.currentEquipedItem != null); } else if (!equipPoint.equipPointName.Equals("RightArm")) { return; } if (opposite != null && (item.twoHandWeapon || opposite.area.currentEquipedItem.twoHandWeapon)) { opposite.area.RemoveCurrentItem(); } }
IEnumerator EquipItemRoutine(EquipPoint equipPoint, vItem item) { if (!inEquip) { inventory.canEquip = false; inEquip = true; if (equipPoint != null) { if (item.originalObject) { if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null) { var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent <vIEquipment>(); if (_equipment != null) { _equipment.OnUnequip(equipPoint.equipmentReference.item); } Destroy(equipPoint.equipmentReference.equipedObject); } if (!inventory.isOpen) { while (equipTimer > 0) { if (item == null) { break; } yield return(null); equipTimer -= Time.deltaTime; } } var point = equipPoint.handler.customHandlers.Find(p => p.name == item.customEquipPoint); var equipTransform = point != null ? point : equipPoint.handler.defaultHandler; var equipedObject = Instantiate(item.originalObject, equipTransform.position, equipTransform.rotation) as GameObject; equipedObject.transform.parent = equipTransform; if (equipPoint.equipPointName.Contains("Left")) { var scale = equipedObject.transform.localScale; scale.x *= -1; equipedObject.transform.localScale = scale; } equipPoint.equipmentReference.item = item; equipPoint.equipmentReference.equipedObject = equipedObject; var equipment = equipedObject.GetComponent <vIEquipment>(); if (equipment != null) { equipment.OnEquip(item); } equipPoint.onInstantiateEquiment.Invoke(equipedObject); } else if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null) { var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent <vIEquipment>(); if (_equipment != null) { _equipment.OnUnequip(equipPoint.equipmentReference.item); } Destroy(equipPoint.equipmentReference.equipedObject); equipPoint.equipmentReference.item = null; } } inEquip = false; inventory.canEquip = true; if (equipPoint != null) { CheckTwoHandItem(equipPoint, item); } } }