Ejemplo n.º 1
0
        /// <summary>
        /// Méthode d'initialisation ou de réinitialisation, appelée au début et au redémarrage de l'application.
        /// </summary>
        private void Init()
        {
            try
            {
                SuspendLayout();

                enigmas = EnigmaReferencer.ReferenceEnigmas();

                solved = new List <string>();

                CheckIntegrity();

                NextEnigma();

                ResumeLayout();
            }
            catch (IntegrityException e)
            {
                MessageBox.Show(e.Message);
                Environment.Exit(1);
            }
            catch (NoAnswerException e)
            {
                MessageBox.Show(e.Message);
                Environment.Exit(1);
            }
            catch (EndGameException e)
            {
                MessageBox.Show(e.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cette méthode trouve et affiche l'énigme suivante celle qui se trouve actuellement à l'écran et effectue le remplacement.
        /// </summary>
        private void NextEnigma()
        {
            tbxAnswer.Text = "";

            #if DEBUG
            Enigma debug = EnigmaReferencer.DebugEnigma();
            if (debug != null)
            {
                if (active != null)
                {
                    Environment.Exit(0);
                }
                SetActive(debug);
                return;
            }
            #endif

            if (enigmas.Count == 0)
            {
                throw new EndGameException();
            }

            if (active == null)
            {
                SetActive(enigmas[enigmas.Count - 1]);
            }
            Enigma next = enigmas[(enigmas.IndexOf(active) + 1) % enigmas.Count];
            while (next != active)
            {
                if (next.IsPlayable(solved))
                {
                    lblId.Text = next.Title;

                    SetActive(next);
                    return;
                }
                next = enigmas[(enigmas.IndexOf(next) + 1) % enigmas.Count];
            }
            MessageBox.Show("C'est la dernière énigme disponible.", "Bientôt fini !");
        }