feat(PlayerSkillSystem): 实现天雷狂轰技能特效和伤害机制

- 添加技能2特效配置,包括落雷击中特效和雷暴全屏光环特效
- 更新技能2名称从"全屏AOE伤害"为"全屏天雷狂轰伤害"
- 实现屏幕中央触发全屏雷暴光环效果
- 添加交错落雷机制,对敌方单位进行精确打击
- 支持无敌人时在敌方阵地随机散落震撼天雷
- 优化伤害计算和冷却逻辑
- 同步更新技能日志信息和代码注释
```
This commit is contained in:
huadexuan committed 2026-10-08 00:08:46 +08:00
1 parent 23c559d9f7
commit 8534d974a9
3 files changed
+87 -11

No files matched your search

Binary file not shown.
@@ -33,6 +33,10 @@ public class PlayerSkillSystem : MonoBehaviour
public float skill2Damage = 80f;
private float skill2RemainingCooldown = 0f;
[Header("技能2特效配置")]
public GameObject lightningStrikePrefab; // 落雷击中特效 (Assets/TJGeneratorLibEffects/Prefabs/Combat/Explosions/LightningExplosion/LightningExplosionBlue.prefab)
public GameObject lightningNovaPrefab; // 雷暴全屏光环特效 (Assets/TJGeneratorLibEffects/Prefabs/Combat/Nova/Lightning/NovaLightningBlue.prefab)
private void Awake()
{
Instance = this;
@@ -277,7 +281,7 @@ public class PlayerSkillSystem : MonoBehaviour
}
/// <summary>
/// 使用技能2:全屏AOE伤害
/// 使用技能2:全屏天雷狂轰伤害
/// </summary>
public void UseSkill2()
{
@@ -287,32 +291,103 @@ public class PlayerSkillSystem : MonoBehaviour
}
float finalDamage = skill2Damage * powerMultiplier;
Debug.Log($"释放技能2:全屏AOE(造成 {finalDamage:F1} 伤害,威力倍率: {powerMultiplier:F2})");
Debug.Log($"释放技能2:天雷狂轰(造成 {finalDamage:F1} 伤害,威力倍率: {powerMultiplier:F2})");
// 对所有敌方单位造成伤害
var enemies = FindObjectsOfType<UnitBase>();
int hitCount = 0;
foreach (var unit in enemies)
// 加载特效资源
GameObject strikePrefab = lightningStrikePrefab;
#if UNITY_EDITOR
if (strikePrefab == null)
{
strikePrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>("Assets/TJGeneratorLibEffects/Prefabs/Combat/Explosions/LightningExplosion/LightningExplosionBlue.prefab");
}
#endif
GameObject novaPrefab = lightningNovaPrefab;
#if UNITY_EDITOR
if (novaPrefab == null)
{
novaPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>("Assets/TJGeneratorLibEffects/Prefabs/Combat/Nova/Lightning/NovaLightningBlue.prefab");
}
#endif
// 1. 屏幕中央触发全屏雷暴光环
if (novaPrefab != null)
{
Vector3 centerPos = new Vector3(0f, 0.1f, 0f);
var novaGo = Instantiate(novaPrefab, centerPos, novaPrefab.transform.rotation);
Destroy(novaGo, 3.5f);
}
// 2. 检索所有活着的敌方单位
var allUnits = FindObjectsOfType<UnitBase>();
var targetEnemies = new System.Collections.Generic.List<UnitBase>();
foreach (var unit in allUnits)
{
if (unit == null || !unit.gameObject.activeInHierarchy) continue;
var team = unit.GetComponent<UnitTeam>();
if (team != null && team.teamId == 1) // 敌方
{
var healthBar = unit.GetComponent<WorldHealthBar>();
if (healthBar != null && !healthBar.IsDead)
{
healthBar.TakeDamage(finalDamage);
hitCount++;
targetEnemies.Add(unit);
}
}
}
Debug.Log($"全屏AOE命中 {hitCount} 个敌人");
StartCoroutine(ExecuteLightningStrikesRoutine(targetEnemies, strikePrefab, finalDamage));
// 开始冷却
skill2RemainingCooldown = skill2Cooldown * cooldownMultiplier;
}
// TODO: 播放技能特效
private System.Collections.IEnumerator ExecuteLightningStrikesRoutine(
System.Collections.Generic.List<UnitBase> targetEnemies,
GameObject strikePrefab,
float finalDamage)
{
if (targetEnemies.Count > 0)
{
// 敌群交错落雷
for (int i = 0; i < targetEnemies.Count; i++)
{
var enemy = targetEnemies[i];
if (enemy != null && enemy.gameObject.activeInHierarchy)
{
Vector3 strikePos = enemy.transform.position;
strikePos.y = 0.1f;
if (strikePrefab != null)
{
var strikeGo = Instantiate(strikePrefab, strikePos, strikePrefab.transform.rotation);
Destroy(strikeGo, 3f);
}
var healthBar = enemy.GetComponent<WorldHealthBar>();
if (healthBar != null && !healthBar.IsDead)
{
healthBar.TakeDamage(finalDamage);
}
}
yield return new WaitForSeconds(0.08f); // 80毫秒交错落雷节奏
}
}
else
{
// 无敌人时在敌方阵地随机散落 6 道震撼天雷
for (int i = 0; i < 6; i++)
{
Vector3 randomPos = new Vector3(Random.Range(-5f, 5f), 0.1f, Random.Range(2f, 12f));
if (strikePrefab != null)
{
var strikeGo = Instantiate(strikePrefab, randomPos, strikePrefab.transform.rotation);
Destroy(strikeGo, 3f);
}
yield return new WaitForSeconds(0.08f);
}
}
}
/// <summary>