Example #1
0
        // Tests GestionItem
        private void BtnItem_Click(object sender, EventArgs e)
        {
            txtTestes.Clear();
            GestionItem  gItem = new GestionItem();
            GestionHeros ghero = new GestionHeros();

            Item item = new Item
            {
                x           = 8,
                y           = 8,
                MondeId     = 3114,
                Nom         = "Test",
                Description = "Ceci est un test"
            };

            Hero hero = ghero.LstHeros.First();

            // Création d'un item
            gItem.CréationItem(item);
            AfficherInfoItems(gItem);

            // Modification d'un item
            txtTestes.Text += "\r\nDernier item : " + item.Id + " : " + item.Nom + " - " + item.Description + " - " + item.x + ", " + item.y + " - " + item.MondeId + "\r\n\r\n";

            gItem.ModificationItem(item.Id, hero.Id, -2);
            AfficherInfoItems(gItem);

            // Suppression d'un item
            txtTestes.Text += "\r\nSuppression d\'un item : \r\n";
            txtTestes.Text += "Compte avant (même compte qu\'après, mais heroId n\'existe pas) : " + gItem.LstItems.Count() + "\r\n";
            txtTestes.Text += "Dernier item : " + gItem.LstItems.Last().Id + " - " + gItem.LstItems.Last().Nom + " - " + gItem.LstItems.Last().x.ToString() + ", " + gItem.LstItems.Last().y.ToString() + " - " + gItem.LstItems.Last().IdHero.ToString() + "\r\n";
            gItem.SuppressionItem(item, hero);
            txtTestes.Text += "Compte après (même compte, mais x,y n\'est plus présent) : " + gItem.LstItems.Count() + "\r\n";
            txtTestes.Text += "Dernier item : " + gItem.LstItems.Last().Id + " - " + gItem.LstItems.Last().Nom + " - " + gItem.LstItems.Last().x.ToString() + ", " + gItem.LstItems.Last().y.ToString() + " - " + gItem.LstItems.Last().IdHero.ToString() + "\r\n";
        }
Example #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;
            }
        }