Esempio n. 1
0
        // Tests GestionMonstre
        private void BtnMonstre_Click(object sender, EventArgs e)
        {
            txtTestes.Clear();

            GestionMonstre gMonstre = new GestionMonstre();
            Monstre        monstre  = new Monstre
            {
                x       = 8,
                y       = 8,
                MondeId = 3114,
                Nom     = "Test",
                Niveau  = 17,
                StatPV  = 18
            };

            // Création d'un monstre
            gMonstre.CréerMonstre(monstre);
            AfficherInfoMonstres(gMonstre);

            // Modification d'un monstre
            txtTestes.Text += "\r\nModification du monstre créé : \r\n";
            txtTestes.Text += "Dernier monstre : " + gMonstre.LstMonstres.Last().Id + " - " + gMonstre.LstMonstres.Last().Nom + "\r\n";
            gMonstre.ModifierMonstre(monstre, monstre.x, monstre.y, 3111, "Pompom", 1, 8, 8f, 12f, null);
            monstre         = gMonstre.LstMonstres.Last();
            txtTestes.Text += "Info du monstre modifié : \r\n";
            txtTestes.Text += monstre.Id + " - " + monstre.x + " - " + monstre.y + " - " + monstre.MondeId + " - " + monstre.Niveau + " - " + monstre.Nom
                              + " - " + monstre.StatPV + " - " + monstre.StatDmgMax + " - " + monstre.StatDmgMin + "\r\n";
            txtTestes.Text += "Dernier monstre : " + gMonstre.LstMonstres.Last().Id + " - " + gMonstre.LstMonstres.Last().Nom + "\r\n";

            // Suppression d'un monstre
            txtTestes.Text += "\r\nSuppression de monstre : \r\n";
            txtTestes.Text += "Compte avant : " + gMonstre.LstMonstres.Count() + "\r\n";
            txtTestes.Text += "Dernier monstre : " + gMonstre.LstMonstres.Last().Id + " - " + gMonstre.LstMonstres.Last().Nom + "\r\n";
            gMonstre.SupprimerMonstre(monstre);
            txtTestes.Text += "Compte après : " + gMonstre.LstMonstres.Count() + "\r\n";
            txtTestes.Text += "Dernier monstre : " + gMonstre.LstMonstres.Last().Id + " - " + gMonstre.LstMonstres.Last().Nom + "\r\n";
        }
Esempio n. 2
0
        private void UpdateTile(Tile t, int worldId, int ActiveX, int ActiveY, int TileID)
        {
            switch (t.TypeObjet)
            {
            case TypeTile.Item:
                m_GestionItem.RetournerItems();
                HugoLand.Item item = m_GestionItem.LstItems.FirstOrDefault(x => x.MondeId == worldId && x.x == ActiveX && x.y == ActiveY);
                if (item != null)
                {
                    m_GestionItem.ModificationItem(t.Name, TileID, item.Id);
                }
                else
                {
                    item = new HugoLand.Item()
                    {
                        Nom         = t.Name,
                        MondeId     = worldId,
                        x           = ActiveX,
                        y           = ActiveY,
                        ImageId     = TileID,
                        Description = t.Category + " " + t.Color
                    };

                    m_GestionItem.CreerItemMonde(item);
                }
                break;

            case TypeTile.Monstre:
                m_GestionMonstre.RetournerMonstres();
                int   statPv = 0, statLevel = 0;
                float statAttkMax = 0f, statAttkMin = 0f;

                int.TryParse(txtLevel.Text, out statLevel);
                int.TryParse(txtPv.Text, out statPv);
                float.TryParse(txtAttkMax.Text, out statAttkMax);
                float.TryParse(txtAttkMin.Text, out statAttkMin);

                HugoLand.Monstre monstre = m_GestionMonstre.LstMonstres.FirstOrDefault(x => x.MondeId == worldId && x.x == ActiveX && x.y == ActiveY);
                if (monstre != null)
                {
                    m_GestionMonstre.ModificationMonstre(t.Name, TileID, monstre.Id, statPv, statAttkMax, statAttkMin, statLevel);
                }
                else
                {
                    monstre = new HugoLand.Monstre()
                    {
                        Nom     = t.Name,
                        MondeId = worldId,
                        x       = ActiveX,
                        y       = ActiveY,
                        ImageId = TileID,
                    };

                    m_GestionMonstre.CréerMonstre(monstre, statPv, statAttkMax, statAttkMin, statLevel);
                }
                break;

            case TypeTile.ObjetMonde:
                m_GestionObjetMonde.RetournerObjetMonde();
                HugoLand.ObjetMonde objMonde = m_GestionObjetMonde.LstObjetMondes.FirstOrDefault(x => x.MondeId == worldId && x.x == ActiveX && x.y == ActiveY);
                if (objMonde != null)
                {
                    m_GestionObjetMonde.ModificationObjetMonde(t.Name, TileID, objMonde.Id);
                }
                else
                {
                    objMonde = new HugoLand.ObjetMonde()
                    {
                        Description = t.Name,
                        MondeId     = worldId,
                        x           = ActiveX,
                        y           = ActiveY,
                        TypeObjet   = TileID
                    };

                    m_GestionObjetMonde.CreerObjetMonde(objMonde);
                }
                break;
            }
        }