This commit is contained in:
tangbin
2025-06-22 15:21:25 +08:00
parent 89d395440a
commit 1cb6dc502f
22 changed files with 2241 additions and 7346 deletions

View File

@@ -84,6 +84,8 @@ public class GridSelector : MonoBehaviour
{
return getMapGrid(new Vector2(pos.x,pos.y));
}
public Vector2Int getMapGrid(Vector2 pos)
{
var grid = new Vector2Int();
@@ -91,6 +93,10 @@ public class GridSelector : MonoBehaviour
grid.y = Mathf.FloorToInt(pos.y / map.sideHeight);
return grid;
}
public Vector2 getPosByGrid(Vector2Int grid)
{
return new Vector2(grid.x * map.sideWidth + map.sideWidth/2, grid.y * map.sideHeight + map.sideHeight / 2);
}
private void Awake()
{
mapRenderer = GetComponent<MeshRenderer>();