```
feat(gameplay): 提升单位检测范围并添加法师属性 - 将所有单位的检测范围从默认值提升至100 - 为法师预制体添加护盾、等级等新属性 - 为法师添加暴击、吸血、伤害减免等战斗属性 - 更换法师弹丸预设并调整相关参数 - 添加锚点交战Z线控制功能 - 更新玩家数据中配备的召唤师技能 - 移除多余的纹理配置文件 ```
This commit is contained in:
1 parent
6089308f66
commit
23c559d9f7
243 files changed
+150612
-1459
No files matched your search
@@ -18,6 +18,7 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
public DefenseWaveLevelController waveLevelController;
|
||||
public Button startBattleButton;
|
||||
public GameObject deploymentUI; // 布阵 UI(英雄卡片面板)
|
||||
public Text deployHintText; // 布阵提示文本
|
||||
|
||||
[Header("英雄配置")]
|
||||
public HeroRoster roster;
|
||||
@@ -77,6 +78,7 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
SetupDeployGrid();
|
||||
DeployHighlight.Ensure();
|
||||
InitializeCardDrag();
|
||||
EnsureDeployHintText();
|
||||
|
||||
Debug.Log("DefenseGameFlowController: 布阵阶段,把英雄卡拖到网格上。");
|
||||
}
|
||||
@@ -138,7 +140,7 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
}
|
||||
|
||||
AlignGridCells(deployGridRoot.transform);
|
||||
deployGridRoot.SetActive(true);
|
||||
deployGridRoot.SetActive(false); // 隐藏蓝框视觉,仅保留拖拽时的防守格位高亮
|
||||
}
|
||||
|
||||
/// <summary>把网格下的格位按 DeployGrid 的坐标摆好,保证视觉与吸附完全一致。</summary>
|
||||
@@ -227,6 +229,58 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
Debug.Log($"DefenseGameFlowController: 已按出战阵容开启 {cardDrags.Count} 张卡片的拖动。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确保布阵提示文本存在。如果 Inspector 未绑定,则在 TowerDefenseCanvas 下自动创建或寻找。
|
||||
/// </summary>
|
||||
private void EnsureDeployHintText()
|
||||
{
|
||||
if (deployHintText != null)
|
||||
{
|
||||
deployHintText.gameObject.SetActive(true);
|
||||
deployHintText.text = "拖拽下方卡牌部署英雄到格位";
|
||||
return;
|
||||
}
|
||||
|
||||
var canvasObj = GameObject.Find("TowerDefenseCanvas");
|
||||
if (canvasObj == null) return;
|
||||
|
||||
var existingHint = canvasObj.transform.Find("DeployHintText");
|
||||
if (existingHint != null)
|
||||
{
|
||||
deployHintText = existingHint.GetComponent<Text>();
|
||||
if (deployHintText != null)
|
||||
{
|
||||
deployHintText.gameObject.SetActive(true);
|
||||
deployHintText.text = "拖拽下方卡牌部署英雄到格位";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 自动创建 DeployHintText UI
|
||||
var hintObj = new GameObject("DeployHintText", typeof(RectTransform), typeof(CanvasRenderer), typeof(Text));
|
||||
hintObj.transform.SetParent(canvasObj.transform, false);
|
||||
|
||||
var rect = hintObj.GetComponent<RectTransform>();
|
||||
rect.anchorMin = new Vector2(0.5f, 1f);
|
||||
rect.anchorMax = new Vector2(0.5f, 1f);
|
||||
rect.pivot = new Vector2(0.5f, 1f);
|
||||
rect.anchoredPosition = new Vector2(0f, -310f); // 放在顶部标题与开始按钮下方
|
||||
rect.sizeDelta = new Vector2(600f, 60f);
|
||||
|
||||
deployHintText = hintObj.GetComponent<Text>();
|
||||
deployHintText.text = "拖拽下方卡牌部署英雄到格位";
|
||||
deployHintText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||
deployHintText.fontSize = 28;
|
||||
deployHintText.fontStyle = FontStyle.Bold;
|
||||
deployHintText.alignment = TextAnchor.MiddleCenter;
|
||||
deployHintText.color = new Color(1f, 0.92f, 0.5f, 1f); // 亮暖黄色,突出提示
|
||||
|
||||
// 加上外发光/阴影组件增强可视度
|
||||
var shadow = hintObj.AddComponent<Shadow>();
|
||||
shadow.effectColor = new Color(0f, 0f, 0f, 0.8f);
|
||||
shadow.effectDistance = new Vector2(2f, -2f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取玩家出战阵容(PlayerData.json 的 currentDeck),按槽位返回角色数据。
|
||||
/// PlayerData 不可用时回退到场景里配置的 HeroRoster。
|
||||
@@ -360,6 +414,7 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
|
||||
if (deploymentUI != null) deploymentUI.SetActive(false);
|
||||
if (startBattleButton != null) startBattleButton.gameObject.SetActive(false);
|
||||
if (deployHintText != null) deployHintText.gameObject.SetActive(false);
|
||||
if (deployGridRoot != null) deployGridRoot.SetActive(false);
|
||||
if (DeployHighlight.Instance != null) DeployHighlight.Instance.Hide();
|
||||
|
||||
@@ -432,7 +487,8 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
unitBase.InitializeFromPlayerData(
|
||||
characterData.GetMaxHealth(level),
|
||||
characterData.GetAttackPower(level),
|
||||
characterData.GetMoveSpeed(level));
|
||||
characterData.GetMoveSpeed(level),
|
||||
level);
|
||||
}
|
||||
|
||||
var healthBar = unit.GetComponent<WorldHealthBar>();
|
||||
@@ -536,12 +592,21 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
var unitBase = hero.GetComponent<UnitBase>();
|
||||
var navAgent = hero.GetComponent<UnityEngine.AI.NavMeshAgent>();
|
||||
|
||||
bool canWalk = UnityEngine.AI.NavMesh.SamplePosition(
|
||||
hero.transform.position, out _, 2f, UnityEngine.AI.NavMesh.AllAreas);
|
||||
// 如果处于攻击或技能状态,navAgent 可能会被临时禁用,需重新启用 NavMeshAgent
|
||||
if (unitBase != null)
|
||||
{
|
||||
unitBase.target = null; // 清空目标退出攻击/追踪状态
|
||||
}
|
||||
if (navAgent != null && !navAgent.enabled)
|
||||
{
|
||||
navAgent.enabled = true;
|
||||
}
|
||||
|
||||
if (navAgent != null && navAgent.enabled && canWalk)
|
||||
bool canWalk = navAgent != null && navAgent.enabled && navAgent.isOnNavMesh
|
||||
&& UnityEngine.AI.NavMesh.SamplePosition(hero.transform.position, out _, 2f, UnityEngine.AI.NavMesh.AllAreas);
|
||||
|
||||
if (canWalk)
|
||||
{
|
||||
if (unitBase != null) unitBase.target = null; // 放开目标,进入回位
|
||||
navAgent.isStopped = false;
|
||||
navAgent.ResetPath();
|
||||
continue;
|
||||
@@ -552,7 +617,11 @@ public class DefenseGameFlowController : MonoBehaviour
|
||||
{
|
||||
Debug.LogWarning($"DefenseGameFlowController: {hero.name} 寻路不可用,瞬移回格位");
|
||||
hero.transform.position = initialPos;
|
||||
if (navAgent != null) navAgent.nextPosition = initialPos;
|
||||
if (navAgent != null)
|
||||
{
|
||||
if (!navAgent.enabled) navAgent.enabled = true;
|
||||
navAgent.nextPosition = initialPos;
|
||||
}
|
||||
if (unitBase != null) unitBase.ResetAnchorPosition();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user