成就系统 巨大修改 新的ui 黑白效果 等一堆
This commit is contained in:
@@ -188,8 +188,10 @@ public class TeamManager : MonoBehaviour
|
||||
//如果在队伍中已有角色的情况下再次触发此方法,首先要去掉旧信息,再放新信息
|
||||
CharacterView newCharacter = currentSelectedCharacterCard;
|
||||
List<CharacterView> newCurrentTeam = getCurrentSelectedTeam().teamIdList;
|
||||
|
||||
if (aimListIndex > 0 || aimListIndex < newCurrentTeam.Count)
|
||||
|
||||
// 修复:原代码使用 (aimListIndex > 0 || aimListIndex < Count) 永远几乎为真,
|
||||
// 会导致当 aimListIndex = 0 或越界时也进入逻辑,造成数据错乱。
|
||||
if (aimListIndex >= 0 && aimListIndex < newCurrentTeam.Count)
|
||||
{
|
||||
for(int i=0;i<newCurrentTeam.Count;i++)
|
||||
{
|
||||
@@ -209,10 +211,14 @@ public class TeamManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
newCurrentTeam[aimListIndex] = newCharacter;
|
||||
currentTeamSettings[currentSelectedTeam].teamIdList = newCurrentTeam;
|
||||
teamSettingPanelInstance.updateTeamSettingElements();
|
||||
return;
|
||||
}
|
||||
newCurrentTeam[aimListIndex] = newCharacter;
|
||||
currentTeamSettings[currentSelectedTeam].teamIdList = newCurrentTeam;
|
||||
teamSettingPanelInstance.updateTeamSettingElements();
|
||||
|
||||
Debug.LogWarning($"TeamManager.ResetTeamCharacter: aimListIndex out of range: {aimListIndex} (Count={newCurrentTeam.Count})");
|
||||
}
|
||||
/// <summary>
|
||||
/// 移除队伍中的指定角色
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2251c37a7903f4447ba858ef24fe25d7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83349f645e9e9764ab6c8c66e5b107a3
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,256 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class loadSettlementTeamPrefab : MonoBehaviour
|
||||
{
|
||||
[Header("��Ҫ����")]
|
||||
public ScoreManager sm;
|
||||
public teamUIController tuic;
|
||||
public GameManager gm;
|
||||
[Header("����")]
|
||||
public GameObject settleTeamCardsPrefab;
|
||||
public GameObject objectToPutdown;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate five settlement cards under objectToPutdown and populate their fields.
|
||||
/// Uses tuic.GetCurrentAllySOs() for profile/name when available, falls back to AllyHero_SO via allySlotIds.
|
||||
/// Reads current HP from AllyCombatant instances named ally_01..ally_05 and idol score from ScoreManager.
|
||||
/// </summary>
|
||||
public void PopulateSettlementCards()
|
||||
{
|
||||
if (settleTeamCardsPrefab == null)
|
||||
{
|
||||
Debug.LogWarning("loadSettlementTeamPrefab: prefab not assigned");
|
||||
return;
|
||||
}
|
||||
|
||||
// If objectToPutdown missing, fall back to this GameObject so instantiated cards are parented somewhere
|
||||
if (objectToPutdown == null)
|
||||
{
|
||||
objectToPutdown = this.gameObject;
|
||||
Debug.LogWarning($"loadSettlementTeamPrefab: objectToPutdown was null - falling back to '{objectToPutdown.name}'");
|
||||
}
|
||||
|
||||
// ensure tuic reference
|
||||
if (tuic == null && teamUIController.Instance != null)
|
||||
tuic = teamUIController.Instance;
|
||||
|
||||
// 修复:确保 sm 被正确赋值
|
||||
if (sm == null && ScoreManager.Instance != null)
|
||||
sm = ScoreManager.Instance;
|
||||
|
||||
// Diagnostic: log target parent state
|
||||
bool parentSceneValid = objectToPutdown != null && objectToPutdown.scene.IsValid();
|
||||
Debug.Log($"[loadSettlementTeamPrefab] Target parent: {objectToPutdown.name}, activeInHierarchy: {objectToPutdown.activeInHierarchy}, sceneValid: {parentSceneValid}");
|
||||
|
||||
// 诊断:记录 ScoreManager 的状态
|
||||
if (sm != null)
|
||||
{
|
||||
Debug.Log($"[loadSettlementTeamPrefab] ScoreManager found. Idol sums: R{sm.red_idolScore_sum} G{sm.green_idolScore_sum} Y{sm.yellow_idolScore_sum} P{sm.purple_idolScore_sum} B{sm.blue_idolScore_sum}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[loadSettlementTeamPrefab] ScoreManager is null! Idol scores will be 0.");
|
||||
}
|
||||
|
||||
// Clear existing children
|
||||
for (int i = objectToPutdown.transform.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
var c = objectToPutdown.transform.GetChild(i).gameObject;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) DestroyImmediate(c);
|
||||
else
|
||||
#endif
|
||||
Destroy(c);
|
||||
}
|
||||
|
||||
// Get current ally SOs if available
|
||||
TeamCharacterDataInfo[] allySOs = null;
|
||||
if (tuic != null)
|
||||
allySOs = tuic.GetCurrentAllySOs();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
// Instantiate as UI child preserving local transform
|
||||
var go = Instantiate(settleTeamCardsPrefab, objectToPutdown.transform, false);
|
||||
if (go == null) continue;
|
||||
go.SetActive(true);
|
||||
|
||||
// Ensure local scale/position are sane for UI
|
||||
try { go.transform.localScale = Vector3.one; } catch { }
|
||||
|
||||
// Explicitly set parent and adjust RectTransform
|
||||
go.transform.SetParent(objectToPutdown.transform, false);
|
||||
var rectTransform = go.GetComponent<RectTransform>();
|
||||
if (rectTransform != null)
|
||||
{
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
rectTransform.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
// Diagnostic: verify parenting applied
|
||||
if (go.transform.parent != objectToPutdown.transform)
|
||||
{
|
||||
Debug.LogWarning($"[loadSettlementTeamPrefab] Parenting mismatch for created card slot {i+1}: expected parent={objectToPutdown.name}, actual parent={go.transform.parent?.name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameConfig.verboseLogs) Debug.Log($"[loadSettlementTeamPrefab] Card correctly parented under {objectToPutdown.name}");
|
||||
}
|
||||
|
||||
var card = go.GetComponent<settleTeamPrefab>();
|
||||
if (card == null)
|
||||
{
|
||||
Debug.LogWarning("Instantiated settleTeamCardsPrefab missing settleTeamPrefab component");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Attempt to resolve an AllyHero_SO for this slot (via teamUIController.allySlotIds) so we can prefer its squareProfile
|
||||
AllyHero_SO resolvedHeroSO = null;
|
||||
int allyId = -1;
|
||||
var ui = tuic ?? teamUIController.Instance;
|
||||
if (ui != null && ui.allySlotIds != null && i < ui.allySlotIds.Count)
|
||||
allyId = ui.allySlotIds[i];
|
||||
if (allyId > 0)
|
||||
{
|
||||
var arr = Resources.LoadAll<AllyHero_SO>("");
|
||||
foreach (var a in arr)
|
||||
{
|
||||
if (a != null && a.ally_heroID == allyId) { resolvedHeroSO = a; break; }
|
||||
}
|
||||
}
|
||||
|
||||
// Populate profile and name: prefer AllyHero_SO.ally_hero_squareProfile when available
|
||||
bool setProfile = false;
|
||||
|
||||
if (resolvedHeroSO != null && card.ally_profile != null)
|
||||
{
|
||||
if (resolvedHeroSO.ally_hero_squareProfile != null)
|
||||
{
|
||||
card.ally_profile.sprite = resolvedHeroSO.ally_hero_squareProfile;
|
||||
card.ally_profile.color = new Color(1f, 1f, 1f, 1f);
|
||||
if (card.ally_name != null)
|
||||
{
|
||||
string displayName = FormatAllyName(resolvedHeroSO.ally_heroDesignation, resolvedHeroSO.ally_heroName);
|
||||
card.ally_name.text = displayName;
|
||||
}
|
||||
setProfile = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Populate profile and name from TeamCharacterDataInfo if available (used by some UI flows)
|
||||
if (!setProfile && allySOs != null && i < allySOs.Length && allySOs[i] != null)
|
||||
{
|
||||
var so = allySOs[i];
|
||||
if (card.ally_profile != null && so.CharacterTeamSprite != null)
|
||||
{
|
||||
card.ally_profile.sprite = so.CharacterTeamSprite;
|
||||
card.ally_profile.color = new Color(1f,1f,1f,1f);
|
||||
}
|
||||
if (card.ally_name != null) card.ally_name.text = so.CharacterName ?? string.Empty;
|
||||
setProfile = true;
|
||||
}
|
||||
|
||||
// Fallback: if we found an AllyHero_SO but it lacked squareProfile, try other profiles on the SO
|
||||
if (!setProfile && resolvedHeroSO != null)
|
||||
{
|
||||
if (card.ally_profile != null && resolvedHeroSO.ally_heroProfile != null)
|
||||
{
|
||||
card.ally_profile.sprite = resolvedHeroSO.ally_heroProfile;
|
||||
card.ally_profile.color = new Color(1f,1f,1f,1f);
|
||||
}
|
||||
if (card.ally_name != null)
|
||||
{
|
||||
string displayName = FormatAllyName(resolvedHeroSO.ally_heroDesignation, resolvedHeroSO.ally_heroName);
|
||||
card.ally_name.text = displayName;
|
||||
}
|
||||
setProfile = true;
|
||||
}
|
||||
|
||||
// Health: try to find AllyCombatant by name ally_01..ally_05
|
||||
var allyGo = GameObject.Find($"ally_0{i+1}");
|
||||
if (allyGo != null)
|
||||
{
|
||||
var ac = allyGo.GetComponent<AllyCombatant>();
|
||||
if (ac != null && card.ally_healthBar != null)
|
||||
{
|
||||
float fill = ac.maxHP > 0 ? (float)ac.currentHP / ac.maxHP : 0f;
|
||||
card.ally_healthBar.fillAmount = Mathf.Clamp01(fill);
|
||||
|
||||
// 新增:如果角色血量为0(死了),给 ally_profile 赋予灰色材质
|
||||
if (ac.currentHP <= 0 && card.ally_profile != null && card.grayM != null)
|
||||
{
|
||||
card.ally_profile.material = card.grayM;
|
||||
Debug.Log($"[loadSettlementTeamPrefab] Applied gray material to ally {i+1} (dead, currentHP={ac.currentHP})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this_allyIdolScore: map index to ScoreManager fields if available
|
||||
// 修复:确保从正确的 ScoreManager 实例读取数据
|
||||
if (card.this_allyIdolScore != null)
|
||||
{
|
||||
int idol = 0;
|
||||
|
||||
// 优先使用已赋值的 sm,否则从 ScoreManager.Instance 获取
|
||||
var scoreManager = sm != null ? sm : ScoreManager.Instance;
|
||||
|
||||
if (scoreManager != null)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: idol = scoreManager.red_idolScore_sum; break;
|
||||
case 1: idol = scoreManager.green_idolScore_sum; break;
|
||||
case 2: idol = scoreManager.yellow_idolScore_sum; break;
|
||||
case 3: idol = scoreManager.purple_idolScore_sum; break;
|
||||
case 4: idol = scoreManager.blue_idolScore_sum; break;
|
||||
}
|
||||
Debug.Log($"[loadSettlementTeamPrefab] Slot {i+1} idol score: {idol}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[loadSettlementTeamPrefab] Cannot find ScoreManager for slot {i+1} idol score");
|
||||
}
|
||||
|
||||
card.this_allyIdolScore.text = idol.ToString();
|
||||
}
|
||||
|
||||
// Populate battle statistics from teamUIController
|
||||
if (tuic != null)
|
||||
{
|
||||
if (card.this_allyDamageDealt != null)
|
||||
card.this_allyDamageDealt.text = Mathf.FloorToInt(tuic.totalDamageDealt[i]).ToString();
|
||||
|
||||
if (card.this_allyDamageTook != null)
|
||||
card.this_allyDamageTook.text = Mathf.FloorToInt(tuic.totalDamageTaken[i]).ToString();
|
||||
|
||||
if (card.this_allyHealthRestored != null)
|
||||
card.this_allyHealthRestored.text = Mathf.FloorToInt(tuic.totalHealProvided[i]).ToString();
|
||||
|
||||
if (card.this_allyManaRestored != null)
|
||||
card.this_allyManaRestored.text = Mathf.FloorToInt(tuic.totalManaRestored[i]).ToString();
|
||||
}
|
||||
|
||||
if (GameConfig.verboseLogs) Debug.Log($"[loadSettlementTeamPrefab] Created card for slot {i+1}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化角色名字为"称号 名字"的形式
|
||||
/// </summary>
|
||||
/// <param name="designation">称号</param>
|
||||
/// <param name="name">名字</param>
|
||||
/// <returns>格式化后的名字</returns>
|
||||
private string FormatAllyName(string designation, string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(designation))
|
||||
{
|
||||
return name ?? string.Empty;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
return designation;
|
||||
}
|
||||
return $"{designation} {name}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27660cffd39783442b2928b61cf7da23
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class settleTeamPrefab : MonoBehaviour
|
||||
{
|
||||
[Header("Ally Basic Information")]
|
||||
public Image ally_profile;
|
||||
public Text ally_name;
|
||||
public Image ally_healthBar;
|
||||
public Material grayM;
|
||||
[Header("this_Ally_settlement")]
|
||||
public Text thisAlly_earnExp;
|
||||
public Text this_allyIdolScore;
|
||||
[Header("±¾³¡¹±Ï×")]
|
||||
public Text this_allyDamageDealt;
|
||||
public Text this_allyDamageTook;
|
||||
public Text this_allyHealthRestored;
|
||||
public Text this_allyManaRestored;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c62158dd79cf39240aea02980c6f24f9
|
||||
Reference in New Issue
Block a user