コード例 #1
0
        public void Ihm_AvecUnJeuDeDonnees_LeJoueurGagne()
        {
            // arrange
            var fausseConsole            = new FausseConsole();
            var fauxDe                   = Mock.Of <ILanceurDeDe>();
            var sequence                 = Mock.Get(fauxDe).SetupSequence(de => de.Lance());
            var monstre                  = new Monstre();
            var monstres                 = new Queue <Monstre>();
            var fausseFabriqueDeMonstres = Mock.Of <IFabriqueDeMonstres>();

            sequence.Returns(6);
            monstres.Enqueue(new Monstre());
            Mock.Get(fausseFabriqueDeMonstres).Setup(m => m.GetMonstres()).Returns(monstres);

            var fournisseurMeteo = Mock.Of <IFournisseurMeteo>();
            var ihm = new Ihm(fausseConsole, fauxDe, fournisseurMeteo, fausseFabriqueDeMonstres);

            // act
            ihm.Demarre();

            // assert
            var resultat = fausseConsole.StringBuilder.ToString();

            resultat.Should().StartWith("A l'attaque : points/vie 0/15");
            resultat.Should().EndWith("Le joueur est vainqueur !! Félicitations...\r\n");
            resultat.Should().HaveLength(76);
        }
コード例 #2
0
        public void ModificationMonstre(string tileName, int tileID, int id, int statPv, float statAttkMax, float statAttkMin, int statLevel)
        {
            try
            {
                using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1())
                {
                    Monstre monstre = contexte.Monstres.FirstOrDefault(x => x.Id == id);
                    monstre.Nom     = tileName;
                    monstre.ImageId = tileID;
                    if (statPv != 0)
                    {
                        monstre.StatPV = statPv;
                    }
                    if (statAttkMax != 0)
                    {
                        monstre.StatDmgMax = statAttkMax;
                    }
                    if (statAttkMin != 0)
                    {
                        monstre.StatDmgMin = statAttkMin;
                    }
                    if (statLevel != 0)
                    {
                        monstre.Niveau = statLevel;
                    }

                    contexte.SaveChanges();
                    RetournerMonstres();
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #3
0
        // Création d'un monstre
        public void CréerMonstre(Monstre monstre)
        {
            try
            {
                using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1())
                {
                    // Ajouter le monstre dans le monde demandé
                    Monde monde = contexte.Mondes.Find(monstre.MondeId);
                    monstre.Monde = monde;
                    monde.Monstres.Add(monstre);

                    if ((monstre.y > -1 && monstre.y <= monstre.Monde.LimiteY) && (monstre.x > -1 && monstre.x <= monstre.Monde.LimiteX) &&
                        (monstre.MondeId > 0 && contexte.Mondes.Any(x => x.Id == monstre.MondeId)) &&
                        monstre.Nom != "" && monstre.Niveau > 0 && monstre.StatPV > 0 &&
                        !(contexte.Monstres.Any(x => x.Id == monstre.Id)))
                    {
                        contexte.Monstres.Add(monstre);
                        contexte.SaveChanges();
                        RetournerMonstres();
                    }
                }
            }
            catch (Exception)
            {
                //LstErreursMonstres.Add("Erreur dans la méthode \'CréerMonstre\' : " + ex.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Auteur: Mathew Lemonde
        ///
        /// Creation d'un Monstre avec valeur aléatoires
        /// </summary>
        /// <param name="Mondeid">Id du monde</param>
        public void CreateMonster(int Mondeid, int x, int y, int HP, string sname)
        {
            var Monde = context.Mondes.FirstOrNull(c => c.Id == Mondeid);

            if (Monde == null)
            {
                return;
            }
            Random  _rand   = new Random();
            int     DmgMin  = _rand.Next(0, 100);
            Monstre monster = new Monstre()
            {
                MondeId = Monde.Id,
                Nom     = sname,
                //TODO
                Niveau = _rand.Next(0, 101),
                x      = x,
                y      = y,
                StatPV = HP,

                //DMG SELON LE MONSTRE TODO
                StatDmgMax = _rand.Next(DmgMin, 400)
            };

            context.Monstres.Add(monster);
            Monde.Monstres.Add(monster);
            context.SaveChanges();
        }
コード例 #5
0
 public void Attaque(Monstre monstre)
 {
     if (this.LancerDe() > monstre.LancerDe())
     {
         monstre.SubitDegats();
     }
 }
コード例 #6
0
ファイル: MonsterManager.cs プロジェクト: ChrisVolkoff/DeRPG
 public Monstre CréerMonstre(Héros joueur, string nomModèle, float scale, float échelleBox, Vector3 positionInitiale, Vector3 rotationInitiale, Vector3 rotationOffset,
                 string name, float vitesseDéplacementInitiale, float vitesseRotationInitiale, bool peutBougerEnTournant, float ptsVie,
                 int ptsDéfense, int ptsAttaque, int deltaDamage, float attackSpeed, bool isRange, float range, float aggrorange, int niveau, int id)
 {
     Monstre newMonster = new Monstre(Jeu, ScèneJeu, joueur, nomModèle, scale, échelleBox, positionInitiale, rotationInitiale, rotationOffset, name, vitesseDéplacementInitiale, vitesseRotationInitiale, peutBougerEnTournant, ptsVie, ptsDéfense, ptsAttaque, deltaDamage, attackSpeed, isRange, range, aggrorange, niveau, id);
     ListeMonstres.Add(newMonster);
     newMonster.Initialize();
     return newMonster;
 }
コード例 #7
0
    public void  RemoveFromList(Monstre monstre)
    {
        _monsterSpawnList.Remove(monstre);

        if (_monsterSpawnList.Count == 0)
        {
            monstersDeathEvent.Invoke();
        }
    }
コード例 #8
0
ファイル: HealthBar.cs プロジェクト: ChrisVolkoff/DeRPG
 public HealthBar(RPG jeu, ScèneDeJeu scenejeu, Monstre sujet, string nomhealthtex, string nombackgroundtex, string nomfont)
     : base(jeu)
 {
     Jeu = jeu;
     ScèneJeu = scenejeu;
     Sujet = sujet;
     NomHealthTex = nomhealthtex;
     NomBackgroundTex = nombackgroundtex;
     NomFont = nomfont;
     Visible = false;
 }
コード例 #9
0
        //Le main contient le fonctionnement du jeu
        static void Main(string[] args)
        {
            //création d'un joueur
            Joueur stephane = new Joueur(150);
            int    numero = 0;
            int    coupFacile = 0, coupDifficle = 0;

            //Tant que le joueur stephane est vivant on créer des monstres
            while (stephane.estVivant())
            {
                //On crée un nouveau monstre à chaque fois que l'ancien à été vaincu
                Monstre  monstre = creationMonstre();
                var      test    = monstre.GetType().ToString();
                string[] type    = new string[2];
                type = test.Split('+');
                //le numero indiquant la quantité de monstre créé
                numero++;
                Console.WriteLine("\n\n\nmonstre numéro: " + numero + " de type " + type[1]);
                //tant que le monstre est vivant ainsi que le joueur le combat continue
                while (monstre.estVivant && stephane.estVivant())
                {
                    Console.WriteLine("stephane attaque le monstre !");
                    stephane.Attaque(monstre);
                    if (monstre.estVivant)
                    {
                        Console.WriteLine("le monstre est toujours vivant et attaque stephane !");
                        monstre.Attaque(stephane);
                        Console.WriteLine("il reste à stéphane " + stephane.pointsVie + " points de vie");
                    }
                    else
                    {
                        Console.WriteLine("le monstre à été vaincu");
                    }
                    //ajout des points pour avoir vaincu le monstre
                    if (stephane.estVivant())
                    {
                        if (monstre is Monstre)
                        {
                            coupFacile++;
                        }
                        if (monstre is MonstreDifficile)
                        {
                            coupDifficle++;
                        }
                    }
                }
            }
            //Résumé de la partie
            Console.WriteLine("\nAïe! stephane est mort, il a vaincu {0} monstre et {1} monstre difficle", coupFacile, coupDifficle);
            Console.WriteLine("\nil a donc un score total de {0} points", coupFacile + 2 * coupDifficle);
            Console.ReadKey();
        }
コード例 #10
0
        /// <summary>
        /// Constructeur
        /// </summary>
        /// <param name="nom"></param>
        /// <param name="niveau"></param>
        /// <param name="DmgMax"></param>
        /// <param name="DmgMin"></param>
        /// <param name="PV"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public cMonstre(string nom, int x, int y)
        {
            _monstre     = new Monstre();
            _monstre.Nom = nom;
            Random rnd = new Random(DateTime.Now.Millisecond);

            _monstre.Niveau     = rnd.Next(1, 20);
            _monstre.StatDmgMax = rnd.Next(10, 40);
            _monstre.StatDmgMin = rnd.Next(1, 40);
            _monstre.StatPV     = rnd.Next(1, 50);
            _monstre.x          = x;
            _monstre.y          = y;
        }
コード例 #11
0
        public CombatWindow(Personnage perso)
        {
            InitializeComponent();
            this.perso   = perso;
            this.monstre = new Monstre();
            MessageBox.Show("Un " + monstre.Name + " se présente devant vous ! FIGHT !", "The Dungeon");

            nameMonstre.Text   = monstre.Name;
            pvMonstre.Text     = "PV : " + monstre.Pv;
            degatsMonstre.Text = "Dégats : " + monstre.Degat;

            pvPerso.Text     = "PV : " + perso.Pv;
            degatsPerso.Text = "Dégats : " + perso.Degat;
        }
コード例 #12
0
    public void SpawnAlly(int nbMonster)
    {
        List <Transform> _savedSpawnPointList = new List <Transform>(_spawnPointList); // Save a copy of the spawn point

        //Start the spell animation
        for (int i = 0; i < nbMonster; i++)
        {
            int _randomSpawnPoint = Random.Range(0, _savedSpawnPointList.Count);
            _monster = Instantiate(_monsterPrefabList[0].GetComponent <Monstre>(), _savedSpawnPointList[_randomSpawnPoint].position, Quaternion.identity);
            _monsterSpawnList.Add(_monster);
            _monster.mySpawner = this;
            _savedSpawnPointList.RemoveAt(_randomSpawnPoint);
        }
    }
コード例 #13
0
        public void Ihm_AvecUnJeuDeDonnees_LeJoueurPerds()
        {
            // arrange
            var fausseConsole            = new FausseConsole();
            var fauxDe                   = Mock.Of <ILanceurDeDe>();
            var sequence                 = Mock.Get(fauxDe).SetupSequence(de => de.Lance());
            var monstre                  = new Monstre();
            var monstres                 = new Queue <Monstre>();
            var fausseFabriqueDeMonstres = Mock.Of <IFabriqueDeMonstres>();

            foreach (var lancer in new[] { 4, 5, 1, 1, 4, 3, 5, 6, 6, 6, 1, 2, 4, 2, 3, 2, 6, 4, 5, 1, 1, 4, 3, 5, 6, 6, 6, 1, 2, 4, 2, 3, 2, 6 })
            {
                sequence.Returns(lancer);
                monstres.Enqueue(new Monstre());
            }

            Mock.Get(fausseFabriqueDeMonstres).Setup(m => m.GetMonstres()).Returns(monstres);

            var fournisseurMeteo = Mock.Of <IFournisseurMeteo>();
            var ihm = new Ihm(fausseConsole, fauxDe, fournisseurMeteo, fausseFabriqueDeMonstres);

            // act
            ihm.Demarre();

            // assert
            var resultat = fausseConsole.StringBuilder.ToString();

            resultat.Should().Be(@"A l'attaque : points/vie 0/15
Combat perdu: points/vie 0/14
Monstre battu: points/vie 1/14
Monstre battu: points/vie 2/14
Combat perdu: points/vie 2/13
Monstre battu: points/vie 3/13
Combat perdu: points/vie 3/12
Monstre battu: points/vie 4/12
Monstre battu: points/vie 5/12
Monstre battu: points/vie 6/12
Monstre battu: points/vie 7/12
Combat perdu: points/vie 7/9
Combat perdu: points/vie 7/7
Monstre battu: points/vie 8/7
Monstre battu: points/vie 9/7
Combat perdu: points/vie 9/5
Combat perdu: points/vie 9/4
Combat perdu: points/vie 9/0
Après un courageux combat, le joueur a malheureusement été vaincu ...
");
            resultat.Should().HaveLength(631);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: TMCognitic/DemoAttribute
        public void Loot(Monstre m)
        {
            Type monsterType = m.GetType();

            Console.WriteLine($"Je loot un {monsterType.Name}");

            IEnumerable <LootAttribute> lootAttributes = monsterType.GetCustomAttributes <LootAttribute>();

            foreach (LootAttribute lootAttribute in lootAttributes)
            {
                Console.WriteLine($"Je ramasse {lootAttribute.Text} : {lootAttribute.Value}");
            }

            Console.WriteLine();
        }
コード例 #15
0
ファイル: Foret.cs プロジェクト: Cerisedw/HeroesVsMonsters
        public void Play()
        {
            while (GameOver == false)
            {
                int x = this.Monstre.GetHashCode();

                Hero.Frappe(Monstre);

                if (x == this.Monstre.GetHashCode())
                {
                    Monstre.Frappe(Hero);
                }
            }
            Console.WriteLine($"\n{this.Hero.GetType().Name} est mort et a obtenu {this.Hero.Or} d'or et {this.Hero.Cuir} de cuir.");
        }
コード例 #16
0
    public List <MonstreObjet> GenerateVague()
    {
        List <MonstreObjet> retour = new List <MonstreObjet>();

        for (int i = 0; i < contenu.Count; i++)
        {
            for (int j = 0; j < contenu[i].nombre; j++)
            {
                Monstre newMob = new Monstre(contenu[i].monstre.dmg, contenu[i].monstre.or, contenu[i].monstre.pv, contenu[i].monstre.element);
                GameManager.gameManager.monstres.Add(newMob);
                retour.Add(new MonstreObjet(newMob, contenu[i].monstre.objetMonstre));
            }
        }

        return(retour);
    }
コード例 #17
0
        public Form2(String nom)
        {
            nbTours      = 1;
            this.heros   = new Heros(nom);
            this.monstre = new Monstre("Janounours");
            InitializeComponent();

            nomHeros.Text     = heros.getNom();
            vieHeros.Text     = heros.getPv().ToString();
            attaqueHeros.Text = heros.getAttaque().ToString();
            defenseHeros.Text = heros.getDefense().ToString();
            manaHeros.Text    = heros.getMana().ToString();

            nomMonstre.Text     = monstre.getNom();
            vieMonstre.Text     = monstre.getPv().ToString();
            attaqueMonstre.Text = monstre.getAttaque().ToString();
            defenseMonstre.Text = monstre.getDefense().ToString();

            logJeu.AppendText("\t\t\t\tDébut de la partie !\n\n");
        }
コード例 #18
0
        // Suppression d'un monstre
        public void SupprimerMonstre(Monstre monstre)
        {
            try
            {
                using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1())
                {
                    Monde monde = contexte.Mondes.Find(monstre.MondeId);
                    monstre.Monde = monde;
                    monde.Monstres.Remove(monstre);

                    if (contexte.Monstres.Any(x => x.Id == monstre.Id))
                    {
                        contexte.Monstres.Remove(contexte.Monstres.Find(monstre.Id));
                        contexte.SaveChanges();
                        RetournerMonstres();
                    }
                }
            }
            catch (Exception)
            {
                //LstErreursMonstres.Add("Erreur dans la méthode \'SupprimerMonstre\' : " + ex.Message);
            }
        }
コード例 #19
0
        /// <summary>
        /// Méthode de création de monstre
        /// Gestion de la création d'un monstre, empêche la création de 2 monstres identiques
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Creer_Click(object sender, RoutedEventArgs e)
        {
            Monstre monstre = new Monstre(Race.Text, Nom.Text);

            monstre.AddDescription(Description.Text);
            monstre.AddImage("../../../Bestiaire Witcher/img/Assets/not_found.jpg");
            monstre.AddFaiblesse("Huile contre les " + monstre.Race);
            monstre.IsDeletable = true;
            MyMainWindow.UCContent.MonstresCrees = (Dictionary <String, List <Monstre> >)SaveLoad.ChargementFichierBinaire("../../../Bestiaire.Services/don/MesMonstre.txt");


            // si la race du monstre existe et que le monstre existe déjà pour cette race, erreur
            if (MyMainWindow.UCContent.MonstresCrees.ContainsKey(monstre.Race) && MyMainWindow.UCContent.MonstresCrees[monstre.Race].Contains(monstre))
            {
                Error.Visibility = Visibility.Visible;
                Nom.Background   = Brushes.DarkRed;
            }
            // si il n'existe pas
            else
            {
                // si la race du monstre existe et qu'il n'existe pas, on le crée
                if (MyMainWindow.UCContent.MonstresCrees.ContainsKey(monstre.Race) && !MyMainWindow.UCContent.MonstresCrees[monstre.Race].Contains(monstre))
                {
                    MyMainWindow.UCContent.MonstresCrees[monstre.Race].Add(monstre);
                }
                // sinon on crée une nouvelle paire clef/valeur
                else
                {
                    MyMainWindow.UCContent.MonstresCrees.Add(monstre.Race, new List <Monstre> {
                        monstre
                    });
                }
                SaveLoad.SauvegardeFichierBinaire("../../../Bestiaire.Services/don/MesMonstre.txt", MyMainWindow.UCContent.MonstresCrees);
                MyMainWindow.UCContent.RaceMiens.ItemsSource = MyMainWindow.UCContent.StringRacesMiensList = ServicesMonstres.GetStringRacesMiensList(MyMainWindow.UCContent.MonstresCrees);
                Close();
            }
        }
コード例 #20
0
        // Modification d'un monstre
        public void ModifierMonstre(Monstre monstre, int x, int y, int mondeId, string nom, int niveau, int Pv, float DmgMin, float DmgMax, int?imgId)
        {
            try
            {
                using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1())
                {
                    Monde monde = contexte.Mondes.Find(monstre.MondeId);
                    monde.Monstres.Remove(monstre);

                    Monstre dbMonstre = contexte.Monstres.FirstOrDefault(z => z.Id == monstre.Id);

                    if (dbMonstre != null)
                    {
                        dbMonstre.Nom        = nom;
                        dbMonstre.Niveau     = niveau;
                        dbMonstre.ImageId    = imgId;
                        dbMonstre.StatPV     = Pv;
                        dbMonstre.StatDmgMax = DmgMax;
                        dbMonstre.StatDmgMin = DmgMin;
                        dbMonstre.MondeId    = mondeId;
                        dbMonstre.x          = x;
                        dbMonstre.y          = y;

                        monde           = contexte.Mondes.Find(mondeId);
                        dbMonstre.Monde = monde;
                        monde.Monstres.Add(dbMonstre);

                        contexte.SaveChanges();
                        RetournerMonstres();
                    }
                }
            }
            catch (Exception)
            {
                //LstErreursMonstres.Add("Erreur dans la méthode \'ModifierMonstre\' : " + ex.Message);
            }
        }
コード例 #21
0
ファイル: HealthBar.cs プロジェクト: ChrisVolkoff/DeRPG
 public HealthBar AjouterBarreDeVie(Monstre sujet)
 {
     HealthBar tempBarre = new HealthBar(Jeu, ScèneJeu, sujet, NomHealthTexture, NomBackgroundTexture, NomFont);
     ListeDeBarres.Add(tempBarre);
     tempBarre.Initialize();
     return tempBarre;
 }
コード例 #22
0
        private void modificationMap(int x, int y, int tileID)
        {
            if (m_Map.getMapTileType(y, x) == tileID)
            {
                return;
            }


            Tile       tileSelected    = m_TileLibrary.ObjMonde.Values.Where(c => c.IndexTypeObjet == tileID).First();
            Tile       tileUnder       = m_TileLibrary.ObjMonde.Values.Where(c => c.IndexTypeObjet == m_Map.getMapTileType(y, x)).First();
            ObjetMonde objOriginal     = m_DObj.Keys.ToList().Where(c => c.x == x && c.y == y).FirstOrDefault();
            Monstre    monstreOriginal = m_DMonstre.Keys.ToList().Where(c => c.x == x && c.y == y).FirstOrDefault();
            Item       itemOriginal    = m_DItem.Keys.ToList().Where(c => c.x == x && c.y == y).FirstOrDefault();
            string     testOriginality = "";

            if (objOriginal != null)
            {
                testOriginality = m_DObj[objOriginal];
            }
            else if (monstreOriginal != null)
            {
                testOriginality = m_DMonstre[monstreOriginal];
            }
            else if (itemOriginal != null)
            {
                testOriginality = m_DItem[itemOriginal];
            }

            if (tileSelected.IndexTypeObjet == 32)
            {
                if (testOriginality == "MODIFIED" || testOriginality == "ORIGINAL")
                {
                    if (tileUnder.TypeObjet == TypeTile.ObjetMonde)
                    {
                        m_OBJ.Add(m_DObj.Keys.Where(c => c.x == x && c.y == y).First());
                        m_DObj.Remove(m_DObj.Keys.Where(c => c.x == x && c.y == y).First());
                        return;
                    }
                    else if (tileUnder.TypeObjet == TypeTile.Item)
                    {
                        m_li.Add(m_DItem.Keys.Where(c => c.x == x && c.y == y).First());
                        m_DItem.Remove(m_DItem.Keys.Where(c => c.x == x && c.y == y).First());
                        return;
                    }
                    else
                    {
                        m_Mons.Add(m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First());
                        m_DMonstre.Remove(m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First());
                        return;
                    }
                }

                if (tileUnder.TypeObjet == TypeTile.ObjetMonde)
                {
                    m_DObj.Remove(objOriginal);
                    return;
                }
                else if (tileUnder.TypeObjet == TypeTile.Monstre)
                {
                    m_DMonstre.Remove(monstreOriginal);
                    return;
                }
                else
                {
                    m_DItem.Remove(itemOriginal);
                    return;
                }
            }


            if (tileSelected.TypeObjet == TypeTile.ObjetMonde && testOriginality == "ORIGINAL" || testOriginality == "MODIFIED")
            {
                m_DObj.Keys.Where(c => c.x == x && c.y == y).First().Description = tileSelected.Name;
                m_DObj.Keys.Where(c => c.x == x && c.y == y).First().TypeObjet   = tileSelected.IndexTypeObjet;
                m_DObj[m_DObj.Keys.Where(c => c.x == x && c.y == y).First()]     = "MODIFIED";
                return;
            }
            else if (tileSelected.TypeObjet == TypeTile.Item && (testOriginality == "ORIGINAL" || testOriginality == "MODIFIED") && (tileUnder.TypeObjet == TypeTile.Item))
            {
                m_DItem.Keys.Where(c => c.x == x && c.y == y).First().Description = tileSelected.Name;
                m_DItem.Keys.Where(c => c.x == x && c.y == y).First().ImageId     = tileSelected.IndexTypeObjet;
                m_DItem.Keys.Where(c => c.x == x && c.y == y).First().Nom         = tileSelected.Name;
                m_DItem[m_DItem.Keys.Where(c => c.x == x && c.y == y).First()]    = "MODIFIED";
                return;
            }
            else if (tileSelected.TypeObjet == TypeTile.Monstre && (testOriginality == "ORIGINAL" || testOriginality == "MODIFIED") && (tileUnder.TypeObjet == TypeTile.Monstre))
            {
                m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First().Nom         = tileSelected.Name;
                m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First().ImageId     = tileSelected.IndexTypeObjet;
                m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First().StatPV      = tileSelected.Health;
                m_DMonstre[m_DMonstre.Keys.Where(c => c.x == x && c.y == y).First()] = "MODIFIED";
                return;
            }

            if (tileSelected.TypeObjet == TypeTile.ObjetMonde && (testOriginality != "ORIGINAL") && (testOriginality != "MODIFIED"))
            {
                if (tileUnder.IndexTypeObjet != 32 && testOriginality == "NEW")
                {
                    if (tileUnder.TypeObjet == TypeTile.Monstre)
                    {
                        m_DMonstre.Remove(monstreOriginal);
                    }
                    else if (tileUnder.TypeObjet == TypeTile.Item)
                    {
                        m_DItem.Remove(itemOriginal);
                    }
                    else
                    {
                        m_DObj.Remove(objOriginal);
                    }
                    m_DObj.Add(new ObjetMonde()
                    {
                        TypeObjet   = tileSelected.IndexTypeObjet,
                        x           = x,
                        y           = y,
                        Monde       = m_CurrentWorld,
                        Description = tileSelected.Name
                    },
                               "NEW");
                }
                else
                {
                    m_DObj.Add(new ObjetMonde()
                    {
                        TypeObjet   = tileSelected.IndexTypeObjet,
                        x           = x,
                        y           = y,
                        Monde       = m_CurrentWorld,
                        Description = tileSelected.Name
                    },
                               "NEW");
                }
                return;
            }

            if (tileSelected.TypeObjet == TypeTile.Monstre)
            {
                if (tileUnder.IndexTypeObjet != 32)
                {
                    if (tileUnder.TypeObjet == TypeTile.ObjetMonde && tileUnder.IsBlock)
                    {
                        m_DObj.Remove(objOriginal);
                    }
                    else if (tileUnder.TypeObjet == TypeTile.Item)
                    {
                        m_DItem.Remove(itemOriginal);
                    }
                    //else
                    //{
                    //    m_DMonstre.Remove(monstreOriginal);
                    //}
                    m_DMonstre.Add(new Monstre()
                    {
                        Nom     = tileSelected.Name,
                        StatPV  = tileSelected.Health,
                        Monde   = m_CurrentWorld,
                        x       = x,
                        y       = y,
                        ImageId = tileSelected.IndexTypeObjet,
                        //À revoir juste en dessous !!!
                        StatDmgMax = 0,
                        StatDmgMin = 0,
                        Niveau     = 0
                    },
                                   "NEW");
                }
                else
                {
                    m_DMonstre.Add(new Monstre()
                    {
                        Nom     = tileSelected.Name,
                        StatPV  = tileSelected.Health,
                        Monde   = m_CurrentWorld,
                        x       = x,
                        y       = y,
                        ImageId = tileSelected.IndexTypeObjet,
                        //À revoir juste en dessous !!!
                        StatDmgMax = 0,
                        StatDmgMin = 0,
                        Niveau     = 0
                    },
                                   "NEW");
                }
                return;
            }

            if (tileSelected.TypeObjet == TypeTile.Item)
            {
                if (tileUnder.IndexTypeObjet != 32)
                {
                    if (tileUnder.TypeObjet == TypeTile.Monstre)
                    {
                        m_DMonstre.Remove(monstreOriginal);
                    }
                    else if (tileUnder.TypeObjet == TypeTile.ObjetMonde && tileUnder.IsBlock)
                    {
                        m_DObj.Remove(objOriginal);
                    }
                    //else
                    //{
                    //    m_DItem.Remove(itemOriginal);
                    //}

                    m_DItem.Add(new Item()
                    {
                        ImageId     = tileSelected.IndexTypeObjet,
                        x           = x,
                        y           = y,
                        Monde       = m_CurrentWorld,
                        Description = tileSelected.Name,
                        Nom         = tileSelected.Name
                    },
                                "NEW");
                }
                else
                {
                    m_DItem.Add(new Item()
                    {
                        ImageId     = tileSelected.IndexTypeObjet,
                        x           = x,
                        y           = y,
                        Monde       = m_CurrentWorld,
                        Description = tileSelected.Name,
                        Nom         = tileSelected.Name
                    },
                                "NEW");
                }
                return;
            }
        }
コード例 #23
0
        private void EnvoiClick(object sender, RoutedEventArgs e)
        {
            if (TextFirstName.Text != null && TextLastName != null && TextAddress.Text != null &&
                TextCity.Text != null)
            {
                string fonction  = TextAddress.Text;
                string matricule = TextCity.Text;
                string prenom    = TextFirstName.Text;
                string nom       = TextLastName.Text;
                string sexeString;
                if (sexe.Text == "male")
                {
                    sexeString = "M";
                }
                else if (sexe.Text == "femelle")
                {
                    sexeString = "F";
                }
                else
                {
                    sexeString = "A";
                }
                bool flagMatricule = true;

                for (int i = 0; i < Administration.listePersonnel.Count; i++)
                {
                    if (matricule == Convert.ToString(Administration.listePersonnel[i].Matricule))
                    {
                        flagMatricule = false;
                    }
                }

                if (flagMatricule)
                {
                    if (exactitude.IsChecked == true)
                    {
                        try
                        {
                            try
                            {
                                string          connectionString = "SERVER=35.195.241.250; PORT=3306; DATABASE=zombillenium; UID=root; PASSWORD=abcd1234;";
                                MySqlConnection connection       = new MySqlConnection(connectionString);
                                connection.Open();
                                MySqlCommand command = connection.CreateCommand();
                                command.CommandText = "INSERT INTO zombillenium.personnel (fonction, matricule, nom, prenom, sexe) VALUES ('" + fonction + "','" + matricule + "','" + nom + "','" + prenom + "','" + sexeString + "');";

                                MySqlDataReader reader;
                                reader = command.ExecuteReader();

                                if (reader.Read())
                                {
                                    affichage.Text = reader.GetString(0);
                                }
                                else
                                {
                                    affichage.Text = "Personnel ajouté";
                                }


                                connection.Close();
                            }
                            catch
                            {
                                affichage.Text = "Non ajouté à la base de données";
                            }

                            TypeSexe      typeSe       = (TypeSexe)sexe.SelectedItem;
                            int           matriculeInt = Convert.ToInt32(TextCity.Text);
                            Grade         typeGrade    = (Grade)listeGrades.SelectedItem;
                            string        pouvoirs     = listePouvoirs.Text;
                            List <string> pouvoirsList = new List <string>();
                            pouvoirsList = pouvoirs.Split(';').ToList();
                            int cagnotteInt = 0;
                            try { cagnotteInt = Convert.ToInt32(cagnotte.Text); } catch { }

                            List <Attraction> affectationListe = new List <Attraction>();
                            for (int i = 0; i < Administration.listeAttractions.Count; i++)
                            {
                                if (affectation.Text == Administration.listeAttractions[i].Nom)
                                {
                                    if (affectation.Text != "néant")
                                    {
                                        affectationListe.Add(Administration.listeAttractions[i]);
                                        break;
                                    }
                                }
                            }

                            int forceInt = 0;
                            try { forceInt = Convert.ToInt32(nbForce.Value); } catch { }

                            double cruauteDouble = 0;
                            try { cruauteDouble = Convert.ToDouble(nbCruaute.Value); } catch { }

                            double luminDouble = 0;
                            try { luminDouble = Convert.ToDouble(nbLumin.Value); } catch { }

                            int decompInt = 0;
                            try { decompInt = Convert.ToInt32(nbDecomp.Value); } catch { }

                            CouleurZ typeTeint = (CouleurZ)teint.SelectedItem;

                            List <Personnel> list1 = new List <Personnel>();

                            if (affectationListe.Count == 0)
                            {
                                if (typePersonnel.Text == "Sorcier")
                                {
                                    Sorcier perso1 = new Sorcier(pouvoirsList, typeGrade, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else
                                {
                                    if (typeMonstre.Text == "Demon")
                                    {
                                        Demon perso1 = new Demon(forceInt, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Fantome")
                                    {
                                        Fantome perso1 = new Fantome(Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "LoupGarou")
                                    {
                                        LoupGarou perso1 = new LoupGarou(cruauteDouble, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Vampire")
                                    {
                                        Vampire perso1 = new Vampire(luminDouble, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Zombie")
                                    {
                                        Zombie perso1 = new Zombie(decompInt, typeTeint, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else
                                    {
                                        Monstre perso1 = new Monstre(true, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                }
                            }
                            else
                            {
                                if (typeMonstre.Text == "Demon")
                                {
                                    Demon perso1 = new Demon(forceInt, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Fantome")
                                {
                                    Fantome perso1 = new Fantome(affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "LoupGarou")
                                {
                                    LoupGarou perso1 = new LoupGarou(cruauteDouble, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Vampire")
                                {
                                    Vampire perso1 = new Vampire(luminDouble, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Zombie")
                                {
                                    Zombie perso1 = new Zombie(decompInt, typeTeint, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else
                                {
                                    Monstre perso1 = new Monstre(true, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                            }
                            Administration.listePersonnel.Add(list1[0]);
                            if (affichage.Text != "Non ajouté à la base de données")
                            {
                                affichage.Text = "Personnel ajouté";
                            }
                            else
                            {
                                affichage.Text = "Personnel ajouté au programme, mais pas à la base de données MySQL.";
                            }
                        }

                        catch
                        {
                            MessageBoxResult result = MessageBox.Show("Type de valeur d'entrée incorrect: vérifier les informations saisies.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        affichage.Text = "Merci de confirmer l'exactitude des informations en cochant la case.";
                    }
                }
                else
                {
                    affichage.Text = "Ce matricule existe déjà. Merci de le changer.";
                }
            }
            else
            {
                affichage.Text = "Veuillez vérifier les informations saisies.";
            }
        }
コード例 #24
0
ファイル: Capture.cs プロジェクト: Fabofed/Travail1-CAO
 public override void Effectuer(Monstre monstre)
 {
     this.joueur.MonstresCaptures.Add(monstre); //Ajoute le monstre a la liste de monstres captures
 }
コード例 #25
0
 private static bool TestFaiblesse(Monstre monstre)
 {
     return(monstre.Faiblesse.Count() > 1 && monstre.Faiblesse.Count() < 3);
 }
コード例 #26
0
ファイル: cMonde.cs プロジェクト: timagetank/BdDProjects
 /// <summary>
 /// Permet de retirer un monstre au monde.
 /// </summary>
 /// <param name="monstre"></param>
 public void RetirerMonstre(Monstre monstre)
 {
     _monde.Monstre.Remove(monstre);
     context.SaveChanges();
 }
コード例 #27
0
ファイル: cMonde.cs プロジェクト: timagetank/BdDProjects
 /// <summary>
 /// Permet d'ajouter un monstre au monde.
 /// </summary>
 /// <param name="monstre"></param>
 public void AjouterMonstre(Monstre monstre)
 {
     _monde.Monstre.Add(monstre);
     context.SaveChanges();
 }
コード例 #28
0
 private void DG1_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     objEmpToEdit = DG1.SelectedItem as Monstre;
 }
コード例 #29
0
 public MonstreObjet(Monstre mo, GameObject g)
 {
     monstre = mo;
     go      = g;
 }
コード例 #30
0
        public void CréerMonstre(Monstre monstre, int statPv, float statAttkMax, float statAttkMin, int statLevel)
        {
            int    defStatPv = 0, lvl = 0;
            float  defStatMax = 0, defStatMin = 0;
            Random rdn = new Random();

            try
            {
                using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1())
                {
                    // Ajouter le monstre dans le monde demandé
                    Monstre mNew = new Monstre()
                    {
                        Nom     = monstre.Nom,
                        x       = monstre.x,
                        y       = monstre.y,
                        ImageId = monstre.ImageId,
                        MondeId = monstre.MondeId
                    };

                    if (statLevel == 0)
                    {
                        lvl         = rdn.Next(1, 11);
                        mNew.Niveau = lvl;
                    }
                    else
                    {
                        mNew.Niveau = statLevel;
                    }

                    if (statPv == 0)
                    {
                        defStatPv   = 50;
                        mNew.StatPV = defStatPv + (lvl * 10);
                    }
                    else
                    {
                        mNew.StatPV = statPv;
                    }

                    if (statAttkMax == 0)
                    {
                        defStatMax      = 10;
                        mNew.StatDmgMax = defStatMax * (1 + lvl / 5);
                    }
                    else
                    {
                        mNew.StatDmgMax = statAttkMax;
                    }

                    if (statAttkMin == 0)
                    {
                        defStatMin      = 5;
                        mNew.StatDmgMin = defStatMin * (1 + lvl / 4);
                    }
                    else
                    {
                        mNew.StatDmgMin = statAttkMin;
                    }

                    //Monde monde = contexte.Mondes.Find(item.MondeId)
                    if (monstre.y > -1 && monstre.x > -1)
                    {
                        contexte.Monstres.Add(mNew);
                        contexte.SaveChanges();
                        RetournerMonstres();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #31
0
 public Combat(Joueur joueur, Monstre monstre)
 {
     Joueur  = joueur;
     Monstre = monstre;
 }