```
feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
This commit is contained in:
1 parent
0e7de5f885
commit
53d95802e5
448 files changed
+133333
-472
No files matched your search
@@ -0,0 +1,77 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 拆家版出兵管理:从城堡前方出兵点生成单位,消耗能量。
|
||||
/// 替代旧的召唤师身边召唤逻辑。
|
||||
/// </summary>
|
||||
public class CastleSpawnManager : MonoBehaviour
|
||||
{
|
||||
public static CastleSpawnManager Instance { get; private set; }
|
||||
|
||||
[Header("出兵点(城堡前方)")]
|
||||
public Transform blueSpawnPoint;
|
||||
public Transform redSpawnPoint;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this) { Destroy(gameObject); return; }
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
/// <summary>从指定阵营城堡出兵,消耗能量。teamId: 0=蓝, 1=红。</summary>
|
||||
public bool TrySpawn(CharacterData data, int teamId)
|
||||
{
|
||||
if (data == null || data.unitPrefab == null) return false;
|
||||
if (ManaSystem.Instance == null || !ManaSystem.Instance.TryConsumeMana(data.manaCost))
|
||||
{
|
||||
Debug.Log($"能量不足,需要 {data.manaCost}");
|
||||
return false;
|
||||
}
|
||||
|
||||
Transform spawnPoint = teamId == 0 ? blueSpawnPoint : redSpawnPoint;
|
||||
if (spawnPoint == null)
|
||||
{
|
||||
Debug.LogError($"找不到 teamId={teamId} 的出兵点");
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 direction = spawnPoint.forward;
|
||||
direction.y = 0f;
|
||||
if (direction.sqrMagnitude < 0.001f) direction = Vector3.forward;
|
||||
direction.Normalize();
|
||||
|
||||
GameObject unit = Instantiate(
|
||||
data.unitPrefab,
|
||||
spawnPoint.position,
|
||||
Quaternion.LookRotation(direction, Vector3.up));
|
||||
|
||||
// 设置阵营
|
||||
UnitTeam unitTeam = unit.GetComponent<UnitTeam>();
|
||||
if (unitTeam != null)
|
||||
{
|
||||
unitTeam.teamId = teamId;
|
||||
unit.tag = teamId == 0 ? "Friend" : "Enemy";
|
||||
}
|
||||
|
||||
// 初始化属性(默认 1 级)
|
||||
UnitBase unitBase = unit.GetComponent<UnitBase>();
|
||||
if (unitBase != null)
|
||||
{
|
||||
PlayerCharacterData playerData = new PlayerCharacterData("castle_spawn", 1, 0);
|
||||
float hp = playerData.GetMaxHealth(data);
|
||||
float atk = playerData.GetAttackPower(data);
|
||||
float spd = playerData.GetMoveSpeed(data);
|
||||
unitBase.InitializeFromPlayerData(hp, atk, spd);
|
||||
}
|
||||
|
||||
Debug.Log($"城堡出兵: {data.characterName} teamId={teamId} pos={spawnPoint.position}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanAfford(CharacterData data)
|
||||
{
|
||||
return data != null
|
||||
&& ManaSystem.Instance != null
|
||||
&& ManaSystem.Instance.CurrentManaInt >= data.manaCost;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user