using UnityEngine; namespace HxGame { public enum CELL_SIDE { TopLeft = 0, Top = 1, TopRight = 2, BottomRight = 3, Bottom = 4, BottomLeft = 5, Left = 6, Right = 7 } public class CellNode { //格子坐标 //private readonly int _row; //private readonly int _column; private readonly int _x; private readonly int _y; private readonly int _index; //格子类型, 可移动、阻挡、隐藏 public CellType cellType = CellType.Obstacle; public int X { get { return _x; } } public int Y { get { return _y; } } public int index { get { return _index; } } float[] _crossCost; /// /// 格子的消耗,默认1. /// public float[] crossCost { get { return _crossCost; } set { _crossCost = value; } } /// /// 此单元格的组。可以指定不同的组与FindPath cellGroupMask参数一起使用 /// public int group = 1; //由于编辑器格子宽高可能不固定,所以动态换算 public Vector3 GetPos(float width, float height) { float x = _x * width + width / 2; float z = _y * height + height / 2; return new Vector3(x, 0.03f, z); } public CellNode(int x, int y, int index, CellType type) { _x = x; _y = y; _index = index; if (type == CellType.Safe) cellType |= CellType.Safe; else cellType = type; } } }