private void Parser(XmlNodeList nodes, List <XmlCategory> temps)
 {
     foreach (XmlNode item in nodes)
     {
         XmlCategory t = new XmlCategory();
         t.id     = item.Attributes["id"].Value;
         t.text   = item.Attributes["text"].Value;
         t.name   = item.Attributes["name"].Value;
         t.gender = item.Attributes["gender"].Value;
         //Debug.Log(item.Attributes["id"].Value + " " + item.Attributes["text"].Value + " " + item.Attributes["name"].Value + " " + item.Attributes["gender"].Value);
         temps.Add(t);
     }
 }
        private T ItemCreate <T>(XmlCategory mod, XmlCategory currentWeapon, XmlCategory end, XmlCategory typeWeapon, ItemRarity rarity, float maxValue, float minValue, float valueW, int maxValueD, int minValueD, int width, int height, Sprite icon) where T : WeaponItem
        {
            T obj = ScriptableObject.CreateInstance <T>();

            obj.itemName        = mod.text + " " + currentWeapon.name + " " + end.text;
            obj.itemDescription = typeWeapon.text;
            obj.rarity          = rarity;
            obj.weight          = new VarFloat("Weight", valueW + (height + width));
            obj.damage          = new VarMinMax <float>("Damage", minValue + (height * 5f), maxValue + (height * 5f));
            obj.duration        = new VarMinMax <int>("Duration", minValueD, maxValueD);
            obj.itemIcon        = icon;
            obj.itemWidth       = width;
            obj.itemHeight      = height;
            return(obj);
        }
        /// <summary>
        /// передавать инт для выбора, что сгенерировать 1-оружие 2-броня 3 - украшения
        /// </summary>
        public Item Generator(int num)
        {
            XmlCategory mod;
            XmlCategory end;
            float       maxValue, minValue, valueW;
            int         maxValueD, minValueD, width, rar, height;

            Sprite     icon;
            ItemRarity rarity;

            //1 - оружка 2 - броня 3 - украшения
            switch (num)
            {
            case 1:
            {
                XmlCategory currentWeapon = GetRandom(weapons.ToArray());
                XmlCategory typeWeapon;


                maxValue = float.Parse(Random.Range(5f, 15f).ToString("F1"));
                minValue = float.Parse(Random.Range(1f, 5f).ToString("F1"));

                valueW = float.Parse(Random.Range(0.6f, 2.5f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 1;
                rar       = Random.Range(0, 4);
                height    = Random.Range(2, 4);
                rarity    = (ItemRarity)rar;
                //1 - одноручка 2 -двуручка
                switch (currentWeapon.id)
                {
                case ("1"):
                {
                    typeWeapon = GetRandom(OneHanded.ToArray());
                    //Debug.Log(currentWeapon.name + " " + currentWeapon.gender);
                    mod = GetRandomWithGender(modsW, currentWeapon.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(OneH);
                    return(ItemCreate <OneHandedItem>(mod, currentWeapon, end, typeWeapon, rarity, maxValue, minValue, valueW, maxValueD, minValueD, width, height, icon));
                }

                case ("2"):
                {
                    typeWeapon = GetRandom(TwoHanded.ToArray());
                    //Debug.Log(currentWeapon.name + " " + currentWeapon.gender);
                    mod = GetRandomWithGender(modsW, currentWeapon.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(TwoH);
                    return(ItemCreate <TwoHandedItem>(mod, currentWeapon, end, typeWeapon, rarity, maxValue * 2, minValue * 2, valueW * 2, maxValueD, minValueD, width * 2, height, icon));
                }
                }
                return(null);
            }

            case (2):
                XmlCategory currentArmor = GetRandom(armors.ToArray());
                XmlCategory typeArmor;
                maxValue = float.Parse(Random.Range(5f, 15f).ToString("F1"));

                valueW = float.Parse(Random.Range(2f, 6f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 2;
                rar       = Random.Range(0, 4);
                height    = 2;
                rarity    = (ItemRarity)rar;
                ///1-шлем 2-грудь 3- пояс 4 - поножи 5 - боты 6 - щит
                switch (currentArmor.id)
                {
                case ("1"):
                    typeArmor = GetRandom(head.ToArray());
                    //Debug.Log(currentArmor.name+" "+currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Head);
                    return(ItemCreate <HeadItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));

                case ("2"):
                    height   += Random.Range(0, 2);
                    valueW   *= 5f;
                    maxValue += (int)(height * width * 5f);
                    typeArmor = GetRandom(torso.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Torso);
                    return(ItemCreate <TorsoItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));

                case ("3"):
                    height    = 1;
                    valueW    = float.Parse(Random.Range(0.5f, 2f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(belt.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Belt);
                    return(ItemCreate <WaistItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));

                case ("4"):
                    height    = Random.Range(2, 4);
                    valueW    = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(legs.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Legs);
                    return(ItemCreate <LegsItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));

                case ("5"):
                    valueW    = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(feets.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Feets);
                    return(ItemCreate <FeetItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));

                case ("6"):
                    height   += Random.Range(0, 2);
                    valueW   *= 2.5f;
                    maxValue += (int)(height * width * 2.5f);
                    typeArmor = GetRandom(shields.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Shields);
                    return(ItemCreate <OffHandItem>(mod, currentArmor, end, typeArmor, rarity, maxValue, valueW + (height + width), maxValueD, minValueD, width, height, icon));
                }
                return(null);

            case (3):
                XmlCategory currentJewelry = GetRandom(jewerlys.ToArray());
                XmlCategory typeJewelry;
                maxValue = float.Parse(Random.Range(0.5f, 1.5f).ToString("F1"));

                valueW = float.Parse(Random.Range(0.01f, 0.5f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 1;
                rar       = Random.Range(0, 4);
                height    = 1;
                rarity    = (ItemRarity)rar;
                //1 - кольцо
                switch (currentJewelry.id)
                {
                case ("1"):
                    typeJewelry = GetRandom(ring.ToArray());
                    //Debug.Log(currentJewelry.name+" "+ currentJewelry.gender);
                    mod = GetRandomWithGender(modsA, currentJewelry.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Ring);
                    return(ItemCreate <JewerlyItem>(mod, currentJewelry, end, typeJewelry, rarity, maxValue, valueW, maxValueD, minValueD, width, height, icon));

                case ("2"):
                    width++;
                    height++;
                    maxValue    = float.Parse(Random.Range(1.5f, 3f).ToString("F1"));
                    valueW      = float.Parse(Random.Range(0.1f, 1.5f).ToString("F1"));
                    typeJewelry = GetRandom(wrist.ToArray());
                    //Debug.Log(currentJewelry.name+" "+ currentJewelry.gender);
                    mod = GetRandomWithGender(modsA, currentJewelry.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end  = GetRandom(endsW.ToArray());
                    icon = GetRandom(Wrist);
                    return(ItemCreate <WristItem>(mod, currentJewelry, end, typeJewelry, rarity, maxValue, valueW, maxValueD, minValueD, width, height, icon));
                }
                return(null);
            }
            return(null);
        }
        /// <summary>
        /// передавать инт для выбора, что сгенерировать 1-оружие 2-броня 3 - украшения
        /// </summary>
        public void Generator(int num)
        {
            XmlCategory mod;
            XmlCategory end;
            float       maxValue, minValue, valueW;
            int         maxValueD, minValueD, width, rar, height;

            Sprite icon;

            //1 - оружка 2 - броня 3 - украшения
            switch (num)
            {
            case 1:
            {
                XmlCategory currentWeapon = GetRandom(weapons.ToArray());
                XmlCategory typeWeapon;


                maxValue = float.Parse(Random.Range(5f, 15f).ToString("F1"));
                minValue = float.Parse(Random.Range(1f, 5f).ToString("F1"));

                valueW = float.Parse(Random.Range(0.6f, 2.5f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 1;
                rar       = Random.Range(0, 4);
                height    = Random.Range(2, 4);
                //1 - одноручка 2 -двуручка
                switch (currentWeapon.id)
                {
                case ("1"):
                {
                    typeWeapon = GetRandom(OneHanded.ToArray());
                    //Debug.Log(currentWeapon.name + " " + currentWeapon.gender);
                    mod = GetRandomWithGender(modsW, currentWeapon.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(OneH);
                    text.text += (mod.text + " " + currentWeapon.name + " " + end.text + "\n\n " + typeWeapon.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;
                }

                case ("2"):
                {
                    typeWeapon = GetRandom(TwoHanded.ToArray());
                    //Debug.Log(currentWeapon.name + " " + currentWeapon.gender);
                    mod = GetRandomWithGender(modsW, currentWeapon.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(TwoH);
                    text.text += (mod.text + " " + currentWeapon.name + " " + end.text + "\n\n " + typeWeapon.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;
                }
                }
                return;
            }

            case (2):
                XmlCategory currentArmor = GetRandom(armors.ToArray());
                XmlCategory typeArmor;
                maxValue = float.Parse(Random.Range(5f, 15f).ToString("F1"));

                valueW = float.Parse(Random.Range(2f, 6f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 2;
                rar       = Random.Range(0, 4);
                height    = 2;
                ///1-шлем 2-грудь 3- пояс 4 - поножи 5 - боты 6 - щит
                switch (currentArmor.id)
                {
                case ("1"):
                    typeArmor = GetRandom(head.ToArray());
                    //Debug.Log(currentArmor.name+" "+currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Head);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n \n" + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("2"):
                    height   += Random.Range(0, 2);
                    valueW   *= 5f;
                    maxValue += (int)(height * width * 5f);
                    typeArmor = GetRandom(torso.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Torso);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n \n" + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("3"):
                    height    = 1;
                    valueW    = float.Parse(Random.Range(0.5f, 2f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(belt.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Belt);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n \n" + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("4"):
                    height    = Random.Range(2, 4);
                    valueW    = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(legs.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Legs);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n \n" + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("5"):
                    valueW    = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    maxValue  = float.Parse(Random.Range(1f, 5f).ToString("F1"));
                    typeArmor = GetRandom(feets.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Feets);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n\n " + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("6"):
                    height   += Random.Range(0, 2);
                    valueW   *= 2.5f;
                    maxValue += (int)(height * width * 2.5f);
                    typeArmor = GetRandom(shields.ToArray());
                    //Debug.Log(currentArmor.name + " " + currentArmor.gender);
                    mod = GetRandomWithGender(modsA, currentArmor.gender);
                    //Debug.Log(mod.text + " " + mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Shields);
                    text.text += (mod.text + " " + currentArmor.name + " " + end.text + "\n \n" + typeArmor.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;
                }
                return;

            case (3):
                XmlCategory currentJewelry = GetRandom(jewerlys.ToArray());
                XmlCategory typeJewelry;
                maxValue = float.Parse(Random.Range(0.5f, 1.5f).ToString("F1"));

                valueW = float.Parse(Random.Range(0.01f, 0.5f).ToString("F1"));

                maxValueD = Random.Range(1, 100);
                minValueD = Random.Range(1, 100);
                width     = 1;
                rar       = Random.Range(0, 4);
                height    = 1;
                //1 - кольцо
                switch (currentJewelry.id)
                {
                case ("1"):
                    typeJewelry = GetRandom(ring.ToArray());
                    //Debug.Log(currentJewelry.name+" "+ currentJewelry.gender);
                    mod = GetRandomWithGender(modsA, currentJewelry.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Ring);
                    text.text += (mod.text + " " + currentJewelry.name + " " + end.text + "\n\n " + typeJewelry.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;

                case ("2"):
                    width++;
                    height++;
                    maxValue    = float.Parse(Random.Range(1.5f, 3f).ToString("F1"));
                    valueW      = float.Parse(Random.Range(0.1f, 1.5f).ToString("F1"));
                    typeJewelry = GetRandom(wrist.ToArray());
                    //Debug.Log(currentJewelry.name+" "+ currentJewelry.gender);
                    mod = GetRandomWithGender(modsA, currentJewelry.gender);
                    //Debug.Log(mod.text+" "+mod.gender);
                    end        = GetRandom(endsW.ToArray());
                    icon       = GetRandom(Wrist);
                    text.text += (mod.text + " " + currentJewelry.name + " " + end.text + "\n\n " + typeJewelry.text + "\nArmor= " + maxValue + " Weight= " + valueW + " Height and width= (" + height + " " + width + ") DurabilityMax =" + maxValueD + "DurabilityMin= " + minValueD + "\n\n");
                    return;
                }
                return;
            }
            return;
        }