//Método que se lanza al seleccionar comenzar el juego. private void lblStart_Click(object sender, EventArgs e) { player.SetNamePlayer(txtNameUser.Text); LevelOneForm levelOne = new LevelOneForm(player, question); this.Hide(); levelOne.ShowDialog(); }
//Método para verificar la interacción del jugador y las almas. private void InteractionDetection_Tick(object sender, EventArgs e) { if (((ptbPlayer.Left + ptbPlayer.Width) == (ptbSoulOne.Left + ptbSoulOne.Width)) && ((ptbPlayer.Location.Y + ptbPlayer.Height + 4) == (ptbSoulOne.Location.Y + ptbSoulOne.Height)) && ptbSoulOne.Visible != false) { ptbSoulOne.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (pbtSoulTwo.Left + pbtSoulTwo.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (soulTwo.GetCoordY() + pbtSoulTwo.Height)) && pbtSoulTwo.Visible != false) { pbtSoulTwo.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (pbtSoulThree.Left + pbtSoulThree.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (soulThree.GetCoordY() + pbtSoulThree.Height)) && pbtSoulThree.Visible != false) { pbtSoulThree.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (pbtSoulFour.Left + pbtSoulFour.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (soulFour.GetCoordY() + pbtSoulFour.Height)) && pbtSoulFour.Visible != false) { pbtSoulFour.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (pbtSoulFive.Left + pbtSoulFive.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (soulFive.GetCoordY() + pbtSoulFive.Height)) && pbtSoulFive.Visible != false) { pbtSoulFive.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (pbtSoulSix.Left + pbtSoulSix.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (soulSix.GetCoordY() + pbtSoulSix.Height)) && pbtSoulSix.Visible != false) { pbtSoulSix.Visible = false; CounterForPoints(); } else if (((ptbPlayer.Left + ptbPlayer.Width) == (ptbPortal.Left + ptbPortal.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (portal.GetCoordY() + ptbPortal.Height))) { if (EvaluateRecolection() == true) { player.SetPointsPlayer(pointsUser + 50); moveUser.Enabled = false; moveUser.Stop(); InteractionDetection.Enabled = false; InteractionDetection.Stop(); this.Hide(); LevelThreeeForm levelThree = new LevelThreeeForm(this.player, questions); levelThree.ShowDialog(); } else { pointsUser = pointsUser - 5; lblPoints.Text = Convert.ToString(pointsUser); MessageBox.Show("¡Error!", "¡Aún no ha recolectado todas las almas!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (((ptbPlayer.Left + ptbPlayer.Width) == (ptbBadFour.Left + ptbBadFour.Width)) && ((player.GetCoordY() + ptbPlayer.Height) == (badFour.GetCoordY() + ptbBadFour.Height))) { ptbBadFour.Visible = false; QuestionForm questionForm = new QuestionForm(GetQuestion()); questionForm.ShowDialog(); answerUser = questionForm.GetAnswer(); if (answerUser == true) { pointsUser += 10; player.SetPointsPlayer(pointsUser); lblPoints.Text = Convert.ToString(pointsUser); MessageBox.Show("¡Correcto!", "¡Respuesta correcta!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (player.GetLives() == 0) { this.Hide(); EndGameForm gameOver = new EndGameForm(this.player); moveUser.Enabled = false; moveUser.Stop(); InteractionDetection.Enabled = false; InteractionDetection.Stop(); gameOver.ShowDialog(); } pointsUser = pointsUser - 20; player.SetPointsPlayer(pointsUser); lives = lives - 1; player.SetLives(lives); moveUser.Enabled = false; moveUser.Stop(); InteractionDetection.Enabled = false; InteractionDetection.Stop(); this.Hide(); LevelOneForm levelOne = new LevelOneForm(this.player, questions); levelOne.ShowDialog(); } } }