```
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
@@ -7,15 +7,23 @@ public class CrystalMineCapture : MonoBehaviour
|
||||
[Range(0f, 100f)] public float blueProgress = 50f;
|
||||
[Min(0f)] public float capturePerDamage = 1f;
|
||||
|
||||
[Tooltip("是否自动添加中立阵营(teamId=2)。拆家版关闭以避免单位自动锁敌水晶矿")]
|
||||
public bool autoSetNeutralTeam = true;
|
||||
|
||||
[Header("水晶矿光球")]
|
||||
[SerializeField] private AdjustableGlowOrb glowOrb;
|
||||
[Tooltip("混沌裂缝传送门(随机出兵点),随争夺进度同步变色,可留空")]
|
||||
[SerializeField] private RiftPortalVisual riftVisual;
|
||||
[SerializeField] private Color neutralColor = Color.white;
|
||||
[SerializeField] private Color blueColor = new Color(0.1f, 0.65f, 1f, 1f);
|
||||
[SerializeField] private Color redColor = new Color(1f, 0.12f, 0.08f, 1f);
|
||||
|
||||
[Header("世界血条")]
|
||||
[Tooltip("血条相对模型渲染包围盒顶部的额外高度")]
|
||||
[Min(0f)] public float heightOffset = 1.1f;
|
||||
[Min(0.1f)] public float barWidth = 1.8f;
|
||||
[Min(0.1f)] public float barWidth = 5f;
|
||||
|
||||
private float? barHeightCache;
|
||||
|
||||
private Canvas canvas;
|
||||
private RectTransform barRect;
|
||||
@@ -28,24 +36,41 @@ public class CrystalMineCapture : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
unitTeam = GetComponent<UnitTeam>();
|
||||
if (unitTeam == null)
|
||||
if (autoSetNeutralTeam)
|
||||
{
|
||||
unitTeam = gameObject.AddComponent<UnitTeam>();
|
||||
unitTeam = GetComponent<UnitTeam>();
|
||||
if (unitTeam == null)
|
||||
{
|
||||
unitTeam = gameObject.AddComponent<UnitTeam>();
|
||||
}
|
||||
unitTeam.teamId = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitTeam = GetComponent<UnitTeam>();
|
||||
}
|
||||
unitTeam.teamId = 2;
|
||||
|
||||
if (glowOrb == null)
|
||||
{
|
||||
glowOrb = GetComponentInChildren<AdjustableGlowOrb>(true);
|
||||
}
|
||||
|
||||
if (riftVisual == null)
|
||||
{
|
||||
riftVisual = GetComponentInChildren<RiftPortalVisual>(true);
|
||||
}
|
||||
|
||||
CreateCaptureBar();
|
||||
RefreshVisuals();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 强制重置光球颜色为初始状态
|
||||
if (glowOrb != null)
|
||||
{
|
||||
glowOrb.SetGlowColor(neutralColor);
|
||||
}
|
||||
RefreshVisuals();
|
||||
}
|
||||
|
||||
@@ -53,13 +78,8 @@ public class CrystalMineCapture : MonoBehaviour
|
||||
{
|
||||
if (barRect == null) return;
|
||||
|
||||
barRect.position = transform.position + Vector3.up * heightOffset;
|
||||
Vector3 parentScale = transform.lossyScale;
|
||||
float targetScale = barWidth / 100f;
|
||||
barRect.localScale = new Vector3(
|
||||
parentScale.x != 0f ? targetScale / parentScale.x : targetScale,
|
||||
parentScale.y != 0f ? targetScale / parentScale.y : targetScale,
|
||||
parentScale.z != 0f ? targetScale / parentScale.z : targetScale);
|
||||
barRect.position = transform.position + Vector3.up * GetBarHeight();
|
||||
barRect.localScale = Vector3.one * (barWidth / 100f);
|
||||
|
||||
Camera camera = Camera.main;
|
||||
if (camera != null)
|
||||
@@ -68,6 +88,27 @@ public class CrystalMineCapture : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 血条高度 = 所有子 Renderer 包围盒顶部 + heightOffset。
|
||||
// 水晶矿模型根节点是 100 倍缩放,高度必须按世界包围盒算,否则血条会埋进模型内部被遮挡。
|
||||
private float GetBarHeight()
|
||||
{
|
||||
if (barHeightCache.HasValue) return barHeightCache.Value;
|
||||
|
||||
float top = 0f;
|
||||
Renderer[] renderers = GetComponentsInChildren<Renderer>();
|
||||
if (renderers.Length > 0)
|
||||
{
|
||||
Bounds bounds = renderers[0].bounds;
|
||||
for (int i = 1; i < renderers.Length; i++)
|
||||
{
|
||||
bounds.Encapsulate(renderers[i].bounds);
|
||||
}
|
||||
top = bounds.max.y;
|
||||
}
|
||||
barHeightCache = top - transform.position.y + heightOffset;
|
||||
return barHeightCache.Value;
|
||||
}
|
||||
|
||||
public bool ReceiveCaptureDamage(float damage, GameObject attacker)
|
||||
{
|
||||
if (damage <= 0f || attacker == null) return false;
|
||||
@@ -109,12 +150,19 @@ public class CrystalMineCapture : MonoBehaviour
|
||||
Color color = blueProgress >= 100f ? blueColor : blueProgress <= 0f ? redColor : neutralColor;
|
||||
glowOrb.SetGlowColor(color);
|
||||
}
|
||||
|
||||
if (riftVisual != null)
|
||||
{
|
||||
Color riftColor = blueProgress >= 100f ? blueColor : blueProgress <= 0f ? redColor : neutralColor;
|
||||
riftVisual.SetRiftColor(riftColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCaptureBar()
|
||||
{
|
||||
GameObject root = new GameObject("CrystalCaptureBar", typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler));
|
||||
root.transform.SetParent(transform, false);
|
||||
// 血条 Canvas 不要作为水晶矿的子对象,直接放在场景根目录避免被 100 倍缩放影响
|
||||
root.transform.parent = null;
|
||||
canvas = root.GetComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.WorldSpace;
|
||||
canvas.sortingOrder = 110;
|
||||
|
||||
Reference in new issue
Block a user