Exemplo n.º 1
0
        /// <summary>
        /// Generates the items
        /// </summary>
        private void GenerateItems()
        {
            Random rnd = new Random();

            m_Message = new BuildMessage();

            MapViewer.Maps oldMap = Pandora.Map.Map;
            Pandora.Map.Map = (MapViewer.Maps)m_Map;

            for (int x = 0; x < m_Rectangle.Width; x++)
            {
                for (int y = 0; y < m_Rectangle.Height; y++)
                {
                    if (!m_Grid[x, y])
                    {
                        continue;
                    }

                    RandomTile tile = m_TileSet.Tiles[rnd.Next(m_TileSet.Tiles.Count)] as RandomTile;

                    foreach (int id in tile.Items)
                    {
                        BuildItem item = new BuildItem();
                        item.ID = id;

                        // Hue
                        int hue = m_Hue;

                        if (m_RandomHues != null)
                        {
                            // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
                            hue = m_RandomHues.Hues[rnd.Next(m_RandomHues.Hues.Count)];
                            // Issue 10 - End
                        }

                        item.Hue = hue;

                        // Location
                        item.X = m_Rectangle.X + x;
                        item.Y = m_Rectangle.Y + y;

                        if (m_Z != -1)
                        {
                            item.Z = Pandora.Map.GetMapHeight(new Point(item.X, item.Y));
                        }
                        else
                        {
                            item.Z = m_Z;
                        }


                        m_Message.Items.Add(item);
                    }
                }
            }

            Pandora.Map.Map = oldMap;
        }
Exemplo n.º 2
0
        /// <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
        {
            RandomBrushMessage msg = new RandomBrushMessage();
            Random             rnd = new Random();

            RandomizeBrush(fill);

            for (int x = 0; x < m_Width; x++)
            {
                for (int y = 0; y < m_Height; y++)
                {
                    if (m_Grid[x, y])
                    {
                        RandomTile tile = tileset.Tiles[rnd.Next(tileset.Tiles.Count)] as RandomTile;

                        foreach (int id in tile.Items)
                        {
                            BuildItem 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 - (m_Width / 2);
                            item.Y = y - (m_Height / 2);

                            msg.Items.Add(item);
                        }
                    }
                }
            }

            return(msg);
        }
Exemplo n.º 3
0
		private void bAdd_Click(object sender, System.EventArgs e)
		{
			RandomTile tile = new RandomTile();

			tile.Name = txName.Text;

			foreach( string s in txItems.Lines )
			{
				try
				{
					int id = int.Parse( s );
					tile.Items.Add( id );
				}
				catch {}
			}

			if ( tile.Items.Count == 0 )
			{
				MessageBox.Show( Pandora.Localization.TextProvider[ "Random.InvalidIDs" ] );
				return;
			}

			txName.Text = "";
			txItems.Text = "";

			m_TileSet.Tiles.Add( tile );
			lst.Items.Add( tile );
		}
Exemplo n.º 4
0
		private void labQuick_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
		{
			BoxDeco deco = e.Data.GetData( typeof( BoxDeco ) ) as BoxDeco;

			if ( deco != null )
			{
				RandomTile tile = new RandomTile();

				tile.Items.Add( deco.ID );
				tile.Name = deco.Name;

				m_TileSet.Tiles.Add( tile );
				lst.Items.Add( tile );
			}
		}