diff --git a/Assets/Scenes/DefenseTest.scene b/Assets/Scenes/DefenseTest.scene index 73a6a95..c947bd0 100644 Binary files a/Assets/Scenes/DefenseTest.scene and b/Assets/Scenes/DefenseTest.scene differ diff --git a/Assets/Scripts/技能脚本/PlayerSkillSystem.cs b/Assets/Scripts/技能脚本/PlayerSkillSystem.cs index e2ed15d..cd28b81 100644 --- a/Assets/Scripts/技能脚本/PlayerSkillSystem.cs +++ b/Assets/Scripts/技能脚本/PlayerSkillSystem.cs @@ -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 } /// - /// 使用技能2:全屏AOE伤害 + /// 使用技能2:全屏天雷狂轰伤害 /// 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(); - int hitCount = 0; - - foreach (var unit in enemies) + // 加载特效资源 + GameObject strikePrefab = lightningStrikePrefab; +#if UNITY_EDITOR + if (strikePrefab == null) { + strikePrefab = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/TJGeneratorLibEffects/Prefabs/Combat/Explosions/LightningExplosion/LightningExplosionBlue.prefab"); + } +#endif + + GameObject novaPrefab = lightningNovaPrefab; +#if UNITY_EDITOR + if (novaPrefab == null) + { + novaPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath("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(); + var targetEnemies = new System.Collections.Generic.List(); + + foreach (var unit in allUnits) + { + if (unit == null || !unit.gameObject.activeInHierarchy) continue; var team = unit.GetComponent(); if (team != null && team.teamId == 1) // 敌方 { var healthBar = unit.GetComponent(); 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 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(); + 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); + } + } } /// diff --git a/CODELY.md b/CODELY.md index 9111422..863f13b 100644 --- a/CODELY.md +++ b/CODELY.md @@ -143,6 +143,7 @@ - [2026-10-07 17:32:11] 召唤师技能治疗特效实现:使用 ParabolaFlyObject 驱动 GlowOrbGreen 飞球 (Assets/TJGeneratorLibEffects/Prefabs/Interactive/Loot/GlowOrb/GlowOrbGreen.prefab) 抛物线飞行至阵地中心,落地瞬间触发 2.5 倍缩放的 HealNova 粒子冲击波 (Assets/TJGeneratorLibEffects/Prefabs/Interactive/Healing/HealNova.prefab),并在此时调用 BuffSystem.Instance.ApplyGroupHeal 结算恢复。 - [2026-10-07 16:22:52] 法师技能与特效配置更新:法师 projectilePrefab 统一使用 FireballSharpMissileFire.prefab,并且命中落地触发 MagicExplosionFire.prefab 爆破,具体资产路径已同步更新至《召唤之战-角色与技能说明.md》。 +- [2026-10-08 00:04:53] 天雷狂轰技能实现:点击释放时在全屏中心激发 NovaLightningBlue 蓝闪电光环,同时按 80ms 节奏交错向全场敌方单位头顶劈下 LightningExplosionBlue 落雷(无敌人时在阵地随机轰炸 6 道),造成最终结算伤害并弹出漂字。具体路径与配置已同步写入项目。 ### Reference - [2026-09-09 12:23:17] 飞行物脚本 Projectile.cs 负责锁敌追踪、碰撞检测和伤害结算。箭矢预制体 ArrowProjectile_White.prefab 已配置 Projectile 组件和 CapsuleCollider(Is Trigger)。远程单位需在攻击动画松弦帧添加 OnAttackEffect Event,并在 UnitBase 中设置 attackType=RangedProjectile、projectilePrefab、projectileSpawnPoint。