完成阻隔点
This commit is contained in:
@@ -49,7 +49,7 @@ public class GridSelector : MonoBehaviour
|
||||
//创建新的地图默认为全部是可行走区域
|
||||
for (int i = 0; i < totalNumber; i++)
|
||||
{
|
||||
dataArray[i].barrier = (int)CellType.None;
|
||||
dataArray[i].barrier = (int)CellType.Move;
|
||||
}
|
||||
RefreshPlaneRender();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class GridSelector : MonoBehaviour
|
||||
}
|
||||
public int getdataByPos(Vector3 pos)
|
||||
{
|
||||
int hitIndex = Mathf.FloorToInt(pos.x / map.sideLength) + Mathf.FloorToInt(pos.z / map.sideLength) * horizontalNumber;
|
||||
int hitIndex = Mathf.FloorToInt(pos.x / map.sideWidth) + Mathf.FloorToInt(pos.z / map.sideHeight) * horizontalNumber;
|
||||
return hitIndex;
|
||||
}
|
||||
private void Awake()
|
||||
@@ -366,7 +366,9 @@ public class GridSelector : MonoBehaviour
|
||||
}
|
||||
private void setDataCellType(int index,bool IsCancel)
|
||||
{
|
||||
if (true)
|
||||
if (UICellEditor.Instance == null) return;
|
||||
if (UICellEditor.Instance.editorGrid == CellType.Move ||
|
||||
UICellEditor.Instance.editorGrid == CellType.Obstacle)
|
||||
{
|
||||
if (IsCancel)
|
||||
{
|
||||
@@ -385,7 +387,7 @@ public class GridSelector : MonoBehaviour
|
||||
dataArray[index].barrier |= (int)CellType.Obstacle;
|
||||
}
|
||||
}
|
||||
else if (true)
|
||||
else if (UICellEditor.Instance.editorGrid == CellType.Safe)
|
||||
{
|
||||
if (IsCancel)
|
||||
{
|
||||
@@ -399,7 +401,7 @@ public class GridSelector : MonoBehaviour
|
||||
dataArray[index].barrier |= (int)CellType.Safe;
|
||||
}
|
||||
}
|
||||
else if (true)
|
||||
else if (UICellEditor.Instance.editorGrid == CellType.Stall)
|
||||
{
|
||||
if (IsCancel)
|
||||
{
|
||||
@@ -413,12 +415,50 @@ public class GridSelector : MonoBehaviour
|
||||
dataArray[index].barrier |= (int)CellType.Stall;
|
||||
}
|
||||
}
|
||||
else if (UICellEditor.Instance.editorGrid == CellType.Hide)
|
||||
{
|
||||
if (IsCancel)
|
||||
{
|
||||
if ((dataArray[index].barrier & (int)CellType.Hide) != 0)
|
||||
{
|
||||
dataArray[index].barrier &= ~(int)CellType.Hide;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dataArray[index].barrier |= (int)CellType.Hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FullAllArea()
|
||||
{
|
||||
for (int i = 0; i < dataArray.Length; i++)
|
||||
{
|
||||
CellType cell = (CellType)dataArray[i].barrier;
|
||||
if (!cell.HasFlag(UICellEditor.Instance.editorGrid))
|
||||
{
|
||||
dataArray[i].barrier |= (int)UICellEditor.Instance.editorGrid;
|
||||
}
|
||||
}
|
||||
RefreshPlaneRender();
|
||||
}
|
||||
public void ClearSelectArea()
|
||||
{
|
||||
for (int i = 0; i < dataArray.Length; i++)
|
||||
{
|
||||
CellType cell = (CellType)dataArray[i].barrier;
|
||||
if (cell.HasFlag(UICellEditor.Instance.editorGrid))
|
||||
{
|
||||
dataArray[i].barrier &= ~(int)UICellEditor.Instance.editorGrid;
|
||||
}
|
||||
}
|
||||
RefreshPlaneRender();
|
||||
}
|
||||
|
||||
public void RefreshPlaneRender()
|
||||
{
|
||||
moveNum = 0;
|
||||
for (int i = 0; i < dataArray.Length; i++) {
|
||||
//int barrier = dataArray[i].barrier;
|
||||
setDataColor(i);
|
||||
CellType cell = (CellType)dataArray[i].barrier;
|
||||
if (cell.HasFlag(CellType.Move))
|
||||
@@ -434,10 +474,11 @@ public class GridSelector : MonoBehaviour
|
||||
x = index % horizontalNumber;
|
||||
y = index / horizontalNumber;
|
||||
}
|
||||
//TODO 这里有改动,应该是对的
|
||||
private Vector2 GetCenterPosByIndex(int index)
|
||||
{
|
||||
GetXyByIndex(index, out int x, out int y);
|
||||
return new Vector2(x + 0.5f, y + 0.5f) * map.sideLength;
|
||||
return new Vector2((x + 0.5f)*map.sideWidth, (y + 0.5f) * map.sideHeight);
|
||||
}
|
||||
private bool Pnpoly(Vector2 gridPos, Vector2 pos0, Vector2 pos1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user