From 7e8b5ca6e2d4bff8966cb651122fc59ed22ef94b Mon Sep 17 00:00:00 2001 From: kabix09 Date: Tue, 3 Jan 2023 22:48:05 +0100 Subject: [PATCH] Exuippment - fix equip --- .../UI/Panel/EquipmentPanelController.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/REFACTORING/Application/UI/Panel/EquipmentPanelController.cs b/Assets/Scripts/REFACTORING/Application/UI/Panel/EquipmentPanelController.cs index ca36686c..1101d506 100644 --- a/Assets/Scripts/REFACTORING/Application/UI/Panel/EquipmentPanelController.cs +++ b/Assets/Scripts/REFACTORING/Application/UI/Panel/EquipmentPanelController.cs @@ -55,19 +55,38 @@ public class EquipmentPanelController : DraggablePanelController // 2. Set up panel additn items to it //public void SetUp - in parent - + /// + /// elements: List< + /// IndexValuePair< + /// int: dropped slot number, + /// EquippableItem: dragged item + /// > + /// > + /// + /// public override void BuildPanelContent(List> elements) { base.BuildPanelContent(elements); -/* Debug.Log("Build content"); */ foreach (IndexValuePair element in elements) { -/* Debug.Log($"key: {element.Key} - value: {element.Value}"); */ + //Debug.Log($"key: {element.Key} - {(EquipmentPanelSlotsTypeEnum)element.Key}"); - if(element.Value != null) - ChildBoxList.Where(slot => ((EquipmentSlot)slot).type == (EquipmentPanelSlotsTypeEnum)element.Key).ToList().ForEach(slot => slot.SetItem((EquippableItem)element.Value)); + if (element.Value != null) + { + + // 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) { - Debug.Log("End Drag"); if (!DraggedSlotController.Instance.IsDragged()) // if there was nothing dragged - ignore event return; DraggedSlotController.Instance.RemoveDraggedSlot(); - + if (!itemSlot.Item) ((ItemSlot)ChildBoxList.Where(slot => slot.Number == itemSlot.Number).First()).ResetSlot(); else @@ -104,7 +122,7 @@ public class EquipmentPanelController : DraggablePanelController { 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(slot.Key, slot.Value)); } else