public void createArray() { //height and width of the original image file int image_width = m_myImage.Width; int image_height = m_myImage.Height; //height and width of the floor plan (in tiles) m_height = (int)(image_height / this.m_pixelsperfoot); m_width = (int)(image_width / this.m_pixelsperfoot); m_floorPlanArray = new FloorTile[m_height, m_width]; // height and width of the array representation of the new array to be created // each cell represent the walkable or non-walkable block defined earlier for (int row = 0; row < m_height; row++) { for (int column = 0; column < m_width; column++) { if (getWalkableValue(column, row) == 0) m_floorPlanArray[row, column] = new FloorTile(column, row, true,this); else m_floorPlanArray[row, column] = new FloorTile(column, row, false,this); } } }
public void createArray() { //height and width of the original image file int image_width = m_myImage.Width; int image_height = m_myImage.Height; //height and width of the floor plan (in tiles) m_height = (int)(image_height / this.m_pixelsperfoot); m_width = (int)(image_width / this.m_pixelsperfoot); m_floorPlanArray = new FloorTile[m_height, m_width]; // height and width of the array representation of the new array to be created // each cell represent the walkable or non-walkable block defined earlier for (int row = 0; row < m_height; row++) { for (int column = 0; column < m_width; column++) { if (getWalkableValue(column, row) == 0) { m_floorPlanArray[row, column] = new FloorTile(column, row, true, this); } else { m_floorPlanArray[row, column] = new FloorTile(column, row, false, this); } } } }
public List <FloorTile> condenseList(List <FloorTile> path) { List <FloorTile> condensedList = new List <FloorTile>(); FloorTile lastTile = path[0]; condensedList.Add(path[0]); for (int i = 1; i < path.Count; i++) { if (path[i].Position.Y == lastTile.Position.Y) // moving vertically { while (i < path.Count && path[i].Position.Y == lastTile.Position.Y && i < path.Count - 1) // walk until the next turn { i++; } } else // moving horizontally { while (i < path.Count && path[i].Position.X == lastTile.Position.X) // walk until the next turn { i++; } } lastTile = path[i - 1]; condensedList.Add(path[i - 1]); // add the turning point to the new list; } return(condensedList); }
public void Connect() { for (int row = 0; row < m_height; row++) { for (int column = 0; column < m_width; column++) { FloorTile tile = getTile(column, row); tile.ResetWalkableNeighbors(); } } }
public Boolean setTargetTile(int x, int y) { FloorTile target_tile; if (m_target_tile != null) { m_target_tile.SetTarget(false); } { target_tile = getTile(x, y); if (target_tile.Iswalkable()) { m_target_tile = target_tile; m_target_tile.SetTarget(true); return(true); } } return(false); }
public Boolean setStartTile(int x, int y) { FloorTile start_tile; start_tile = getTile(x, y); if (m_start_tile != null) { m_start_tile.SetStart(false); } { if (start_tile.Iswalkable()) { m_start_tile = start_tile; m_start_tile.SetStart(true); return(true); } } return(false); }
public void ResetWalkableNeighbors() { FloorTile tile1 = m_floorPlan.getTile(this.m_location.X - 1, this.m_location.Y); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X + 1, this.m_location.Y); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y - 1); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y + 1); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } }
public Boolean setTargetTile(int x, int y) { FloorTile target_tile; if (m_target_tile != null) m_target_tile.SetTarget(false); { target_tile = getTile(x, y); if (target_tile.Iswalkable()) { m_target_tile = target_tile; m_target_tile.SetTarget(true); return true; } } return false; }
public Boolean setStartTile(int x, int y) { FloorTile start_tile; start_tile = getTile(x,y); if (m_start_tile != null) m_start_tile.SetStart(false); { if (start_tile.Iswalkable()) { m_start_tile = start_tile; m_start_tile.SetStart(true); return true; } } return false; }