public void LoadCurrentItemOnEquipmentSlot() { if (currentItem == null) { return; } if (currentItem is Items.ClothItem) { currentItem.isEquiped = true; UI_Slot slot = GetEquipmentSlot(currentItem.bodyPart); if (slot.itemInstance != null) { SetItemOnStoredSlot(slot.itemInstance); } slot.LoadItem(currentItem); StoreIdOnResources(currentItem, slot); LoadItemsOnCharacter(); currentItem = null; } else { //we droped a weapon on our character } }
UI_Slot GetEquipmentSlot(Items.BodyPart bodyPart) { UI_Slot result = null; equipmentSlots.TryGetValue(bodyPart, out result); return(result); }
public override void OnClick(UI_Slot slot, UI_InventoryManager invManager) { if (slot.itemInstance != null) { invManager.SetCurrentItem(slot.itemInstance, slot); slot.UnloadItem(); } }
public void SetCurrentItem(Items.Item targetItem, UI_Slot slot) { storedSlot = slot; currentItem = targetItem; if (currentItem != null) { mouseIcon.sprite = currentItem.ui_info.icon; mouseIcon.enabled = true; } }
public override void OnDropItem(UI_Slot slot, Item item, UI_InventoryManager invManager) { Item previousItem = slot.itemInstance; slot.LoadItem(item); item.isEquiped = false; invManager.ClearCurrentItem(); invManager.UnEquipFromStoredSlot(); if (previousItem != null) { invManager.SetItemOnStoredSlot(previousItem); } }
public void LoadItemOnTargetEquipmentSlot(Items.Item item, bool isLeft) { item.isEquiped = true; UI_Slot slot = null; if (item is Items.Weapon) { slot = GetWeaponEquipmentSlot(isLeft); } else { slot = GetEquipmentSlot(item.bodyPart); } slot.LoadItem(item); StoreIdOnResources(item, slot); }
public override void OnDropItem(UI_Slot slot, Item item, UI_InventoryManager invManager) { if (item.bodyPart == slot.bodyPart) { Item previousItem = slot.itemInstance; slot.LoadItem(item); item.isEquiped = true; invManager.UnEquipFromStoredSlot(); invManager.StoreIdOnResources(item, slot); invManager.LoadItemsOnCharacter(); invManager.ClearCurrentItem(); if (previousItem != null) { previousItem.isEquiped = false; invManager.SetItemOnStoredSlot(previousItem); } } }
void FindCurrentSlot() { PointerEventData pointerData = new PointerEventData(EventSystem.current) { position = Input.mousePosition }; List <RaycastResult> results = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointerData, results); for (int i = 0; i < results.Count; i++) { currentSlot = results[i].gameObject.GetComponentInParent <UI_Slot>(); } if (results.Count == 0) { currentSlot = null; } }
void FindCurrentSlot() { PointerEventData pointerData = new PointerEventData(EventSystem.current) //EventSystem.current : 현재의 이벤트시스템 반환 { position = Input.mousePosition }; //pointerData.position=Input.mousePosition; List <RaycastResult> results = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointerData, results); for (int i = 0; i < results.Count; i++) { currentSlot = results[i].gameObject.GetComponentInParent <UI_Slot>();//raycastresult.gameobject:레이캐스트에 의해 히트된 게임 오브젝트 } if (results.Count == 0) { currentSlot = null; } }
public void StoreIdOnResources(Items.Item item, UI_Slot slot) { Items.BodyPart targetPart = slot.bodyPart; int targetInstId = -1; if (item != null) { targetPart = item.bodyPart; targetInstId = item.instId; } if (item is Items.Weapon) { IdsContainer c = r_manager.GetWeaponIdContainer(targetPart, slot.isLeft); c.instId = targetInstId; } else { IdsContainer c = r_manager.GetIdContainer(targetPart); c.instId = targetInstId; } }
void DetectAction() { if (mouseIsDown) { if (currentItem == null) { if (currentSlot == null) { return; } currentSlot.OnClick(this); } } if (mouseIsUp) { if (currentItem != null) { if (currentSlot != null) { currentSlot.OnDropItem(currentItem, this); } } if (currentItem != null) { SetItemOnStoredSlot(currentItem); } currentItem = null; storedSlot = null; mouseIcon.sprite = null; mouseIcon.enabled = false; } }
public void Init() { for (int i = 0; i < slotAmount; i++) { GameObject go = Instantiate(slotPrefab) as GameObject; go.transform.SetParent(slotGrid); go.SetActive(true); inventorySlots.Add(go.GetComponent <UI_Slot>()); } mouseIcon.enabled = false; UI_Slot[] eq = equipmentGrid.GetComponentsInChildren <UI_Slot>(); for (int i = 0; i < eq.Length; i++) { if (eq[i].bodyPart != null) { if (eq[i].isWeaponSlot) { if (eq[i].isLeft) { leftHandSlot = eq[i]; } else { rightHandSlot = eq[i]; } } if (!equipmentSlots.ContainsKey(eq[i].bodyPart)) { equipmentSlots.Add(eq[i].bodyPart, eq[i]); } } } }
public abstract void OnClick(UI_Slot slot, UI_InventoryManager invManager); //slot: 실제 사용하는 슬롯 public abstract void OnDropItem(UI_Slot slot, Items.Item item, UI_InventoryManager invManager);
public abstract void OnClick(UI_Slot slot, UI_InventoryManager invManager); //slot: 실제 사용하는 슬롯
public override void OnDropItem(UI_Slot slot, Item item, UI_InventoryManager invManager) { invManager.LoadCurrentItemOnEquipmentSlot(); }
public override void OnClick(UI_Slot slot, UI_InventoryManager invManager) { }
public override void OnDropItem(UI_Slot slot, Item item, UI_InventoryManager invManager) { invManager.DropItem(); }