private void bRunBrush_Click(object sender, EventArgs e) { if (!EnsureConditions()) { return; } var fill = pBarFill2.Value / 100d; var width = (int)nWidth.Value; var height = (int)nHeight.Value; var brush = new RandomBrush(width, height); var tileset = cmbTileSet.SelectedItem as RandomTilesList; RandomBrushMessage msg = null; if (rRandomHue.Checked) { var hues = cmbHues.SelectedItem as HuesCollection; msg = brush.CreateMessage(tileset, hues, fill); } else { if (rNoHue.Checked) { msg = brush.CreateMessage(tileset, 0, fill); } else { msg = brush.CreateMessage(tileset, Pandora.Profile.Hues.SelectedIndex, fill); } } Pandora.BoxConnection.SendToServer(msg); }
/// <summary> /// Creates the message that performs the brush /// </summary> /// <param name="tileset">The tileset for the brush</param> /// <param name="hues">A list of hues to use for the brush</param> /// <param name="fill">The are percentage to fill</param> /// <returns>The server message created</returns> // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert private RandomBrushMessage CreateMessage(RandomTilesList tileset, List <int> hues, double fill) // Issue 10 - End { var msg = new RandomBrushMessage(); var rnd = new Random(); RandomizeBrush(fill); for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { if (m_Grid[x, y]) { var tile = tileset.Tiles[rnd.Next(tileset.Tiles.Count)] as RandomTile; foreach (int id in tile.Items) { var item = new BuildItem(); item.ID = id; // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert item.Hue = hues[rnd.Next(hues.Count)]; // Issue 10 - End item.X = x - (Width / 2); item.Y = y - (Height / 2); msg.Items.Add(item); } } } } return(msg); }