/**********************************************************************PAINT*/ /**********************************************************************PAINT*/ /**********************************************************************PAINT*/ private void drawSurface_Paint(object sender, PaintEventArgs e) { // Good ol' graphics object. Graphics g = e.Graphics; /******************************************** DRAW TILES*/ /* This is a work around for not being able to iterate through elements in an Enum. We have to create a string * array that contains the names of each element in the enum, then cycle through each element in the string array instead. */ String[] LAYERS = Enum.GetNames(typeof(Map.LAYER)); // Draw each layer of the map separately, starting with the floor. foreach (String currentElement in LAYERS) { // Convert the current element string to our Enum type "Layer" Map.LAYER THIS_LAYER = (Map.LAYER)Enum.Parse(typeof(Map.LAYER), currentElement); // Iterate through every tile and draw its appropriate layer image. for (int i = 0; i < map.GetColumns(); i++) { for (int j = 0; j < map.GetRows(); j++) { // Check if this layer is not the floor. If it is, just draw it and don't worry about anything else. if (THIS_LAYER != Map.LAYER.FLOOR) { // If this layer isn't the floor, make sure it isn't empty before you draw it. if (!map.GetTiles()[i, j].IsTileLayerEmpty(THIS_LAYER)) { DrawTile(g, i, j, THIS_LAYER); } } else { DrawTile(g, i, j, THIS_LAYER); } } } } // Draw the grid if it is turned on. if (map.IsGridOn()) { for (int i = 0; i < map.GetColumns(); i++) { for (int j = 0; j < map.GetRows(); j++) { g.DrawRectangle(rectPen, (i * map.GetTileSize()) + map.GetMapRootX(), (j * map.GetTileSize()) + map.GetMapRootY(), map.GetTileSize(), map.GetTileSize()); } } } }