示例#1
0
        //Kisorsol egy ritkasági bónuszt az adott tárgy lehetséges bonuszaiból
        public static int[] RollABonus(ItemGenerator selectedItem)
        {
            int[] newRolledBonus = new int[2];

            List <ItemBonus> possibleBonuses = new List <ItemBonus>();

            possibleBonuses = selectedItem.item_bonuses.Where(x => x.item_bonus_max != 0).ToList();

            if (possibleBonuses.Count != 0)
            {
                ItemBonus rolledBonus = possibleBonuses[new Random().Next(possibleBonuses.Count)];

                newRolledBonus[0] = Convert.ToInt32(rolledBonus.item_bonusStatName);

                newRolledBonus[1] = new Random().Next(rolledBonus.item_bonus_min, rolledBonus.item_bonus_max + 1);
            }
            return(newRolledBonus);
        }
示例#2
0
        public static List <ItemGenerator> GetAllData()
        {
            OleDbCommand command = Connect();

            command.CommandText = "SELECT * FROM [ItemGenerator]";
            OleDbDataAdapter adapter = new OleDbDataAdapter(command);
            DataTable        dt      = new DataTable();

            adapter.Fill(dt);

            string debugFolder = System.AppDomain.CurrentDomain.BaseDirectory;
            List <ItemGenerator> ItemGenerators = new List <ItemGenerator>();



            foreach (DataRow row in dt.Rows)
            {
                ItemGenerator itemGenerator = new ItemGenerator();


                itemGenerator.item_id    = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(true)]);
                itemGenerator.item_name  = row.ItemArray[StaticHelper.IndexLine(false)].ToString();
                itemGenerator.item_image = debugFolder + "Images\\" + row.ItemArray[StaticHelper.IndexLine(false)].ToString();
                itemGenerator.item_type  = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());

                itemGenerator.item_rarity               = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_potionEffect         = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_potionEffectValue    = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_potionEffectDuration = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_level            = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_requiedHeroLevel = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_quantityFrom     = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_quantityTo       = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_isStackable      = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_qualityFrom      = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_qualityTo        = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)].ToString());
                itemGenerator.item_primaryStat_damageMax_randomMin  = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)]);
                itemGenerator.item_primaryStat_damageMax_randomMax  = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)]);
                itemGenerator.item_primaryStat_defenseMax_randomMin = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)]);
                itemGenerator.item_primaryStat_defenseMax_randomMax = Convert.ToInt32(row.ItemArray[StaticHelper.IndexLine(false)]);

                int bonusIndex = 19;
                itemGenerator.item_bonuses = new List <ItemBonus>();
                for (int i = 0; i < 22; i++)
                {
                    ItemBonus itemBonus = new ItemBonus();
                    itemBonus.item_bonusStatName = (EnumPossibleBonusStats)i;
                    itemBonus.item_bonus_min     = Convert.ToInt32(row.ItemArray[bonusIndex]);
                    bonusIndex++;
                    itemBonus.item_bonus_max = Convert.ToInt32(row.ItemArray[bonusIndex]);
                    bonusIndex++;
                    itemGenerator.item_bonuses.Add(itemBonus);
                }



                ItemGenerators.Add(itemGenerator);
            }

            adapter.Dispose();
            command.Connection.Close();


            return(ItemGenerators);
        }
        Item DropRandomItem(int input)
        {
            Random random  = new Random();
            Item   newItem = new Item();

            //Szint szűrése
            List <ItemGenerator> ItemDatabaseFilteredByLevel = ItemDataBase;//.Where(x => x.item_id == 67).ToList();

            ItemGenerator selectedItem = ItemDatabaseFilteredByLevel[random.Next(ItemDatabaseFilteredByLevel.Count)];

            newItem.item_id    = selectedItem.item_id;
            newItem.item_name  = selectedItem.item_name;
            newItem.item_image = selectedItem.item_image;
            newItem.item_level = selectedItem.item_level;

            //Mennyiség random
            newItem.item_isStackable = (selectedItem.item_isStackable == 0?false:true);

            if (selectedItem.item_quantityTo > 1)
            {
                newItem.item_quantity = random.Next(selectedItem.item_quantityFrom, selectedItem.item_quantityTo);
            }
            else
            {
                newItem.item_quantity = 1;
            }

            Thread.Sleep(50);
            //Minőség random
            newItem.item_quality = (EnumQuality)random.Next(selectedItem.item_qualityFrom, selectedItem.item_qualityTo + 1);

            newItem.item_type   = (EnumItemType)selectedItem.item_type;
            newItem.item_rarity = (EnumRarity)selectedItem.item_rarity;

            switch (newItem.item_type)
            {
            case EnumItemType.Fegyver:
                //Fegyver sebzés random
                int weaponDamage = random.Next(selectedItem.item_primaryStat_damageMax_randomMin, selectedItem.item_primaryStat_damageMax_randomMax);
                newItem.item_primaryStat_damageMax = StaticHelper.CalculateStatByQuality(weaponDamage, newItem.item_quality);
                break;

            case EnumItemType.Ruha:
                //Ruha védelem random
                int armorDefense = random.Next(selectedItem.item_primaryStat_defenseMax_randomMin, selectedItem.item_primaryStat_defenseMax_randomMax);
                newItem.item_primaryStat_defense = StaticHelper.CalculateStatByQuality(armorDefense, newItem.item_quality);
                break;

            case EnumItemType.Ital:
                //Poti hatás, idő
                newItem.item_potionEffect         = (EnumPotionEffect)selectedItem.item_potionEffect;
                newItem.item_potionEffectValue    = selectedItem.item_potionEffectValue;
                newItem.item_potionEffectDuration = selectedItem.item_potionEffectDuration;
                break;
            }



            switch (selectedItem.item_rarity)
            {
            case 1:
                Thread.Sleep(20);
                int[] bonuses1_1 = StaticHelper.RollABonus(selectedItem);
                newItem.item_bonus1Type  = (EnumPossibleBonusStats)bonuses1_1[0];
                newItem.item_bonus1Value = bonuses1_1[1];
                break;

            case 2:
                Thread.Sleep(20);
                int[] bonuses2_1 = StaticHelper.RollABonus(selectedItem);
                Thread.Sleep(20);
                int[] bonuses2_2 = StaticHelper.RollABonus(selectedItem);
                newItem.item_bonus1Type  = (EnumPossibleBonusStats)bonuses2_1[0];
                newItem.item_bonus1Value = bonuses2_1[1];

                newItem.item_bonus2Type  = (EnumPossibleBonusStats)bonuses2_2[0];
                newItem.item_bonus2Value = bonuses2_2[1];
                break;

            case 3:
                Thread.Sleep(20);
                int[] bonuses3_1 = StaticHelper.RollABonus(selectedItem);
                Thread.Sleep(20);
                int[] bonuses3_2 = StaticHelper.RollABonus(selectedItem);
                Thread.Sleep(20);
                int[] bonuses3_3 = StaticHelper.RollABonus(selectedItem);
                newItem.item_bonus1Type  = (EnumPossibleBonusStats)bonuses3_1[0];
                newItem.item_bonus1Value = bonuses3_1[1];

                newItem.item_bonus2Type  = (EnumPossibleBonusStats)bonuses3_2[0];
                newItem.item_bonus2Value = bonuses3_2[1];

                newItem.item_bonus3Type  = (EnumPossibleBonusStats)bonuses3_3[0];
                newItem.item_bonus3Value = bonuses3_3[1];
                break;
            }


            return(newItem);
        }