Esempio n. 1
0
    private static void CreateArmorConfig()
    {
        List <Dictionary <string, string> > xxListResult;


        #region BasicHeros
        xxListResult = ReadVSC("hero");
        HeroRace[]      heroRaces   = Resources.LoadAll <HeroRace>("");
        RoleCareer[]    careers     = Resources.LoadAll <RoleCareer>("");
        List <HeroInfo> AlreadyHave = Resources.LoadAll <HeroInfo>("").ToList();
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];

            if (AlreadyHave.Exists(x => x.ID == Dic["id"]))
            {
                continue;
            }
            //
            HeroInfo     mi  = ScriptableObject.CreateInstance <HeroInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            int Race = StringToInteger(Dic["race"]);
            foreach (HeroRace race in heroRaces)
            {
                if (race.Index == Race)
                {
                    mi.Race = race; break;
                }
            }
            int career = StringToInteger(Dic["career"]);
            foreach (RoleCareer c in careers)
            {
                if (c.Index == career)
                {
                    mi.Career = c; break;
                }
            }
            mi.InitRAL(RALByDictionary(Dic));
            mi.WeaponRaceList = GetWeaponTypeList(Dic["weaponClass"]);
            mi.SpecialStr     = Dic["specialStr"];
            mi.AddSkillData(
                getSkillsByString(Dic["skill0"])
                , getSkillsByString(Dic["skill1"])
                , getSkillsByString(Dic["skillOmega"])
                );
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/heroes/"
                                      + career + "_"
                                      + mi.ID.Substring(mi.ID.Length - 3) + "_" + mi.Name + ".asset");
        }
        #endregion
        return;

        #region enemy
        xxListResult = CreateConfig.ReadVSC("enemy");
        EnemyRank[] eRanks = Resources.LoadAll <EnemyRank>("");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            EnemyInfo    mi  = ScriptableObject.CreateInstance <EnemyInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            mi.Race = EnemyRaces(Dic["race"]);

            int ranktype = StringToInteger(Dic["rank"]);
            foreach (EnemyRank rank in eRanks)
            {
                if (rank.Index == ranktype)
                {
                    mi.EnemyRank = rank; break;
                }
            }
            mi.RAL              = RALByDictionary(Dic);
            mi.weight           = StringToInteger(Dic["weight"]);
            mi.dropPercent      = StringToInteger(Dic["dropRate"]);
            mi.StartAppearLevel = StringToInteger(Dic["startLevel"]);
            mi.EndAppearLevel   = StringToInteger(Dic["endLevel"]);
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/enemies/"
                                      + mi.ID.Split('#')[1] + mi.Name + ".asset");
        }
        #endregion
        return;

        #region Equip
        xxListResult = CreateConfig.ReadVSC("equip");
        ArmorRank[]        armor_ranks  = Resources.LoadAll <ArmorRank>("");
        WeaponRace[]       waepon_races = Resources.LoadAll <WeaponRace>("");
        List <SpriteAtlas> allAtlas     = Resources.LoadAll <SpriteAtlas>("Sprites/atlas").ToList();
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            EquipItem ei = ScriptableObject.CreateInstance <EquipItem>();
            ei.initData(Dic["id"], Dic["name"], Dic["desc"], CreateConfig.StringToInteger(Dic["level"])
                        , false, true, true, true, false, Dic["specialStr"]);
            ei.ResistStr = Dic["resistStr"];
            //
            int rankType = CreateConfig.StringToInteger(Dic["type"]);
            foreach (ArmorRank rank in armor_ranks)
            {
                if (rank.Index == rankType)
                {
                    ei.ArmorRank = rank; break;
                }
            }
            if (!string.IsNullOrEmpty(Dic["suit"]))
            {
                ei.SuitBelong = true; ei.SuitId = Dic["suit"];
            }
            //
            ei.RAL           = RALBySpecialStr(RoleAttributeList.zero, Dic["specialStr"]);
            ei.RAL           = RALByResistStr(ei.RAL, Dic["resistStr"]);
            ei.PassiveEffect = Dic["passiveEffect"];
            //
            string        _class = Dic["class"];
            EquipPosition pos    = ROHelp.EQUIP_POS(_class);
            ei.EquipPos = pos;
            if (pos == EquipPosition.Hand)
            {
                string weaponClass = Dic["weaponClass"].ToLower();
                foreach (WeaponRace r in waepon_races)
                {
                    if (weaponClass == r.NAME.ToLower())
                    {
                        ei.WeaponRace = r; break;
                    }
                }
            }


            //
            AssetDatabase.CreateAsset(ei, "Assets/Resources/ScriptableObjects/items/Equips/"
                                      + (int)ei.EquipPos + "_"
                                      + ei.LEVEL + "_" + ei.NAME + ".asset");
        }
        #endregion
        return;

        xxListResult = ReadVSC("hero");
        //HeroRace[] heroRaces = Resources.LoadAll<HeroRace>("");
        //RoleCareer[] careers = Resources.LoadAll<RoleCareer>("");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            HeroInfo     mi  = ScriptableObject.CreateInstance <HeroInfo>();
            CharacterSex sex = (CharacterSex)(StringToInteger(Dic["gender"]));
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], sex, "");
            int Race = StringToInteger(Dic["race"]);
            foreach (HeroRace race in heroRaces)
            {
                if (race.Index == Race)
                {
                    mi.Race = race; break;
                }
            }
            int career = StringToInteger(Dic["career"]);
            foreach (RoleCareer c in careers)
            {
                if (c.Index == career)
                {
                    mi.Career = c; break;
                }
            }
            mi.InitRAL(RALByDictionary(Dic));
            mi.WeaponRaceList = GetWeaponTypeList(Dic["weaponClass"]);
            mi.SpecialStr     = Dic["specialStr"];
            mi.AddSkillData(
                getSkillsByString(Dic["skill0"])
                , getSkillsByString(Dic["skill1"])
                , getSkillsByString(Dic["skillOmega"])
                );
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/heroes/"
                                      + career + "_"
                                      + mi.ID.Substring(mi.ID.Length - 3) + "_" + mi.Name + ".asset");
        }

        return;



        return;

        #region Consumable
        xxListResult = CreateConfig.ReadVSC("material");
        for (int i = 0; i < xxListResult.Count; i++)
        {
            Dictionary <string, string> Dic = xxListResult[i];
            SDConstants.MaterialType    MT  = CreateConfig.getMTypeByString(Dic["materialType"]);
            consumableItem mi = ScriptableObject.CreateInstance <consumableItem>();
            mi.initData(Dic["id"], Dic["name"], Dic["desc"], CreateConfig.StringToInteger(Dic["level"])
                        , false, true, true, true, false, Dic["specialStr"], SDConstants.ItemType.Consumable);
            mi.MaterialType     = MT;
            mi.buyPrice_coin    = StringToInteger(Dic["buyPrice_coin"]);
            mi.buyPrice_diamond = StringToInteger(Dic["buyPrice_diamond"]);
            mi.minLv            = StringToInteger(Dic["minLv"]);
            mi.maxLv            = StringToInteger(Dic["maxLv"]);
            mi.exchangeType     = StringToInteger(Dic["exchangeType"]);
            mi.weight           = StringToInteger(Dic["weight"]);
            mi.ConsumableType   = (SDConstants.ConsumableType)StringToInteger(Dic["consumableType"]);
            if (Dic.ContainsKey("range"))
            {
                mi.AOE = ROHelp.AOE_TYPE(Dic["range"]);
            }
            if (Dic.ContainsKey("target"))
            {
                mi.AIM = Dic["target"].ToUpper();
            }
            //
            AssetDatabase.CreateAsset(mi, "Assets/Resources/ScriptableObjects/items/Consumables/"
                                      + mi.ID.Substring(mi.ID.Length - 3) + mi.NAME + ".asset");
        }
        #endregion
    }