Пример #1
0
 public bool Comprobar(smTile[] encaje, string[] orden)
 {
     try
     {
         smTile[] comprobanding = new smTile[encaje.Length];
         for (int yes = 0; yes < encaje.Length; yes++)
         {
             comprobanding[yes] = new smTile(orden[yes]);
             if (!(compare(encaje[yes].FilledImage, comprobanding[yes].FilledImage)))
             {
                 return(false);
             }
         }
         return(true);
     }
     catch
     {
         Console.WriteLine("Obveo que falló papuh e,e");
         return(false);
     }
 }
Пример #2
0
        /// <summary>
        /// Empty constructor
        /// </summary>
        public SecuenciaImagenes(int numImagenes, Jugador nino, string rutaDeImagenes, string[] ordenCorrectoImagenes)
        {
            InitializeComponent();
            this.BackColor      = Color.Chocolate;
            this.lblNombre.Text = nino.GetNombre() + " " + nino.GetApellido();
            int    xSpot;
            int    ySpot;
            int    pp;
            string pathImg = rutaDeImagenes;

            string[] imagenes = Directory.GetFiles(pathImg, "*.png");
            ordenCorrecto = ordenCorrectoImagenes;
            Random rnd = new Random();

            bool[] imgUsada = new bool[numImagenes];
            // Initialize the grid
            grid = new smTile[numImagenes];

            // Initialize each tile in the grid
            for (int row = 0; row < numImagenes; row++)
            {
                try
                {
                    pp = rnd.Next() % numImagenes;
                    while (imgUsada[pp])
                    {
                        pp = rnd.Next() % numImagenes;
                    }

                    // Create the tile
                    grid[row] = new smTile(imagenes[pp]);
                    grid[row].PutItem(grid[row].FilledImage);
                    imgUsada[pp] = true;

                    // Set the location for the tile
                    if (row < 4)
                    {
                        xSpot = (row * anchoImagen) + bordeEnGrid;
                        ySpot = bordeEnGrid;
                        grid[row].Location = new Point(xSpot, ySpot);
                    }
                    else
                    {
                        xSpot = ((row - 4) * anchoImagen) + bordeEnGrid;
                        ySpot = altoImagen + bordeEnGrid + 30;
                        grid[row].Location = new Point(xSpot, ySpot);
                    }

                    // Add the tile to the form
                    this.Controls.Add(grid[row]);
                }
                catch
                {
                    // Just catch an exception, no error handling yet
                    Console.WriteLine("Exception caught for tile[{0}]", row);
                }
            }

            encaje = new smTile[numImagenes];

            for (int i = 0; i < numImagenes; i++)
            {
                try
                {
                    encaje[i] = new smTile();
                    // Set the location for the tile
                    if (i < 4)
                    {
                        xSpot = (i * anchoImagen) + bordeEnGrid;
                        ySpot = 3 * altoImagen;
                        encaje[i].Location = new Point(xSpot, ySpot);
                    }
                    else
                    {
                        xSpot = ((i - 4) * anchoImagen) + bordeEnGrid;
                        ySpot = 4 * altoImagen + bordeEnGrid;
                        encaje[i].Location = new Point(xSpot, ySpot);
                    }
                    this.Controls.Add(encaje[i]);
                }
                catch
                {
                    Console.WriteLine("Error en: {0}", i);
                }
            }
        }