//Llenamos la matriz con los bloques private void LoadTiles() { int xAxis = 6; int yAxis = 4; // Aqui reducimos el tamaño de los bloques para que pueda encajar en el espacio asignado del juego int pbHeight = (int)(Height * 0.3) / yAxis; int pbWidth = (int)(Width / 2.15) / xAxis; string number = "7"; int block; _cpb = new CustomPictureBox[yAxis, xAxis]; for (int i = 0; i < yAxis; i++) { // Aqui se manda a llamar la función RandomNumber para poder realizar la distribución de bloques // por cada fila. block = RandomNumber(ref number); number += block; for (int j = 0; j < xAxis; j++) { _cpb[i, j] = new CustomPictureBox(); // Si el bloque es igual al bloque numero 0, tendra un total de 3 golpes para ser destruido, // y tendra el nombre clave: ThreeHit. if (block == 0) { _cpb[i, j].hits = 3; _cpb[i, j].Tag = "ThreeHit"; } // Si el bloque es igual al bloque numero 6, tendra un total de 2 golpes para ser destruido, // y tendra el nombre clave: TwoHit. else if (block == 6) { _cpb[i, j].hits = 2; _cpb[i, j].Tag = "TwoHit"; } // Si el bloque es igual a un número dentro del rango 1-5, // solo tendra un golpe para ser destruido, y tendra el nombre clave: OneHit. else { _cpb[i, j].hits = 1; _cpb[i, j].Tag = "OneHit"; } _cpb[i, j].Height = pbHeight; _cpb[i, j].Width = pbWidth; //Aqui lo que hicimos fue que le cambiamos las coordenadas de aparicion de los bloques, para que //encajara con el espacio asignado del juego _cpb[i, j].Left = (int)(Width * 0.30) + j * pbWidth; _cpb[i, j].Top = (int)(Height * 0.22) + i * pbHeight; _cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/_" + (block) + ".png"); _cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; _cpb[i, j].BackColor = Color.Transparent; Controls.Add(_cpb[i, j]); } } }
// Metodo para cargar los bloques private void LoadTiles() { // Variables auxiliares para el calculo de tamano de cada cpb int xAxis = 20, yAxis = 5; remainingPb = xAxis * yAxis; int pbHeight = (int)(Height * 0.3) / yAxis; int pbWidth = (Width - (xAxis - 20)) / xAxis; cpb = new CustomPictureBox[yAxis, xAxis]; // Rutina de instanciacion y agregacion al UserControl for (int i = 0; i < yAxis; i++) { for (int j = 0; j < xAxis; j++) { cpb[i, j] = new CustomPictureBox(); if (i == 3) { cpb[i, j].Hits = 2; } else { cpb[i, j].Hits = 1; } // Seteando el tamano cpb[i, j].Height = pbHeight; cpb[i, j].Width = pbWidth; // Posicion de left, y posicion de top cpb[i, j].Left = j * pbWidth; cpb[i, j].Top = i * pbHeight + scorePanel.Height + 1; // Si el valor de i = 3, entonces colocar ruta de imagen de bloque blindada if (i == 3) { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/armored.png"); cpb[i, j].Tag = "blinded"; } else { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + GRN() + ".png"); cpb[i, j].Tag = "tileTag"; } cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; Controls.Add(cpb[i, j]); } } }
//Cargar bloques private void LoadTiles() { int xAxis = 10, yAxis = 7; //Altura y anchura de los bloques int cpbheight = (int)(Height * 0.5) / yAxis; int cpbwidth = Width / xAxis; cpb = new CustomPictureBox[yAxis, xAxis]; for (int i = 0; i < yAxis; i++) { for (int j = 0; j < xAxis; j++) { //Cantidad de golpes necesarios cpb[i, j] = new CustomPictureBox(); if (i == 0) { cpb[i, j].Hits = 3; } else if (i == 1) { cpb[i, j].Hits = 2; } else { cpb[i, j].Hits = 1; } //Altura y anchura cpb[i, j].Height = cpbheight; cpb[i, j].Width = cpbwidth; //Posiciones cpb[i, j].Top = i * cpbheight; cpb[i, j].Left = j * cpbwidth; //Cargar imagen cpb[i, j].BackgroundImage = Image.FromFile($"../../Recursos/{i+1}.png"); cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; cpb[i, j].Tag = "tileTag"; Controls.Add(cpb[i, j]); } } }
private void LoadTiles() { int xAxis = 10, yAxis = 5; int pbWidth = (Width - (xAxis - 5)) / xAxis; int pbHeight = (int)(Height * 0.3) / yAxis; 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 == 4) { cpb[i, j].Hits = 2; } else { cpb[i, j].Hits = 1; } // Seteando el tamano cpb[i, j].Height = pbHeight; cpb[i, j].Width = pbWidth; // Posicion de left, y posicion de top cpb[i, j].Left = j * pbWidth; cpb[i, j].Top = i * pbHeight + 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; } if (i == 4) { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/tb1.png"); cpb[i, j].Tag = "blinded"; } else { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + imageBack + ".png"); cpb[i, j].Tag = "tileTag"; } cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; Controls.Add(cpb[i, j]); } } }
private void LoadTiles() { // Variables auxiliares para el calculo de tamano de cada cpb int xAxis = 10, yAxis = 5; remainingPb = xAxis * yAxis; int pbWidth = (Width - (xAxis - 5)) / xAxis; int pbHeight = (int)(Height * 0.3) / yAxis; cpb = new CustomPictureBox[yAxis, xAxis]; // Rutina de instanciacion y agregacion al UserControl for (int i = 0; i < yAxis; i++) { for (int j = 0; j < xAxis; j++) { cpb[i, j] = new CustomPictureBox(); if (i == 4) { cpb[i, j].Hits = 2; } else { cpb[i, j].Hits = 1; } // Seteando el tamano cpb[i, j].Height = pbHeight; cpb[i, j].Width = pbWidth; // Posicion de left, y posicion de top cpb[i, j].Left = j * pbWidth; cpb[i, j].Top = i * pbHeight + scorePanel.Height + 1; int imageBack; 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; } if (i == 4) { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/tb1.png"); cpb[i, j].Tag = "blinded"; } else { cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + imageBack + ".png"); cpb[i, j].Tag = "tileTag"; } cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; Controls.Add(cpb[i, j]); } } }
private void LoadTiles() { int xAxis = 10, yAxis = 5; //10 tiles de "X" - y 5 tiles de "Y" | int pbWidth = (Width - (xAxis - 5)) / xAxis; //ancho de la imagen int pbHeight = (int)(Height * 0.3) / yAxis; //altura de la imagen cpb = new CustomPictureBox[yAxis, xAxis]; //matriz d picturesbox en donde estan ubicaos for (int i = 0; i < yAxis; i++) { for (int j = 0; j < xAxis; j++) { //Level desing CREANDO LOS TILES //BASE cpb[i, j] = new CustomPictureBox(); if (i == 0) //Son los tiles q estan al final de double hit { cpb[i, j].Golpes = 2; } else { cpb[i, j].Golpes = 1; } cpb[i, j].Height = pbHeight; cpb[i, j].Width = pbWidth; // Posicion de left, y posicion de top cpb[i, j].Left = j * pbWidth; cpb[i, j].Top = i * pbHeight + scores.Height + 1; string tile = "Tile_"; if (i == 0) { tile = tile + "Hard"; } else if (i % 2 == 0 && j % 2 == 0) { tile = tile + "Yellow"; } else if (i % 2 == 0 && j % 2 != 0) { tile = tile + "Purple"; } else if (i % 2 != 0 && j % 2 == 0) { tile = tile + "Purple"; } else { tile = tile + "Yellow"; } cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + tile + ".png"); cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; cpb[i, j].Tag = "tileTag"; Controls.Add(cpb[i, j]); } } DatosJuego.tiles = cpb.Length; }
private void LoadTiles() { int x = 10, y = 5; int pbWidth = (Width - (x - 5)) / x; int pbHeight = (int)(Height * 0.3) / y; cpb = new CustomPictureBox[y, x]; for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cpb[i, j] = new CustomPictureBox(); // no se como seria // y ase ocmo pero umm esta complciado yo no entiendo jaja if ((i == 4 || i == 0) & (j % 2 == 0)) { cpb[i, j].Hits = 2; } else if (i == 2) { cpb[i, j].Hits = 2; } else { cpb[i, j].Hits = 1; } cpb[i, j].Height = pbHeight; cpb[i, j].Width = pbWidth; cpb[i, j].Left = j * pbWidth; cpb[i, j].Top = i * pbHeight + Scores.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; } if ((i == 4 || i == 0) & (j % 2 == 0)) { cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/13.png"); cpb[i, j].Tag = "blindedBlue"; } else if (i == 2) { cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/12.png"); cpb[i, j].Tag = "blinded"; } else { cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/" + GenerateTiles() + ".png"); cpb[i, j].Tag = "tileTag"; } cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch; Controls.Add(cpb[i, j]); } } }