Exuippment - fix equip

This commit is contained in:
kabix09 2023-01-03 22:48:05 +01:00
parent db8589c61a
commit 7e8b5ca6e2

View File

@ -55,19 +55,38 @@ public class EquipmentPanelController : DraggablePanelController
// 2. Set up panel additn items to it // 2. Set up panel additn items to it
//public void SetUp - in parent //public void SetUp - in parent
/// <summary>
/// elements: List<
/// IndexValuePair<
/// int: dropped slot number,
/// EquippableItem: dragged item
/// >
/// >
/// </summary>
/// <param name="elements"></param>
public override void BuildPanelContent(List<IndexValuePair<int, EquippableItem>> elements) public override void BuildPanelContent(List<IndexValuePair<int, EquippableItem>> elements)
{ {
base.BuildPanelContent(elements); base.BuildPanelContent(elements);
/* Debug.Log("Build content"); */
foreach (IndexValuePair<int, EquippableItem> element in elements) foreach (IndexValuePair<int, EquippableItem> element in elements)
{ {
/* Debug.Log($"key: {element.Key} - value: {element.Value}"); */ //Debug.Log($"key: {element.Key} - {(EquipmentPanelSlotsTypeEnum)element.Key}");
if(element.Value != null) if (element.Value != null)
ChildBoxList.Where(slot => ((EquipmentSlot)slot).type == (EquipmentPanelSlotsTypeEnum)element.Key).ToList().ForEach(slot => slot.SetItem((EquippableItem)element.Value)); {
// slot type != element.key
// element.Key IS DROPPED SLOT number
// ChildBoxList order IS CONSTANT
// elements HAVE mixed order
// there is error - ChildBoxList.Where(slot => ((EquipmentSlot)slot).type == (EquipmentPanelSlotsTypeEnum)element.Key).ToList().ForEach(slot => slot.SetItem((EquippableItem)element.Value));
// FIX
ChildBoxList[element.Key].SetItem((EquippableItem)element.Value);
}
} }
} }
@ -84,12 +103,11 @@ public class EquipmentPanelController : DraggablePanelController
public override void EndDrag(ItemSlot itemSlot) public override void EndDrag(ItemSlot itemSlot)
{ {
Debug.Log("End Drag");
if (!DraggedSlotController.Instance.IsDragged()) // if there was nothing dragged - ignore event if (!DraggedSlotController.Instance.IsDragged()) // if there was nothing dragged - ignore event
return; return;
DraggedSlotController.Instance.RemoveDraggedSlot(); DraggedSlotController.Instance.RemoveDraggedSlot();
if (!itemSlot.Item) if (!itemSlot.Item)
((ItemSlot)ChildBoxList.Where(slot => slot.Number == itemSlot.Number).First()).ResetSlot(); ((ItemSlot)ChildBoxList.Where(slot => slot.Number == itemSlot.Number).First()).ResetSlot();
else else
@ -104,7 +122,7 @@ public class EquipmentPanelController : DraggablePanelController
{ {
if (slot.Value != null) if (slot.Value != null)
{ {
Debug.Log($"Slot nr: {slot.Key} with item: {slot.Value}"); // Debug.Log($"Slot nr: {slot.Key} with item: {slot.Value}");
UiManager.Add(new IndexValuePair<int, EquippableItem>(slot.Key, slot.Value)); UiManager.Add(new IndexValuePair<int, EquippableItem>(slot.Key, slot.Value));
} }
else else