public bool IsStraightline(Vector2 startVec, Vector2 destVec)
{
Point start = new Point((int)startVec.x, (int)startVec.y);
Point dest = new Point((int)destVec.x, (int)destVec.y);
Node startNode = new Node(start);
Node curNode = startNode;
Node endNode = new Node(dest);
if (!CanWalkOn(endNode))
{
return false;
}
int x = 0;
for (int i = 0; i < Mathf.Abs(start.x - dest.x); i++ )
{
if (start.x < dest.x)
{
x = start.x + i;
}
else
{
x = start.x - i;
}
int y = 0;
for (int j = 0; j < Mathf.Abs(start.y - dest.y);j++ )
{
if (start.y < dest.y)
{
y = start.y + j;
}
else
{
y = start.y - j;
}
int index = y * Game.mapW + x;
if (Game.map[index] == 1)
{
//Debug.Log("false");
return false;
}
}
}
//Debug.Log("true");
return true;
}