private static void SetObstacleInCell(Cell pCell, int cellY, int cellX, Bitmap pBitmap, Obstacle pDefaultObstacle) { var height = Blueprint.Instance.CellHeight; var width = Blueprint.Instance.CellWidth; var whitePixels = 0; var blackPixels = 0; for (int i = cellX * (int)width; i < (cellX * (int)width) + width; i++) { for (int j = cellY * (int)height; j < cellY * (int)height + height; j++) { var color = pBitmap.GetPixel(i, j); if (color.ToArgb() != Color.White.ToArgb()) blackPixels++; else whitePixels++; } } var mean = (double)blackPixels / (whitePixels + blackPixels); if(mean > 0.0) pCell.Obstacle = pDefaultObstacle; }
/// <summary> /// Updates information about the Cell. /// </summary> public void UpdateCell(Cell pCell) { var coor = GetCellCoordinates(pCell.Id); mCells[(int)coor.Y][(int)coor.X] = pCell; }
public CellEventArgs(Cell pCell) { Cell = pCell; }
/// <summary> /// Raises event for observers that cell was updated. /// </summary> public void RaiseCellUpdateEvent(Cell pCell) { if (CellUpdated != null) CellUpdated(this, new CellEventArgs(pCell)); }