根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:

```
docs(readme): 更新文档说明

- 添加项目使用指南
- 完善API接口说明
- 修正错误的配置示例
```

注意:由于您提供的code differences部分为空,以上是一个示例模板。当您有具体的代码变更时,请提供详细的变更内容以便生成更准确的commit message。
This commit is contained in:
huadexuan committed 2026-10-04 22:58:39 +08:00
1 parent 11f1af357d
commit 7d9d0f52d1
83 files changed
+3510 -1493

No files matched your search

+53 -12
View File
@@ -2,20 +2,22 @@ using UnityEngine;
/// <summary>
/// 部署网格的几何参数与坐标换算。
/// 阵型编排场景和战斗场景共用同一份参数,保证两边的格位完全对齐。
/// 网格与场景里用于标记布阵区域的那个 Plane 完全重合:
/// Plane 世界范围 X -5.75..5.75、Z -15.6..-4.4,中心 (0, ?, -10)。
/// 4 列 × 4 行,正好铺满这块区域;整体位于 NavMesh 覆盖范围内。
/// </summary>
public static class DeployGrid
{
public const int Cols = 6;
public const int Rows = 5;
public const float ColStep = 2.4f; // 列间距改为2.4,让网格更紧凑,避免最边缘格子太靠外
public const float RowStep = 2.8f; // 行间距保持2.8
public const float BackZ = -15.0f; // 最靠后一排的中心 Z(调整到靠近摄像机的底部区域)
public const float CellWidth = 2.5f;
public const float CellDepth = 2.5f; // 格子深度改为2.5,与宽度相同,形成正方形
public const int Cols = 4;
public const int Rows = 4;
public const float ColStep = 2.875f; // 11.5 / 4
public const float RowStep = 2.8f; // 11.2 / 4
public const float BackZ = -14.2f; // 第 0 排(最靠近镜头)中心 Z = -10 - 1.5*2.8
public const float CellWidth = 2.815f; // 比间距略小,留出缝,看得出是格子
public const float CellDepth = 2.74f;
public const float CellHeight = 0.03f;
public const float GridY = 0.12f; // 格位可视块的中心高度
public const float UnitY = 0.16f; // 单位落点高度(与 NavMesh 高度一致)
public const float GridY = 0.115f; // 格位可视块中心高度(贴在布阵平面之上)
public const float UnitY = 0.10f; // 单位落点高度(与烘焙后的 NavMesh 高度一致)
public const int CellCount = Cols * Rows;
@@ -34,7 +36,23 @@ public static class DeployGrid
return new Vector3(x, UnitY, z);
}
/// <summary>把地面上的世界坐标吸附到最近格位;不在网格范围内返回 -1。</summary>
/// <summary>整个网格的中心(可视块高度)。</summary>
public static Vector3 GridCenter
{
get
{
float z = BackZ + (Rows - 1) * RowStep * 0.5f;
return new Vector3(0f, GridY, z);
}
}
/// <summary>网格在 X 方向的宽度。</summary>
public static float GridWidth => Cols * ColStep;
/// <summary>网格在 Z 方向的深度。</summary>
public static float GridDepth => Rows * RowStep;
/// <summary>把地面坐标吸附到最近格位;不在网格范围内返回 -1。</summary>
public static int SnapToCell(Vector3 world)
{
int c = Mathf.RoundToInt(world.x / ColStep + (Cols - 1) * 0.5f);
@@ -50,6 +68,29 @@ public static class DeployGrid
return ToIndex(r, c);
}
/// <summary>
/// 宽松吸附:超出网格时夹到最近格位,只要离网格边缘不超过 tolerance 个格子就算命中。
/// 让玩家在网格边缘附近松手也能放下单位。
/// </summary>
public static int SnapToCellClamped(Vector3 world, float tolerance = 0.9f)
{
int c = Mathf.RoundToInt(world.x / ColStep + (Cols - 1) * 0.5f);
int r = Mathf.RoundToInt((world.z - BackZ) / RowStep);
int clampedC = Mathf.Clamp(c, 0, Cols - 1);
int clampedR = Mathf.Clamp(r, 0, Rows - 1);
// 超出网格多少(以格为单位)
int overC = c < 0 ? -c : (c >= Cols ? c - (Cols - 1) : 0);
int overR = r < 0 ? -r : (r >= Rows ? r - (Rows - 1) : 0);
if (overC > tolerance || overR > tolerance)
{
return -1;
}
return ToIndex(clampedR, clampedC);
}
/// <summary>把一组单位在网格宽度内均匀铺开,返回列号。</summary>
public static int SpreadColumn(int indexInGroup, int groupCount)
{
@@ -60,7 +101,7 @@ public static class DeployGrid
return Mathf.RoundToInt(step * (indexInGroup + 1));
}
/// <summary>默认阵型格位:近战在最前排(靠近敌人),远程在最后排。</summary>
/// <summary>默认阵型格位:近战在最靠敌方的一排,远程在最后排。</summary>
public static int DefaultCell(bool isMelee, int indexInGroup, int groupCount)
{
int row = isMelee ? Rows - 1 : 0;