72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
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 MapManager.CellType cellType = MapManager.CellType.Obstacle;
|
||
|
||
public int X { get { return _x; } }
|
||
public int Y { get { return _y; } }
|
||
public int index { get { return _index; } }
|
||
|
||
float[] _crossCost;
|
||
/// <summary>
|
||
/// 格子的消耗,默认1.
|
||
/// </summary>
|
||
public float[] crossCost
|
||
{
|
||
get { return _crossCost; }
|
||
set { _crossCost = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 此单元格的组。可以指定不同的组与FindPath cellGroupMask参数一起使用
|
||
/// </summary>
|
||
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, MapManager.CellType type)
|
||
{
|
||
_x = x;
|
||
_y = y;
|
||
_index = index;
|
||
|
||
if (type == MapManager.CellType.Safe)
|
||
cellType |= MapManager.CellType.Safe;
|
||
else
|
||
cellType = type;
|
||
}
|
||
}
|
||
}
|
||
|