Update shop categories
This commit is contained in:
@@ -12,7 +12,7 @@ public class ShopCategoryManager : MonoBehaviour
|
||||
{
|
||||
"Category 1", // Original category 1
|
||||
"Category 2", // Original category 2
|
||||
"Categories 3-5", // Merged categories 3, 4, 5
|
||||
"Categories 1, 3, 4", // Merged categories 1, 3, 4
|
||||
"Category 6", // Original category 6
|
||||
"Category 7", // Original category 7
|
||||
"Category 8" // Original category 8
|
||||
@@ -27,7 +27,7 @@ public class ShopCategoryManager : MonoBehaviour
|
||||
public Color disabledButtonColor = Color.gray;
|
||||
|
||||
private int currentSelectedCategory = 0;
|
||||
private ShopUIManager shopManager;
|
||||
public ShopUIManager shopManager;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -68,13 +68,9 @@ public class ShopCategoryManager : MonoBehaviour
|
||||
currentSelectedCategory = categoryIndex;
|
||||
UpdateCategoryDisplay();
|
||||
|
||||
// Notify shop manager
|
||||
// Notify shop manager to actually update the item list
|
||||
if (shopManager != null)
|
||||
{
|
||||
// Use reflection to call the private method, or make it public
|
||||
// For now, we'll assume there's a public method to handle category change
|
||||
Debug.Log($"Category {categoryIndex} selected: {categoryNames[categoryIndex]}");
|
||||
}
|
||||
shopManager.SetCategoryIndex(categoryIndex);
|
||||
}
|
||||
|
||||
void UpdateCategoryDisplay()
|
||||
@@ -124,12 +120,12 @@ public class ShopCategoryManager : MonoBehaviour
|
||||
|
||||
public bool IsItemInCategory(GShopItem item, int categoryIndex)
|
||||
{
|
||||
// Category mapping: 0=1, 1=2, 2=3+4+5, 3=6, 4=7, 5=8
|
||||
// Category mapping: 0=1, 1=2, 2=1+3+4, 3=6, 4=7, 5=8
|
||||
switch (categoryIndex)
|
||||
{
|
||||
case 0: return item.mainType == 0; // Category 1
|
||||
case 1: return item.mainType == 1; // Category 2
|
||||
case 2: return item.mainType >= 2 && item.mainType <= 4; // Categories 3, 4, 5 merged
|
||||
case 2: return item.mainType == 0 || item.mainType == 2 || item.mainType == 3; // Categories 1, 3, 4 merged
|
||||
case 3: return item.mainType == 5; // Category 6
|
||||
case 4: return item.mainType == 6; // Category 7
|
||||
case 5: return item.mainType == 7; // Category 8
|
||||
@@ -146,8 +142,8 @@ public class ShopCategoryManager : MonoBehaviour
|
||||
{
|
||||
int originalCategory = item.mainType;
|
||||
|
||||
if (originalCategory >= 2 && originalCategory <= 4)
|
||||
return "Categories 3-5";
|
||||
if (originalCategory == 0 || originalCategory == 2 || originalCategory == 3)
|
||||
return "Categories 1, 3, 4";
|
||||
|
||||
if (originalCategory < categoryNames.Length)
|
||||
return categoryNames[originalCategory];
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ShopUIManager : MonoBehaviour
|
||||
{
|
||||
if (shopMainPanel != null)
|
||||
{
|
||||
shopMainPanel.SetActive(true);
|
||||
OnCategorySelected(0);
|
||||
RefreshShopDisplay();
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,12 @@ public class ShopUIManager : MonoBehaviour
|
||||
Debug.Log($"Category switch to {categoryIndex} completed in {switchTime * 1000f:F2}ms");
|
||||
}
|
||||
|
||||
// Allow external components (e.g., ShopCategoryManager) to switch category
|
||||
public void SetCategoryIndex(int categoryIndex)
|
||||
{
|
||||
OnCategorySelected(categoryIndex);
|
||||
}
|
||||
|
||||
public void RefreshShopDisplay()
|
||||
{
|
||||
// Return all current panels to pool
|
||||
@@ -172,13 +178,13 @@ public class ShopUIManager : MonoBehaviour
|
||||
|
||||
bool IsItemInCategory(GShopItem item, int categoryIndex)
|
||||
{
|
||||
// Category mapping: 0=1, 1=2, 2=3+4+5, 3=6, 4=7, 5=8
|
||||
// Category mapping: 0=1, 1=2, 2=1+3+4, 3=6, 4=7, 5=8
|
||||
switch (categoryIndex)
|
||||
{
|
||||
case 0: return item.mainType == 0; // Category 1
|
||||
case 1: return item.mainType == 1; // Category 2
|
||||
case 2: return item.mainType >= 2 && item.mainType <= 4; // Categories 3, 4, 5 merged
|
||||
case 3: return item.mainType == 5; // Category 6
|
||||
case 1: return item.mainType == 2; // Category 2
|
||||
case 2: return item.mainType == 5; // Categories 1, 3, 4 merged
|
||||
case 3: return item.mainType == 1 || item.mainType == 3 || item.mainType == 4; // Category 6
|
||||
case 4: return item.mainType == 6; // Category 7
|
||||
case 5: return item.mainType == 7; // Category 8
|
||||
default: return false;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f08a2358f441f066ff36ff6a98d580219dcd8b7629d6675b97643a1f3e09953b
|
||||
size 33030989
|
||||
oid sha256:951300c91d8eb0444ef6f6d4231547c757908cba80c036bc743d186711fca527
|
||||
size 33032375
|
||||
|
||||
Reference in New Issue
Block a user