private void LoadTiles()
        {
            try
            {
                int xAxis = 10;
                int yAxis = 5;

                int PlatFormHeight = (int)(Height * 0.3) / yAxis;
                int PlatFormWidth  = (Width - (xAxis - 5)) / xAxis;

                cpb = new CustomPictureBox[yAxis, xAxis];

                for (int i = 0; i < yAxis; i++)
                {
                    for (int j = 0; j < xAxis; j++)
                    {
                        cpb[i, j] = new CustomPictureBox();

                        if (i == 0)
                        {
                            cpb[i, j].Golpes = 2;
                        }
                        else
                        {
                            cpb[i, j].Golpes = 1;
                        }


                        //Position from Height, Position from Width
                        cpb[i, j].Height = PlatFormHeight;
                        cpb[i, j].Width  = PlatFormWidth;


                        //Position from Left, Position from Top

                        cpb[i, j].Left = j * PlatFormWidth;
                        cpb[i, j].Top  = i * PlatFormHeight;

                        //If the value from i = 0, then put on the route from the brick pictureBox
                        cpb[i, j].BackgroundImage       = Image.FromFile("../../Textures/" + GRN() + ".png");
                        cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                        cpb[i, j].Tag = "tileTag";

                        Controls.Add(cpb[i, j]);
                    }
                }
            }
            catch (Exception exceptionGameOver)
            {
                MessageBox.Show("The game has end");
            }
        }
示例#2
0
        //This function, permits fill the platform with bricks, and pick the photos from code
        private void LoadTiles()
        {
            try
            {
                int xAxis = 10;
                int yAxis = 5;

                int PlatFormHeight = (int)(Height * 0.3) / yAxis;
                int PlatFormWidth  = (Width - (xAxis - 5)) / xAxis;

                cpb = new CustomPictureBox[yAxis, xAxis];

                for (int i = 0; i < yAxis; i++)
                {
                    for (int j = 0; j < xAxis; j++)
                    {
                        cpb[i, j] = new CustomPictureBox();

                        if (i == 2)
                        {
                            cpb[i, j].Hits = 2;
                        }
                        else
                        {
                            cpb[i, j].Hits = 1;
                        }

                        //Setting the size
                        cpb[i, j].Height = PlatFormHeight;
                        cpb[i, j].Width  = PlatFormWidth;

                        //Position from Left, Position from Top
                        cpb[i, j].Left = j * PlatFormWidth;
                        cpb[i, j].Top  = i * PlatFormHeight + scorePanel.Height + 1;

                        int imageBack = 0;

                        if (i % 2 == 0 && j % 2 == 0)
                        {
                            imageBack = 3;
                        }
                        else if (i % 2 == 0 && j % 2 != 0)
                        {
                            imageBack = 4;
                        }
                        else if (i % 2 != 0 && j % 2 == 0)
                        {
                            imageBack = 4;
                        }
                        else
                        {
                            imageBack = 3;
                        }

                        //Generar un numero aleatorio para que sean blindados...
                        //Tener cuidado con los numero aleatorios, necesitan seed que se tome con el tiempo
                        if (i == 2)
                        {
                            cpb[i, j].BackgroundImage = Image.FromFile("../../Textures/Tileblinded.png");
                            cpb[i, j].Tag             = "blinded";
                        }
                        else
                        {
                            cpb[i, j].BackgroundImage = Image.FromFile("../../Textures/" + imageBack + ".png");
                            cpb[i, j].Tag             = "tileTag";
                        }

                        cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                        Controls.Add(cpb[i, j]);
                    }
                }
            }
            catch (Exception exceptionGameOver)
            {
                MessageBox.Show("The game has end");
            }
        }