示例#1
0
 /* Metodo que reinicia el tablero. */
 public void Reiniciar(Grid tabLayout = null)
 {
     if (contenedor.IsBusy)
     {
         Inicializar(tabLayout);
         PistasPage.Reiniciar();
         if (contenedor.Temporizador)
         {
             contenedor.ReiniciarTemporizador();
         }
     }
 }
示例#2
0
        //METODOS PRIVADOS-----------------------------------

        /* Metodo que inicializa todo el juego: tablero, tiempo, lista de palabras,
         * puntuaciones. */
        private void Inicializar(Grid tabLayout = null)
        {
            int i, nivel, numLista;

            nivel          = contenedor.Nivel;
            numLista       = contenedor.EstiloPalabras;
            _totalPalabras = 4 + (nivel * 2);
            //generar _tablero
            if (_tablero == null)
            {
                _tablero = new Tablero(nivel, numLista);
            }
            else
            {
                _tablero.Inicializar(nivel, numLista);
            }

            //cargar lista de palabras en etiquetas
            if (LabelPalabras.Count != 0)
            {
                PistasPage.LimpiarLabels();
                LabelPalabras.Clear();
            }
            for (i = 0; i < TotalPalabras; i++)
            {
                LabelPalabras.Add(new Label {
                    Text = GetPalabra(i)
                });
            }

            Activos.Clear();
            LabelPalabras.TrimExcess();

            //vaciar grid de tablero
            if (TableroLayout != null)
            {
                TableroLayout.Children.Clear();
                TableroLayout.RowDefinitions.Clear();
                TableroLayout.ColumnDefinitions.Clear();
            }
            if (tabLayout != null) //en teoria es para la primera vez
            {
                TableroLayout = tabLayout;
            }

            //inicializar colunas y filas del grid
            i      = 0;
            nivel += 6; //reutilizo n
            while (i < nivel)
            {
                TableroLayout.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                TableroLayout.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                ++i;
            }

            //cargar labels e insertarlas en el grid
            tableroButtons = new LetraTablero[nivel][];
            char[][] tab = GetTablero().GetMatriz();
            for (i = 0; i < nivel; i++)
            {
                tableroButtons[i] = new LetraTablero[nivel];
                for (int j = 0; j < nivel; j++)
                {
                    tableroButtons[i][j]          = new LetraTablero(i, j, tab[i][j]);
                    tableroButtons[i][j].Clicked += OnTableroButtonClicked;
                    TableroLayout.Children.Add(tableroButtons[i][j], i, j);
                } //for j
            }     //for i

            //actualizar la puntuacion cuando se pasa de nivel o se reinicia tablero
            _puntuacion = -1;
            contenedor.AumentarPuntuacion();
        }