예제 #1
0
        // Assignes buttons to the tableLayoutPanel tiles
        public GardenClass(int row, int col, ref TableLayoutPanel table,
                           Image myImage)
        {
            Turf = new Button();
            Turf.BackgroundImage = myImage;
            table.Controls.Add(Turf, row, col);
            Turf.Dock   = DockStyle.Fill;
            Turf.Click += Turf_Click;

            GardenClass[] typesOfPlatypus = new GardenClass[25];

            //for (int i = 0; i < typesOfPlatypus.Length; i++)
            //{
            //    typesOfPlatypus[i] =
            //}
        }
예제 #2
0
        private void buttonGarden_Click(object sender, EventArgs e)
        {
            tableLayoutPanel1.Controls.Clear();    // Clears the panel to start a new game

            int rows = tableLayoutPanel1.RowCount; // new variable that takes the number of rows in the tableLayourPanel in the design
            int cols = tableLayoutPanel1.ColumnCount;

            TurfsCollection = new GardenClass[rows, cols]; // 2-dimensional array with size same as the table size

            //Fill in the 2-dimensional array with pictures of the Platypuses
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    int value = rand.Next(3);
                    if (value == 0)
                    {
                        TurfsCollection[i, j] = new GardenClass(i, j, ref tableLayoutPanel1, Image.FromFile("images/Platypus.png"));
                        //platypusType = new PlatypusClass(1);
                        //platypusType.GetK();
                        m = 1;
                    }
                    else if (value == 1)
                    {
                        TurfsCollection[i, j] = new GardenClass(i, j, ref tableLayoutPanel1, Image.FromFile("images/RabidPlatypus.png"));
                        //platypusType = new PlatypusClass(3);
                        n = 3;
                    }
                    else
                    {
                        TurfsCollection[i, j] = new GardenClass(i, j, ref tableLayoutPanel1, Image.FromFile("images/StonePlatypus.png"));
                        k = 5;
                    }
                }
            }
        }