|
@@ -52,6 +52,9 @@ public class ItemShopManager : MonoBehaviour
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Ensure panel settings and proper sorting order are set
|
|
|
|
|
+ EnsurePanelSettings();
|
|
|
|
|
+
|
|
|
InitializeUI();
|
|
InitializeUI();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -518,13 +521,53 @@ public class ItemShopManager : MonoBehaviour
|
|
|
|
|
|
|
|
private void AddItemToCustomerInventory(Item item)
|
|
private void AddItemToCustomerInventory(Item item)
|
|
|
{
|
|
{
|
|
|
- // This method needs to be implemented based on your inventory system
|
|
|
|
|
- // For now, let's just log what would happen
|
|
|
|
|
- Debug.Log($"Would add {item.itemName} to {currentCustomer.name}'s inventory");
|
|
|
|
|
|
|
+ if (currentCustomer == null) return;
|
|
|
|
|
+
|
|
|
|
|
+ // Initialize lists if they're null
|
|
|
|
|
+ if (currentCustomer.weapons == null)
|
|
|
|
|
+ currentCustomer.weapons = new System.Collections.Generic.List<string>();
|
|
|
|
|
+ if (currentCustomer.armor == null)
|
|
|
|
|
+ currentCustomer.armor = new System.Collections.Generic.List<string>();
|
|
|
|
|
+ if (currentCustomer.miscItems == null)
|
|
|
|
|
+ currentCustomer.miscItems = new System.Collections.Generic.List<string>();
|
|
|
|
|
+
|
|
|
|
|
+ // Add item to appropriate inventory list based on type
|
|
|
|
|
+ switch (item.itemType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case ItemType.Weapon:
|
|
|
|
|
+ currentCustomer.weapons.Add(item.itemName);
|
|
|
|
|
+ Debug.Log($"Added weapon '{item.itemName}' to {currentCustomer.name}'s weapon inventory");
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case ItemType.Armor:
|
|
|
|
|
+ currentCustomer.armor.Add(item.itemName);
|
|
|
|
|
+ Debug.Log($"Added armor '{item.itemName}' to {currentCustomer.name}'s armor inventory");
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case ItemType.Miscellaneous:
|
|
|
|
|
+ case ItemType.Consumable:
|
|
|
|
|
+ case ItemType.Tool:
|
|
|
|
|
+ case ItemType.Accessory:
|
|
|
|
|
+ currentCustomer.miscItems.Add(item.itemName);
|
|
|
|
|
+ Debug.Log($"Added item '{item.itemName}' to {currentCustomer.name}'s misc inventory");
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ currentCustomer.miscItems.Add(item.itemName);
|
|
|
|
|
+ Debug.LogWarning($"Unknown item type for '{item.itemName}', added to misc items");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Trigger UI update in MainTeamSelectScript if available
|
|
|
|
|
+ TriggerInventoryUIUpdate();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // If you have an inventory system, add the item here
|
|
|
|
|
- // For example:
|
|
|
|
|
- // currentCustomer.inventory.AddItem(item);
|
|
|
|
|
|
|
+ private void TriggerInventoryUIUpdate()
|
|
|
|
|
+ {
|
|
|
|
|
+ // The OnCharacterDataChanged event is already invoked in PurchaseItem()
|
|
|
|
|
+ // This should trigger any listeners to update their UI
|
|
|
|
|
+ // MainTeamSelectScript should listen to this event to refresh inventory displays
|
|
|
|
|
+ Debug.Log("Character inventory updated - OnCharacterDataChanged event will be triggered");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void UpdatePlayerMoney()
|
|
private void UpdatePlayerMoney()
|
|
@@ -696,4 +739,46 @@ public class ItemShopManager : MonoBehaviour
|
|
|
Debug.Log("Opening shop with test character...");
|
|
Debug.Log("Opening shop with test character...");
|
|
|
OpenShop(testCharacter);
|
|
OpenShop(testCharacter);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ void EnsurePanelSettings()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (uiDocument.panelSettings == null || uiDocument.sortingOrder <= 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Try to find and reuse existing panel settings from other UI
|
|
|
|
|
+ var existingUI = GameObject.Find("TravelUI")?.GetComponent<UIDocument>();
|
|
|
|
|
+ if (existingUI?.panelSettings != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ uiDocument.panelSettings = existingUI.panelSettings;
|
|
|
|
|
+ Debug.Log("✓ ItemShopManager: Panel Settings assigned from TravelUI");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ // Try to find from MainTeamSelectScript or other UI components
|
|
|
|
|
+ var mainTeamSelect = FindFirstObjectByType<MainTeamSelectScript>();
|
|
|
|
|
+ if (mainTeamSelect != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ var mainUIDoc = mainTeamSelect.GetComponent<UIDocument>();
|
|
|
|
|
+ if (mainUIDoc?.panelSettings != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ uiDocument.panelSettings = mainUIDoc.panelSettings;
|
|
|
|
|
+ Debug.Log("✓ ItemShopManager: Panel Settings assigned from MainTeamSelectScript");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Set proper sorting order (> 2 as requested)
|
|
|
|
|
+ uiDocument.sortingOrder = 5; // Higher than 2 to ensure shop displays on top
|
|
|
|
|
+
|
|
|
|
|
+ if (uiDocument.panelSettings != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Make sure panel settings also have a high sorting order
|
|
|
|
|
+ uiDocument.panelSettings.sortingOrder = 5;
|
|
|
|
|
+ Debug.Log($"✓ ItemShopManager: Sorting order set to {uiDocument.sortingOrder}");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Debug.LogWarning("⚠ ItemShopManager: Could not assign Panel Settings. Shop may not display properly.");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|