Esempio n. 1
0
 /// <summary>
 ///@Constructor
 /// </summary>
 /// <param nivelJuego="i"></param>
 public MemoryGame(int i)
 {
     InitializeComponent();
     PanelCartas.Hide();                           // oculta el panel hasta que el juego inicie
     LevelStrart      = i;                         // nivel
     this.WindowState = FormWindowState.Maximized; // meximizamos la pantalla
 }
Esempio n. 2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (LevelStrart == 10)
            {
                level.Text = "***** MASTER LEVEL (" + LevelStrart + ") *****";
            }
            else
            {
                level.Text = "" + LevelStrart;
            }
            if (LevelStrart == 11)
            {
                level.Text = "***** GOD LEVEL (" + LevelStrart + ") *****";
            }
            if (LevelStrart == 1)
            {
                level.Text = "*****  BABY LEVEL (" + LevelStrart + ") *****";
            }


            int[] filasColumnas  = LevelSetUp(LevelStrart);// array{filas,columnas}
            int   contadorCartas = 0;
            // filas columnas
            int filas    = filasColumnas[0];
            int columnas = filasColumnas[1];

            //tamaño del boton carta
            int tamanio = (PanelCartas.Height / filas) - 10;
            int ancho   = PanelCartas.Width;

            PanelCartas.Show();
            numeroCartas = filas * columnas;
            arreglaDatos();
            Pares.Text = contadorEncontradas + "/" + Imagenes.Length;
            int y = 10; ///posicion del primer boton

            for (int i = 1; i <= filas; i++)
            {
                int xlocation = ((ancho / columnas) - tamanio) / 2;
                for (int j = 1; j <= columnas; j++)
                {
                    if (contadorCartas != (Imagenes.Length * 2))
                    {
                        Button newButton = new Button();
                        {
                            newButton.Font      = new Font(newButton.Font.FontFamily, 1);
                            newButton.ForeColor = Color.Silver;
                            newButton.Location  = new Point(xlocation, y);
                            newButton.Size      = new Size(tamanio, tamanio);
                            newButton.Click    += selectCart;
                            newButton.BackColor = Color.Silver;
                            newButton.Name      = string.Format("carta" + contadorCartas);
                            newButton.Text      = datos[contadorCartas];
                            contadorCartas++;

                            /*if (inicio>=0 && inicio < Imagenes.Length) {
                             *  // newButton.BackgroundImage = Image.FromFile(System.IO.Directory.GetCurrentDirectory()+@"\image\"+ Imagenes[inicio]);
                             *  //var pic = new Bitmap(newButton.BackgroundImage, new Size(newButton.Width, newButton.Height));
                             *  // newButton.BackgroundImage = pic;
                             *  newButton.Text = Imagenes[inicio].Substring(0, Imagenes[inicio].LastIndexOf('.'));
                             *
                             * } else {
                             *  newButton.Name = string.Format("no" + inicio);
                             *  newButton.BackColor = Color.Silver;
                             * }
                             *
                             * inicio++;*/
                            PanelCartas.Controls.Add(newButton);
                        }
                        xlocation += (PanelCartas.Width / columnas);
                    }
                }
                y = y + tamanio + 4;
            }
        }