ui基本完毕,修了一大把的bug
This commit is contained in:
@@ -49,10 +49,12 @@ public class idolUpgrade : MonoBehaviour
|
||||
public Text upgradeText;
|
||||
|
||||
private readonly List<materialPrefab> spawnedMaterials = new List<materialPrefab>();
|
||||
private readonly Dictionary<materialPrefab, expBottlesSO> spawnedBottleBindings = new Dictionary<materialPrefab, expBottlesSO>();
|
||||
private expBottlesSO selectedBottle;
|
||||
private DushMaterialKind? selectedBreakthroughMaterialKind;
|
||||
private bool isShowingBreakthrough;
|
||||
private string lastOperationSuccessMessage;
|
||||
private storeItemSO[] cachedStoreItems;
|
||||
|
||||
private static readonly Color UpgradeWarningColor = new Color32(120, 36, 36, 255);
|
||||
private static readonly Color UpgradeMaxColor = new Color32(205, 170, 64, 255);
|
||||
@@ -220,7 +222,7 @@ public class idolUpgrade : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
string bottleName = selectedBottle.expBottleName;
|
||||
string bottleName = GetDisplayName(selectedBottle);
|
||||
string failure;
|
||||
int consumedCount;
|
||||
int grantedExp;
|
||||
@@ -263,11 +265,13 @@ public class idolUpgrade : MonoBehaviour
|
||||
|
||||
item.Bind(
|
||||
bottle.expBottleSprite,
|
||||
bottle.expBottleName,
|
||||
GetDisplayName(bottle),
|
||||
Mathf.Max(0, ExpBottleLedger.EnsureInstance().GetCount(bottle.bottleKind)).ToString(),
|
||||
bottle.itemRarity,
|
||||
bottle == selectedBottle,
|
||||
true,
|
||||
() => SelectBottle(bottle));
|
||||
spawnedBottleBindings[item] = bottle;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -337,9 +341,12 @@ public class idolUpgrade : MonoBehaviour
|
||||
? (requirement.bottle != null ? requirement.bottle.expBottleSprite : null)
|
||||
: (requirement.material != null ? requirement.material.growthMaterialSprite : null),
|
||||
requirement.isBottleRequirement
|
||||
? (requirement.bottle != null ? requirement.bottle.expBottleName : requirement.bottleKind.ToString())
|
||||
: (requirement.material != null ? requirement.material.growthMaterialName : requirement.materialKind.ToString()),
|
||||
? GetDisplayName(requirement.bottle, requirement.bottleKind)
|
||||
: GetDisplayName(requirement.material, requirement.materialKind),
|
||||
amountText,
|
||||
requirement.isBottleRequirement
|
||||
? (requirement.bottle != null ? requirement.bottle.itemRarity : ItemRarity.None)
|
||||
: (requirement.material != null ? requirement.material.itemRarity : ItemRarity.None),
|
||||
ShouldHighlightBreakthroughRequirement(requirement, requiresFullSubmission, bundledSelection),
|
||||
!requiresFullSubmission,
|
||||
() => SelectBreakthroughMaterial(requirement.materialKind));
|
||||
@@ -356,7 +363,7 @@ public class idolUpgrade : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
SetInfoText(selectedBottle.expBottleName);
|
||||
SetInfoText(GetDisplayName(selectedBottle));
|
||||
SetConfirmInteractable(true);
|
||||
SetConfirmButtonText("使用");
|
||||
}
|
||||
@@ -372,7 +379,10 @@ public class idolUpgrade : MonoBehaviour
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isSelected = bottle != null && item.materialName != null && item.materialName.text == bottle.expBottleName;
|
||||
expBottlesSO boundBottle;
|
||||
bool isSelected = bottle != null
|
||||
&& spawnedBottleBindings.TryGetValue(item, out boundBottle)
|
||||
&& boundBottle == bottle;
|
||||
item.SetSelected(isSelected);
|
||||
}
|
||||
|
||||
@@ -1202,6 +1212,100 @@ public class idolUpgrade : MonoBehaviour
|
||||
}
|
||||
|
||||
spawnedMaterials.Clear();
|
||||
spawnedBottleBindings.Clear();
|
||||
}
|
||||
|
||||
private string GetDisplayName(expBottlesSO bottle)
|
||||
{
|
||||
return GetDisplayName(bottle, bottle != null ? bottle.bottleKind : default);
|
||||
}
|
||||
|
||||
private string GetDisplayName(expBottlesSO bottle, ExpBottleKind fallbackKind)
|
||||
{
|
||||
if (bottle != null)
|
||||
{
|
||||
storeItemSO storeItem = FindStoreItemForBottle(bottle);
|
||||
if (storeItem != null && !string.IsNullOrWhiteSpace(storeItem.itemName))
|
||||
{
|
||||
return storeItem.itemName.Trim();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(bottle.expBottleName))
|
||||
{
|
||||
return bottle.expBottleName.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackKind.ToString().Trim();
|
||||
}
|
||||
|
||||
private string GetDisplayName(growthMaterialSO material, DushMaterialKind fallbackKind)
|
||||
{
|
||||
if (material != null)
|
||||
{
|
||||
storeItemSO storeItem = FindStoreItemForGrowthMaterial(material);
|
||||
if (storeItem != null && !string.IsNullOrWhiteSpace(storeItem.itemName))
|
||||
{
|
||||
return storeItem.itemName.Trim();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(material.growthMaterialName))
|
||||
{
|
||||
return material.growthMaterialName.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackKind.ToString().Trim();
|
||||
}
|
||||
|
||||
private storeItemSO FindStoreItemForBottle(expBottlesSO bottle)
|
||||
{
|
||||
if (bottle == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
storeItemSO[] storeItems = GetStoreItems();
|
||||
for (int i = 0; i < storeItems.Length; i++)
|
||||
{
|
||||
storeItemSO storeItem = storeItems[i];
|
||||
if (storeItem != null && storeItem.associatedExpBottle == bottle)
|
||||
{
|
||||
return storeItem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private storeItemSO FindStoreItemForGrowthMaterial(growthMaterialSO material)
|
||||
{
|
||||
if (material == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
storeItemSO[] storeItems = GetStoreItems();
|
||||
for (int i = 0; i < storeItems.Length; i++)
|
||||
{
|
||||
storeItemSO storeItem = storeItems[i];
|
||||
if (storeItem != null && storeItem.associatedGrowthMaterial == material)
|
||||
{
|
||||
return storeItem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private storeItemSO[] GetStoreItems()
|
||||
{
|
||||
if (cachedStoreItems == null)
|
||||
{
|
||||
cachedStoreItems = RuntimeResourcesCache.LoadAllStoreItems() ?? Array.Empty<storeItemSO>();
|
||||
}
|
||||
|
||||
return cachedStoreItems;
|
||||
}
|
||||
|
||||
private void SetInfoText(string content)
|
||||
|
||||
Reference in New Issue
Block a user