From fc2cfdad0d3cfb3844681855c1c45d9415f5ee8e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Tue, 9 May 2023 19:28:57 +0800 Subject: *misc --- marching/Assets/Scripts/Battle/GridMap.cs | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 marching/Assets/Scripts/Battle/GridMap.cs (limited to 'marching/Assets/Scripts/Battle/GridMap.cs') diff --git a/marching/Assets/Scripts/Battle/GridMap.cs b/marching/Assets/Scripts/Battle/GridMap.cs new file mode 100644 index 0000000..c99bf4a --- /dev/null +++ b/marching/Assets/Scripts/Battle/GridMap.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 用Grid托管需要实现这个接口 +/// +public interface IGridMapObject +{ + // 坐标,transform.position + public Vector2 coordinate { get; } +} + +public class GridCell +{ + public List m_Object; +} + +/// +/// 用网格划分场景,不依赖形状,只依赖位置 +/// +public class GridMap +{ + + // 单个cell的大小 + private Vector2 m_CellSize; + + // 整个grid的范围 x, y, xcount, ycount + private Vector4 m_Range; + + // 左上角开始索引 + private List m_GridCells; + + public GridMap() + { + m_GridCells = new List(); + } + + private int GetGridIndex(Vector2 pos) + { + + + return -1; + } + +} \ No newline at end of file -- cgit v1.1-26-g67d0