public void RenderImageToDesktop(string filename) { var height = PlacementGrid.Height; var width = PlacementGrid.Width; var bm = new Bitmap(width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (BlockedGrid.IsSet(x, y)) { bm.SetPixel(x, height - y - 1, Color.Red); } else if (Creep.IsSet(x, y)) { bm.SetPixel(x, height - y - 1, Color.Purple); } else if (Explored.IsSet(x, y)) { if (PlacementGrid.IsSet(x, y)) { bm.SetPixel(x, height - y - 1, Color.LightBlue); } else { bm.SetPixel(x, height - y - 1, Color.DarkBlue); } } else if (PlacementGrid.IsSet(x, y)) { if (NaturalGrid.IsSet(x, y)) { bm.SetPixel(x, height - y - 1, Color.Pink); } else { bm.SetPixel(x, height - y - 1, Color.Green); } } else { bm.SetPixel(x, height - y - 1, Color.Black); } } } bm.Save($"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\{filename}.BMP"); }
private bool ValidPlacement(int xPosition, int yPosition, int size, bool requiresCreep = false, bool requiresPower = false, bool avoidCreep = true, bool avoidNatural = false) { var mx = xPosition + size; var my = yPosition + size; for (int x = xPosition; x < mx; x++) { for (int y = yPosition; y < my; y++) { if (BlockedGrid.IsSet(x, y)) { return(false); } if (!PlacementGrid.IsSet(x, y)) { return(false); } if (requiresCreep && !Creep.IsSet(x, y)) { return(false); } if (avoidCreep && Creep.IsSet(x, y)) { return(false); } if (requiresPower && !Power.IsSet(x, y)) { return(false); } if (avoidNatural && NaturalGrid.IsSet(x, y)) { return(false); } } } return(true); }