private void labelAnswer1_Click(object sender, EventArgs e) { sonidos.sonidoOpcion(); sameBackColor(); labelAnswer1.BackColor = Color.LightSteelBlue; verResp = labelAnswer1.Text; labelNext.Visible = true; }
private void label_Click(object sender, EventArgs e) //Esto hace que cuando se les dé click aparezcan las imagenes { // The timer is only on after two non-matching // icons have been shown to the player, // so ignore any clicks if the timer is running if (timer1.Enabled == true) { return; } Label clickedLabel = sender as Label; //sender importante if (clickedLabel != null) { /* * // If the clicked label is black, the player clicked * // an icon that's already been revealed -- * // ignore the click * if (clickedLabel.ForeColor == Color.Black) * return; * */ //Si la imagen es del mismo color del fondo ya se encontró //Se ignora el click if (clickedLabel.ForeColor == clickedLabel.BackColor) { return; } // If firstClicked is null, this is the first icon // in the pair that the player clicked, // so set firstClicked to the label that the player // clicked, change its color to black, and return //Si firstClicked es null, es el primero en recibir un click //Se le asigna el label que el usuario clickeó, cambia de color y se retorna if (firstClicked == null) { sonidos.sonidoOpcion(); firstClicked = clickedLabel; firstClicked.ForeColor = Color.Yellow; return; } //Si se llega hasta acá, firstClick no es null y le toca a secondClicked //Se le asigna el label que el usuario clickeó y cambia de color sonidos.sonidoOpcion(); secondClicked = clickedLabel; secondClicked.ForeColor = Color.Yellow; // If the player clicked two matching icons, keep them // black and reset firstClicked and secondClicked // so the player can click another icon //Si se encuentran dos iconos iguales, desaparecen y //firstClicked y secondClicked se ponen en null //Si uno esta en español y el otro esté en ingles if (pairsFamilySpanishReal.ContainsKey(firstClicked.Text) && pairsFamilyEnglishReal.ContainsKey(secondClicked.Text)) { if (pairsFamilySpanishReal[firstClicked.Text] == pairsFamilyEnglishReal[secondClicked.Text]) { sonidos.sonidoGanarSebastian(); firstClicked.ForeColor = firstClicked.BackColor; secondClicked.ForeColor = firstClicked.BackColor; //Verificar si ya se ganó el juego CheckForWinner(); firstClicked = null; secondClicked = null; return; } } else if //Si uno esta en ingles y el otro este en español (pairsFamilyEnglishReal.ContainsKey(firstClicked.Text) && pairsFamilySpanishReal.ContainsKey(secondClicked.Text)) { if (pairsFamilyEnglishReal[firstClicked.Text] == pairsFamilySpanishReal[secondClicked.Text]) { sonidos.sonidoGanarSebastian(); firstClicked.ForeColor = firstClicked.BackColor; secondClicked.ForeColor = firstClicked.BackColor; //Verificar si ya se ganó el juego CheckForWinner(); firstClicked = null; secondClicked = null; return; } } // If the player gets this far, the player // clicked two different icons, so start the // timer (which will wait three quarters of // a second, and then hide the icons) timer1.Start(); } }