예제 #1
0
 //génére potion de soin en fonction du lvl
 public void GenerateHealthPotion(int level)
 {
     ItemType type;
     using (var db = new Project2NetContext())
     {
         if ((type = db.ItemsTypess.SingleOrDefault(t => t.Type == 0 && t.Level == level)) == null)
         {
             type = new ItemType
             {
                 AttackStrenghtBonus = 0,
                 DefenseBoost = 0,
                 HpRestoreValue = 80 + level * 80,
                 Level = level,
                 Name = "Potion de soins",
                 Type = 0
             };
             db.ItemsTypess.Add(type);
             db.SaveChanges();
         }
     }
     Name = type.Name;
     PlayerM.AddItem(type.Id);
 }
예제 #2
0
        //Génére potion de defense en fnct du lvl
        public void GenerateDefensePotion(int level)
        {
            ItemType type;
            using (var db = new Project2NetContext())
            {

                if ((type = db.ItemsTypess.SingleOrDefault(t => t.Type == 2 && t.Level == level)) == null)
                {
                    type = new ItemType
                    {
                        AttackStrenghtBonus = 0,
                        DefenseBoost = 5 + 5 * level,
                        HpRestoreValue = 0,
                        Level = level,
                        Name = "Potion de protection",
                        Type = 2
                    };
                    db.ItemsTypess.Add(type);
                    db.SaveChanges();
                }
                Item.ObjectType = type;
            }
        }