```
feat(gameplay): 提升单位检测范围并添加法师属性 - 将所有单位的检测范围从默认值提升至100 - 为法师预制体添加护盾、等级等新属性 - 为法师添加暴击、吸血、伤害减免等战斗属性 - 更换法师弹丸预设并调整相关参数 - 添加锚点交战Z线控制功能 - 更新玩家数据中配备的召唤师技能 - 移除多余的纹理配置文件 ```
This commit is contained in:
1 parent
6089308f66
commit
23c559d9f7
243 files changed
+150612
-1459
No files matched your search
@@ -7,6 +7,12 @@ using UnityEngine.UI;
|
||||
/// </summary>
|
||||
public class PlayerSkillSystem : MonoBehaviour
|
||||
{
|
||||
public static PlayerSkillSystem Instance { get; private set; }
|
||||
|
||||
[Header("战术增益加成倍率")]
|
||||
public float cooldownMultiplier = 1f; // 冷却缩减倍率 (如 0.9 = CD 缩减 10%)
|
||||
public float powerMultiplier = 1f; // 威力加成倍率 (如 1.15 = 效果提升 15%)
|
||||
|
||||
[Header("技能1:群体治疗")]
|
||||
public Button skill1Button;
|
||||
public Text skill1CooldownText;
|
||||
@@ -14,6 +20,12 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
public float skill1HealAmount = 100f;
|
||||
private float skill1RemainingCooldown = 0f;
|
||||
|
||||
[Header("技能1特效配置")]
|
||||
public GameObject cureBallPrefab; // 飞球预制体 (Assets/Prefabs/特效/飞球/cureBall.prefab)
|
||||
public GameObject healNovaPrefab; // 治疗冲击波预制体 (Assets/TJGeneratorLibEffects/Prefabs/Interactive/Healing/HealNova.prefab)
|
||||
public Transform castStartTransform; // 技能施放起点 (如未指定默认摄像机下方或召唤师位置)
|
||||
public Vector3 castTargetPosition = new Vector3(0f, 0.1f, -9f); // 我方阵地中心落地点
|
||||
|
||||
[Header("技能2:全屏AOE")]
|
||||
public Button skill2Button;
|
||||
public Text skill2CooldownText;
|
||||
@@ -21,8 +33,19 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
public float skill2Damage = 80f;
|
||||
private float skill2RemainingCooldown = 0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 自动从场景或父节点绑定技能按钮与图标引用
|
||||
EnsureSkillUIReferences();
|
||||
|
||||
// 从 PlayerData 加载玩家装备的 2 个召唤师技能图标
|
||||
LoadEquippedSkillIcons();
|
||||
|
||||
// 绑定按钮点击事件
|
||||
if (skill1Button != null)
|
||||
{
|
||||
@@ -35,6 +58,76 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSkillUIReferences()
|
||||
{
|
||||
var canvas = GameObject.Find("TowerDefenseCanvas");
|
||||
if (canvas == null) return;
|
||||
|
||||
var skillsPanel = canvas.transform.Find("BottomUI/SkillsPanel");
|
||||
if (skillsPanel == null) return;
|
||||
|
||||
if (skill1Button == null && skillsPanel.childCount > 0)
|
||||
{
|
||||
var item1 = skillsPanel.GetChild(0);
|
||||
skill1Button = item1.GetComponent<Button>();
|
||||
if (skill1Button == null) skill1Button = item1.gameObject.AddComponent<Button>();
|
||||
}
|
||||
|
||||
if (skill2Button == null && skillsPanel.childCount > 1)
|
||||
{
|
||||
var item2 = skillsPanel.GetChild(1);
|
||||
skill2Button = item2.GetComponent<Button>();
|
||||
if (skill2Button == null) skill2Button = item2.gameObject.AddComponent<Button>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 PlayerData 读取玩家配置的 2 个召唤师技能名称,并绑定图标到 UI 位置
|
||||
/// </summary>
|
||||
public void LoadEquippedSkillIcons()
|
||||
{
|
||||
string skill1Name = "神圣赞歌";
|
||||
string skill2Name = "陨石轰炸";
|
||||
|
||||
if (PlayerDataManager.Instance != null && PlayerDataManager.Instance.equippedSummonerSkills != null && PlayerDataManager.Instance.equippedSummonerSkills.Length >= 2)
|
||||
{
|
||||
skill1Name = PlayerDataManager.Instance.equippedSummonerSkills[0];
|
||||
skill2Name = PlayerDataManager.Instance.equippedSummonerSkills[1];
|
||||
}
|
||||
|
||||
SetSkillIcon(skill1Button, skill1Name);
|
||||
SetSkillIcon(skill2Button, skill2Name);
|
||||
}
|
||||
|
||||
private void SetSkillIcon(Button skillBtn, string skillName)
|
||||
{
|
||||
if (skillBtn == null || string.IsNullOrEmpty(skillName)) return;
|
||||
|
||||
Image img = skillBtn.GetComponent<Image>();
|
||||
if (img != null)
|
||||
{
|
||||
Sprite icon = GetSkillIconSprite(skillName);
|
||||
if (icon != null)
|
||||
{
|
||||
img.sprite = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Sprite GetSkillIconSprite(string skillName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(skillName)) return null;
|
||||
|
||||
Sprite icon = Resources.Load<Sprite>($"Picture/UI/召唤师技能图标/{skillName}");
|
||||
#if UNITY_EDITOR
|
||||
if (icon == null)
|
||||
{
|
||||
icon = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>($"Assets/Picture/UI/召唤师技能图标/{skillName}.png");
|
||||
}
|
||||
#endif
|
||||
return icon;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 更新技能1冷却
|
||||
@@ -100,15 +193,87 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"释放技能1:群体治疗(恢复 {skill1HealAmount} 生命)");
|
||||
float finalHeal = skill1HealAmount * powerMultiplier;
|
||||
Debug.Log($"释放技能1:群体治疗(恢复 {finalHeal:F1} 生命,威力倍率: {powerMultiplier:F2})");
|
||||
|
||||
// 对所有友方单位施加治疗
|
||||
BuffSystem.Instance.ApplyGroupHeal(skill1HealAmount);
|
||||
// 智能获取友方阵地中心或平均位置
|
||||
Vector3 targetPos = GetAllyCenterPosition();
|
||||
Vector3 startPos = castStartTransform != null ? castStartTransform.position : new Vector3(targetPos.x, targetPos.y + 10f, targetPos.z - 8f);
|
||||
|
||||
// 加载/实例化抛物线 cureBall
|
||||
GameObject ballPrefab = cureBallPrefab;
|
||||
if (ballPrefab == null)
|
||||
{
|
||||
ballPrefab = Resources.Load<GameObject>("Prefabs/特效/飞球/cureBall");
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
if (ballPrefab == null)
|
||||
{
|
||||
ballPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/特效/飞球/cureBall.prefab");
|
||||
}
|
||||
#endif
|
||||
|
||||
GameObject novaPrefab = healNovaPrefab;
|
||||
#if UNITY_EDITOR
|
||||
if (novaPrefab == null)
|
||||
{
|
||||
novaPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>("Assets/TJGeneratorLibEffects/Prefabs/Interactive/Healing/HealNova.prefab");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ballPrefab != null)
|
||||
{
|
||||
GameObject ballGo = Instantiate(ballPrefab, startPos, Quaternion.identity);
|
||||
var parabola = ballGo.GetComponent<ParabolaFlyObject>();
|
||||
if (parabola == null)
|
||||
{
|
||||
parabola = ballGo.AddComponent<ParabolaFlyObject>();
|
||||
}
|
||||
|
||||
parabola.Launch(startPos, targetPos, 0.8f, 4.5f, novaPrefab, () =>
|
||||
{
|
||||
// 对所有友方单位施加治疗
|
||||
BuffSystem.Instance.ApplyGroupHeal(finalHeal);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 特效缺失兜底直接治疗
|
||||
BuffSystem.Instance.ApplyGroupHeal(finalHeal);
|
||||
}
|
||||
|
||||
// 开始冷却
|
||||
skill1RemainingCooldown = skill1Cooldown;
|
||||
skill1RemainingCooldown = skill1Cooldown * cooldownMultiplier;
|
||||
}
|
||||
|
||||
// TODO: 播放技能特效
|
||||
/// <summary>
|
||||
/// 计算场上己方英雄的实时中心点位置,无单位时回退默认网格中心
|
||||
/// </summary>
|
||||
private Vector3 GetAllyCenterPosition()
|
||||
{
|
||||
var heroes = FindObjectsOfType<UnitBase>();
|
||||
Vector3 sumPos = Vector3.zero;
|
||||
int count = 0;
|
||||
|
||||
foreach (var hero in heroes)
|
||||
{
|
||||
if (hero == null || !hero.gameObject.activeInHierarchy) continue;
|
||||
UnitTeam team = hero.GetComponent<UnitTeam>();
|
||||
if (team != null && team.IsLocalPlayerTeam())
|
||||
{
|
||||
sumPos += hero.transform.position;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
Vector3 center = sumPos / count;
|
||||
center.y = 0.1f;
|
||||
return center;
|
||||
}
|
||||
|
||||
return new Vector3(0f, 0.1f, -10f); // 网格阵地真正中心点
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,7 +286,8 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"释放技能2:全屏AOE(造成 {skill2Damage} 伤害)");
|
||||
float finalDamage = skill2Damage * powerMultiplier;
|
||||
Debug.Log($"释放技能2:全屏AOE(造成 {finalDamage:F1} 伤害,威力倍率: {powerMultiplier:F2})");
|
||||
|
||||
// 对所有敌方单位造成伤害
|
||||
var enemies = FindObjectsOfType<UnitBase>();
|
||||
@@ -135,7 +301,7 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
var healthBar = unit.GetComponent<WorldHealthBar>();
|
||||
if (healthBar != null && !healthBar.IsDead)
|
||||
{
|
||||
healthBar.TakeDamage(skill2Damage);
|
||||
healthBar.TakeDamage(finalDamage);
|
||||
hitCount++;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +310,7 @@ public class PlayerSkillSystem : MonoBehaviour
|
||||
Debug.Log($"全屏AOE命中 {hitCount} 个敌人");
|
||||
|
||||
// 开始冷却
|
||||
skill2RemainingCooldown = skill2Cooldown;
|
||||
skill2RemainingCooldown = skill2Cooldown * cooldownMultiplier;
|
||||
|
||||
// TODO: 播放技能特效
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user