コード例 #1
0
ファイル: Mots.cs プロジェクト: Rom8486/ProjetQuinto2
        public static Mot ChargerMot(Mots mots)
        {
            Random rand = new Random();


            int index = rand.Next(mots.Count);
            Mot mot   = mots.ElementAt(index);

            return(mot);
        }
コード例 #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsFacileJson.json", typeof(Mots));

                mot = Mots.ChargerMot(mots);
            }
            else if (radioButton2.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsDifficileJson.json", typeof(Mots));

                mot = Mots.ChargerMot(mots);
            }
            else if (radioButton3.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsExpertJson.json", typeof(Mots));


                mot = Mots.ChargerMot(mots);
            }

            if (joueur.NbManchesRemportees == 0)
            {
                CreationTimer();
            }

            timer.Start();
            textBox2.Text = joueur.NbManchesRemportees.ToString();
            GestionnaireContextes(Contextes.GameStarted);
            //DateTime TpsDebut = TempsDebut();
            btnStart.Enabled = false;

            joueur.NbEssaiRestant = 7;
            tbNbrEssais.Text      = joueur.NbEssaiRestant.ToString();


            //essai pour charger mot aleatoire à partir du hashset d'essai
            // Random aleatoire = new Random();
            // int index=aleatoire.Next(0, 5);
            // string LeMot = HashSetEssai.ElementAt(index);
            // mot.MotInitial = LeMot.ToUpper();
            tbMotADeviner.Text = mot.MettreTirets(mot.MotInitial);

            //FinEssai
        }
コード例 #3
0
        public void LoadJson(Mots listmots)
        {
            JObject        obj   = null;
            JsonSerializer jsonS = new JsonSerializer();

            string filepath = @"c:\Windows\temp\MotsJson.json";

            if (File.Exists(filepath))
            {
                StreamReader sr    = new StreamReader(filepath);
                JsonReader   jsonR = new JsonTextReader(sr);
                obj = jsonS.Deserialize(jsonR) as JObject;
                jsonR.Close();
                sr.Close();
                this.Add(obj);
            }
        }
コード例 #4
0
ファイル: Lexique.cs プロジェクト: Rom8486/ProjetQuinto2
        //public static void ChargerMots()
        //{
        //    Random rand = new Random();
        //    if (joueur.Niveaudifficulte == "Facile")
        //    {

        //        int index = rand.Next(motsFacile.Count);
        //        Mot mot = motsFacile.ElementAt(index);
        //       // tbEssai.Text = mot.MotInitial;
        //    }
        //    else if (joueur.Niveaudifficulte == "Difficile")
        //    {

        //        int index = rand.Next(motsDifficile.Count);
        //        Mot mot = motsDifficile.ElementAt(index);
        //      //  tbEssai.Text = mot.MotInitial;
        //    }
        //    else if (joueur.Niveaudifficulte == "Expert")
        //    {
        //        int index = rand.Next(motsExpert.Count);
        //        Mot mot = motsExpert.ElementAt(index);
        //      //  tbEssai.Text = mot.MotInitial;
        //    }


        //}
        public void DeserializeAll()
        {
            motsFacile    = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsFacileJson.json", typeof(Mots));
            motsDifficile = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsDifficileJson.json", typeof(Mots));
            motsExpert    = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsExpertJson.json", typeof(Mots));
        }