public int GetDirection(int Cell, int Cell2)
{
int MapWidth = _map.Width;
int[] ListChange = {
1,
MapWidth,
MapWidth * 2 - 1,
MapWidth - 1,
-1,
-MapWidth,
-MapWidth * 2 + 1,
-(MapWidth - 1)
};
dynamic Result = Cell2 - Cell;
for (int i = 7; i >= 0; i += -1)
{
if (Result == ListChange[i])
return i;
}
int ResultX = GetCellXCoord(Cell2) - GetCellXCoord(Cell);
int ResultY = GetCellYCoord(Cell2) - GetCellYCoord(Cell);
if (ResultX == 0)
{
if (ResultY > 0)
return 3;
return 7;
}
else if (ResultX > 0)
{
return 1;
}
else
{
return 5;
}
}