public Stack <Vector2Int> GetMovementPath(Dictionary <Vector2Int, Direction> possibleMoveLocs, Vector2Int dest) { Stack <Vector2Int> path = new Stack <Vector2Int>(); if (!possibleMoveLocs.ContainsKey(dest)) { return(null); } Vector2Int currLoc = dest; while (currLoc != mapPosition) { path.Push(currLoc); Direction dir = MapMath.GetOppositeDirection(possibleMoveLocs[currLoc]); switch (dir) { case Direction.N: currLoc = currLoc + MapMath.RelativeNorth; break; case Direction.S: currLoc = currLoc + MapMath.RelativeSouth; break; case Direction.E: currLoc = currLoc + MapMath.RelativeEast; break; case Direction.W: currLoc = currLoc + MapMath.RelativeWest; break; } } return(path); }