根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:

```
docs(readme): 更新文档说明

- 添加项目使用指南
- 完善API接口描述
- 修正错误的配置示例
```

注意:由于您提供的code differences部分为空,无法确定具体的变更类型和范围。实际使用时请根据真实变更内容替换相应的type、scope、subject和body信息。
This commit is contained in:
huadexuan committed 2026-09-29 17:52:10 +08:00
1 parent bbf8f40e38
commit e127da5416
42 files changed
+1095 -106

No files matched your search

+48 -1
View File
@@ -19,6 +19,7 @@ public class BattleFormationSpawner : MonoBehaviour
private void Start()
{
spawnedHeroCount = 0; // 重置计数器
SpawnHeroes();
}
@@ -88,10 +89,13 @@ public class BattleFormationSpawner : MonoBehaviour
return -1;
}
private static int spawnedHeroCount = 0; // 记录已生成英雄数量
private void Spawn(GameObject prefab, int cell)
{
CharacterData characterData = FindCharacterDataForPrefab(prefab);
GameObject unit = Instantiate(prefab, DeployGrid.CellPosition(cell), Quaternion.identity);
Vector3 spawnPos = DeployGrid.CellPosition(cell);
GameObject unit = Instantiate(prefab, spawnPos, Quaternion.identity);
unit.name = "英雄_" + prefab.name;
if (heroParent != null)
@@ -123,6 +127,49 @@ public class BattleFormationSpawner : MonoBehaviour
characterData.GetAttackPower(level),
characterData.GetMoveSpeed(level));
}
// 设置友方英雄可复活
WorldHealthBar healthBar = unit.GetComponent<WorldHealthBar>();
if (healthBar != null && playerTeamId == 0)
{
healthBar.canRevive = true;
}
// 绑定到英雄卡片UI
BindHeroToCard(unit, characterData, spawnPos);
}
private void BindHeroToCard(GameObject heroUnit, CharacterData characterData, Vector3 spawnPos)
{
if (spawnedHeroCount >= 5) return; // 最多5个英雄
// 查找对应的卡片
Canvas canvas = FindObjectOfType<Canvas>();
if (canvas == null) return;
Transform heroPanel = canvas.transform.Find("BottomUI/HeroCardsPanel");
if (heroPanel == null) return;
string cardName = $"HeroCard{spawnedHeroCount + 1}";
Transform cardObj = heroPanel.Find(cardName);
if (cardObj == null) return;
HeroCardUI heroCardUI = cardObj.GetComponent<HeroCardUI>();
if (heroCardUI == null) return;
// 获取英雄单位组件
UnitBase unitBase = heroUnit.GetComponent<UnitBase>();
if (unitBase == null) return;
// 加载对应的头像
UnityEngine.Sprite icon = characterData != null ? characterData.cardIcon : null;
// 绑定英雄到卡片
heroCardUI.SetHero(unitBase, icon, spawnPos);
spawnedHeroCount++;
Debug.Log($"英雄 {heroUnit.name} 已绑定到 {cardName}");
}
private CharacterData FindCharacterDataForPrefab(GameObject prefab)