public Point GetNextPoint( Point point )
{
Point startingPoint = point;
int pointX = startingPoint.x;
int pointY = startingPoint.y;
if ( pointX == -1 && pointY == -1 ) return null;
// Debug.Log("GetNextPoint From >" + startingPoint.Debuger() );
Point lowestPoint = new Point(0,0);
int lowest = 10000;
foreach (Point movePoint in ValidMoves( pointX, pointY ))
{
int count = squares[ movePoint.x, movePoint.y ].DistanceSteps;
if (count < lowest){
lowest = count;
lowestPoint.x = movePoint.x;
lowestPoint.y = movePoint.y;
}
}
if (lowest != 10000){
// Mark the square as part of the path if it is the lowest number.
// Set the current position as the square with that number of steps.
squares[ lowestPoint.x, lowestPoint.y ].IsPath = true;
pointX = lowestPoint.x;
pointY = lowestPoint.y;
// Debug.Log( " RISE TO " + pointX + " "+ pointY );
squares[ pointX, pointY ].SetColor( Color.cyan );
return new Point( pointX, pointY );
}else{
// break;
}
if ( squares[pointX, pointY].ContentCode == TileContent.Finish )
{
Debug.Log(" //We went from monster to hero, so we're finished.");
return new Point( 20, 7 );
// break;
}
return null;
}