一些修复和优化

This commit is contained in:
2026-07-20 02:22:51 +08:00
parent 818fc9a02f
commit 0a0872c4f4
49 changed files with 2008 additions and 262 deletions
+70 -70
View File
@@ -91,9 +91,11 @@ public class UI_Idols : MonoBehaviour
private int pendingGrowthAnimationHeroId = -1;
private Tween idolExpBarTween;
private Coroutine startupSkillValidationRoutine;
private bool hasStarted;
private void Start()
{
hasStarted = true;
BindQuitButton();
InitializeSectionToggles();
RebuildCards();
@@ -108,7 +110,10 @@ public class UI_Idols : MonoBehaviour
AllyHeroDeployLedger.EnsureInstance().OnHeroGrowthChanged += HandleHeroGrowthChanged;
StoreOwnershipLedger.EnsureInstance().OnOwnershipChanged += HandleOwnershipChanged;
InitializeSectionToggles();
RebuildCards();
if (hasStarted)
{
RebuildCards();
}
HandleOverlayPanelsVisibilityChanged(btmandtopController.CurrentOverlayPanelsVisible);
}
@@ -399,6 +404,7 @@ public class UI_Idols : MonoBehaviour
AllyHero_SO firstDisplayedHero = null;
AllyHero_SO preferredHero = currentSelectedHero;
bool preferredHeroDisplayed = false;
int visibleCardCount = 0;
for (int i = 0; i < heroes.Count; i++)
{
@@ -414,8 +420,8 @@ public class UI_Idols : MonoBehaviour
}
IdolLevelSnapshot snapshot = BuildLevelSnapshot(hero);
GameObject instance = Instantiate(idolCardPrefab, idolCardParent);
spawnedCards.Add(instance);
GameObject instance = GetOrCreateCard(visibleCardCount);
visibleCardCount++;
idolCardPrefab card = instance.GetComponent<idolCardPrefab>();
if (card == null)
@@ -686,8 +692,7 @@ public class UI_Idols : MonoBehaviour
continue;
}
GameObject instance = Instantiate(ssPrefab, ssParent);
spawnedSpecialSkillEntries.Add(instance);
GameObject instance = GetOrCreateSpecialSkillEntry(shown);
ssPrefab display = instance.GetComponent<ssPrefab>();
if (display != null)
@@ -760,47 +765,15 @@ public class UI_Idols : MonoBehaviour
{
for (int i = spawnedCards.Count - 1; i >= 0; i--)
{
if (spawnedCards[i] == null)
GameObject card = spawnedCards[i];
if (card == null)
{
continue;
}
#if UNITY_EDITOR
if (!Application.isPlaying)
if (card.activeSelf)
{
DestroyImmediate(spawnedCards[i]);
}
else
#endif
{
Destroy(spawnedCards[i]);
}
}
spawnedCards.Clear();
if (idolCardParent == null)
{
return;
}
for (int i = idolCardParent.childCount - 1; i >= 0; i--)
{
Transform child = idolCardParent.GetChild(i);
if (child == null || child.GetComponent<idolCardPrefab>() == null)
{
continue;
}
#if UNITY_EDITOR
if (!Application.isPlaying)
{
DestroyImmediate(child.gameObject);
}
else
#endif
{
Destroy(child.gameObject);
card.SetActive(false);
}
}
}
@@ -809,49 +782,61 @@ public class UI_Idols : MonoBehaviour
{
for (int i = spawnedSpecialSkillEntries.Count - 1; i >= 0; i--)
{
if (spawnedSpecialSkillEntries[i] == null)
GameObject entry = spawnedSpecialSkillEntries[i];
if (entry == null)
{
continue;
}
#if UNITY_EDITOR
if (!Application.isPlaying)
if (entry.activeSelf)
{
DestroyImmediate(spawnedSpecialSkillEntries[i]);
}
else
#endif
{
Destroy(spawnedSpecialSkillEntries[i]);
entry.SetActive(false);
}
}
}
spawnedSpecialSkillEntries.Clear();
if (ssParent == null)
private GameObject GetOrCreateCard(int index)
{
while (spawnedCards.Count <= index)
{
return;
GameObject instance = Instantiate(idolCardPrefab, idolCardParent);
spawnedCards.Add(instance);
}
for (int i = ssParent.childCount - 1; i >= 0; i--)
GameObject card = spawnedCards[index];
if (card != null)
{
Transform child = ssParent.GetChild(i);
if (child == null || child.GetComponent<ssPrefab>() == null)
card.transform.SetParent(idolCardParent, false);
card.transform.SetSiblingIndex(index);
if (!card.activeSelf)
{
continue;
}
#if UNITY_EDITOR
if (!Application.isPlaying)
{
DestroyImmediate(child.gameObject);
}
else
#endif
{
Destroy(child.gameObject);
card.SetActive(true);
}
}
return card;
}
private GameObject GetOrCreateSpecialSkillEntry(int index)
{
while (spawnedSpecialSkillEntries.Count <= index)
{
GameObject instance = Instantiate(ssPrefab, ssParent);
spawnedSpecialSkillEntries.Add(instance);
}
GameObject entry = spawnedSpecialSkillEntries[index];
if (entry != null)
{
entry.transform.SetParent(ssParent, false);
entry.transform.SetSiblingIndex(index);
if (!entry.activeSelf)
{
entry.SetActive(true);
}
}
return entry;
}
private static void SetText(Text target, string value)
@@ -1023,7 +1008,22 @@ public class UI_Idols : MonoBehaviour
public void RefreshCurrentHeroDetails()
{
ApplyHeroDetails(currentSelectedHero, false);
if (currentSelectedHero == null)
{
ApplyHeroDetails(null, false);
return;
}
IdolLevelSnapshot snapshot = BuildLevelSnapshot(currentSelectedHero);
SetSliderVisual(idol_expBar, snapshot.sliderValue, snapshot.sliderColor, false);
SetText(idol_expText, snapshot.detailXpText);
SetImageSprite(levelIcon, snapshot.levelIcon);
ApplyLevelDetails(GetEffectiveLevelInfoFromLedger(currentSelectedHero));
if (ieqpmt != null)
{
ieqpmt.RefreshCurrentHeroEquipmentState();
}
}
private void ApplyBehaviourRadar(AllyHero_SO hero)