展前冒死重构
This commit is contained in:
@@ -804,6 +804,11 @@ public class teamUIController : MonoBehaviour
|
||||
return (EnemyData_SO[])currentEnemySOs.Clone();
|
||||
}
|
||||
|
||||
public EnemyCombatant GetCurrentEnemyCombatant()
|
||||
{
|
||||
return enemyCombatantInstance;
|
||||
}
|
||||
|
||||
// Debug helper to print key fields of a TeamCharacterDataInfo
|
||||
private void DebugCharacterSO(TeamCharacterDataInfo so, int slotIndex, bool isEditor)
|
||||
{
|
||||
@@ -1161,6 +1166,12 @@ public class teamUIController : MonoBehaviour
|
||||
|
||||
PopulateAllySOsFromIds();
|
||||
|
||||
// 初始化角色头像:根据槽位 ID 刷新 teammate0X_characterImage,空槽位会被禁用
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RefreshTeammateCharacterImageBySlotId(i);
|
||||
}
|
||||
|
||||
// initialize previous flags so Update can detect changes
|
||||
prevAllyActive[0] = isAlly01_active;
|
||||
prevAllyActive[1] = isAlly02_active;
|
||||
@@ -1518,16 +1529,31 @@ public class teamUIController : MonoBehaviour
|
||||
}
|
||||
|
||||
// helper to set teammate character image based on slot index
|
||||
// 若 sprite 为 null,则禁用对应 Image GameObject(槽位无角色);否则启用并设 sprite。
|
||||
private void SetTeammateCharacterImage(int slotIndex, Sprite sprite)
|
||||
{
|
||||
if (sprite == null) return;
|
||||
Image img = null;
|
||||
switch (slotIndex)
|
||||
{
|
||||
case 0: if (teammate01_characterImage != null) teammate01_characterImage.sprite = sprite; break;
|
||||
case 1: if (teammate02_characterImage != null) teammate02_characterImage.sprite = sprite; break;
|
||||
case 2: if (teammate03_characterImage != null) teammate03_characterImage.sprite = sprite; break;
|
||||
case 3: if (teammate04_characterImage != null) teammate04_characterImage.sprite = sprite; break;
|
||||
case 4: if (teammate05_characterImage != null) teammate05_characterImage.sprite = sprite; break;
|
||||
case 0: img = teammate01_characterImage; break;
|
||||
case 1: img = teammate02_characterImage; break;
|
||||
case 2: img = teammate03_characterImage; break;
|
||||
case 3: img = teammate04_characterImage; break;
|
||||
case 4: img = teammate05_characterImage; break;
|
||||
}
|
||||
|
||||
if (img == null) return;
|
||||
|
||||
if (sprite == null)
|
||||
{
|
||||
// 槽位无角色:禁用 Image
|
||||
img.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 槽位有角色:启用 Image 并设置 sprite
|
||||
img.sprite = sprite;
|
||||
img.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1547,7 +1573,13 @@ public class teamUIController : MonoBehaviour
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= allySlotIds.Count) return;
|
||||
int id = allySlotIds[slotIndex];
|
||||
if (id <= 0) return;
|
||||
|
||||
// 槽位无角色(id <= 0):禁用对应 Image
|
||||
if (id <= 0)
|
||||
{
|
||||
SetTeammateCharacterImage(slotIndex, null);
|
||||
return;
|
||||
}
|
||||
|
||||
AllyHero_SO[] all = RuntimeResourcesCache.LoadAllAllyHeroes();
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
@@ -1555,12 +1587,12 @@ public class teamUIController : MonoBehaviour
|
||||
AllyHero_SO so = all[i];
|
||||
if (so == null || so.ally_heroID != id) continue;
|
||||
Sprite sprite = so.ally_heroProfile != null ? so.ally_heroProfile : so.ally_heroImage;
|
||||
if (sprite != null)
|
||||
{
|
||||
SetTeammateCharacterImage(slotIndex, sprite);
|
||||
}
|
||||
SetTeammateCharacterImage(slotIndex, sprite); // sprite 可能仍为 null,SetTeammateCharacterImage 会禁用
|
||||
return;
|
||||
}
|
||||
|
||||
// 找不到对应 SO:也禁用 Image
|
||||
SetTeammateCharacterImage(slotIndex, null);
|
||||
}
|
||||
|
||||
public void SwapAllyWithLowerAdjacent(int slotIndex)
|
||||
@@ -1984,6 +2016,7 @@ public class teamUIController : MonoBehaviour
|
||||
InitializeEnemyInstance();
|
||||
int difficultyID = BeatmapManager.Instance != null ? BeatmapManager.Instance.assignedDifficulty : 0;
|
||||
enemyCombatantInstance.InitializeFromSO(so, difficultyID);
|
||||
GameplayLevelRuleEventBus.NotifyEnemySpawned(enemyCombatantInstance, enemyCurrentCount, so);
|
||||
|
||||
// set UI visuals (name / sprites)
|
||||
string enemyName = so.enemyName ?? so.name;
|
||||
@@ -2176,6 +2209,7 @@ public class teamUIController : MonoBehaviour
|
||||
so = recognizedEnemySOs[enemyCurrentCount];
|
||||
if (so != null) eName = so.enemyName ?? so.name;
|
||||
}
|
||||
GameplayLevelRuleEventBus.NotifyEnemyDied(e, enemyCurrentCount, so);
|
||||
SkillTriggerFeedUI.PushEnemyDeath(eName);
|
||||
|
||||
// notify enemy ball UI
|
||||
|
||||
Reference in New Issue
Block a user