public void ReadXml(string fileName)
    {
        string   sheetName = "Sheet1";
        Workbook workbook  = Workbook.CreatWorkbook(fileName, sheetName);
        Sheet    sheet     = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName + " in " + fileName);
            return;
        }

        Dictionary <string, List <LanguageTextEntry> > languages = new Dictionary <string, List <LanguageTextEntry> >();

        List <string> langKeys = sheet._rows[0]._cells;

        for (int i = 1; i < langKeys.Count; i++)
        {
            string lang = langKeys[i];
            languages.Add(lang, new List <LanguageTextEntry>());
        }


        for (int i = 1; i < sheet._rows.Count; i++)
        {
            Row    row = sheet._rows[i];
            string IDS = row._cells[0];
            for (int j = 1; j < row._cells.Count; j++)
            {
                LanguageTextEntry textEntry = new LanguageTextEntry();

                textEntry.key  = IDS;
                textEntry.text = row._cells[j];

                string lang = row._key[j];
                List <LanguageTextEntry> textEntryList = languages[lang];
                textEntryList.Add(textEntry);
            }
        }


        for (int i = 1; i < langKeys.Count; i++)
        {
            string lang = langKeys[i];
            List <LanguageTextEntry> textEntryList = languages[lang];

            string path = MultiLanguageAssetPostProcessor.MULTILANGUAGE_ASSETS_FOLDER;
            LocalizationEditorUtils.CreateDirectoryIfNotExist(path, "Fonts", lang);

            // Create config file that contain key-value strings.
            CreateLanguageDataBase(lang, textEntryList);

            // Create config file that contain uv and size information.
            CreateLanguageDictionary(lang, textEntryList);
        }
    }
Example #2
0
    public static void ReadMonthCard()
    {
        Workbook workbook = Workbook.CreatWorkbook(fileName, sheetName1);
        Sheet    sheet    = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName1 + " in " + fileName);
            return;
        }

        bool newFile = false;


        MonthCardIAP dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName1, typeof(MonthCardIAP));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(MonthCardIAP)) as MonthCardIAP;
        }
        else
        {
            dataList = oldFile as MonthCardIAP;
        }


        Row data = sheet._rows[1];

        dataList.iap_id = data["iap_id"];
        dataList.count  = GetInt(data["count"]);

        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName1);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }
    }
Example #3
0
    public static void ReadWeight(string sheetName, string outFileFolder, string outFileName)
    {
        Workbook workbook = Workbook.CreatWorkbook(fileName, sheetName);
        Sheet    sheet    = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName + " in " + fileName);
            return;
        }

        bool newFile = false;


        HeroEquipmentWeight dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(HeroEquipmentWeight));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(HeroEquipmentWeight)) as HeroEquipmentWeight;
        }
        else
        {
            dataList = oldFile as HeroEquipmentWeight;
        }


        dataList._weaponWeight   = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._helmWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._shoulderWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._beltWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._armpieceWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._leggingsWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._necklaceWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._ringWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();

        for (int i = 1; i < sheet._rows.Count; i++)
        {
            Row data = sheet._rows[i];

            PropertyWeightData newData = new PropertyWeightData();
            newData._type   = GetHitParam(data["WeaponType"]);
            newData._weight = GetInt(data["WeaponWeight"]);
            if (newData._type != AIHitParams.None && newData._weight > 0)
            {
                dataList._weaponWeight._dataList.Add(newData);
            }

            PropertyWeightData newData1 = new PropertyWeightData();
            newData1._type   = GetHitParam(data["HelmType"]);
            newData1._weight = GetInt(data["HelmWeight"]);
            if (newData1._type != AIHitParams.None && newData1._weight > 0)
            {
                dataList._helmWeight._dataList.Add(newData1);
            }

            PropertyWeightData newData2 = new PropertyWeightData();
            newData2._type   = GetHitParam(data["ShoulderType"]);
            newData2._weight = GetInt(data["ShoulderWeight"]);
            if (newData2._type != AIHitParams.None && newData2._weight > 0)
            {
                dataList._shoulderWeight._dataList.Add(newData2);
            }

            PropertyWeightData newData3 = new PropertyWeightData();
            newData3._type   = GetHitParam(data["BeltType"]);
            newData3._weight = GetInt(data["BeltWeight"]);
            if (newData3._type != AIHitParams.None && newData3._weight > 0)
            {
                dataList._beltWeight._dataList.Add(newData3);
            }

            PropertyWeightData newData4 = new PropertyWeightData();
            newData4._type   = GetHitParam(data["ArmpieceType"]);
            newData4._weight = GetInt(data["ArmpieceWeight"]);
            if (newData4._type != AIHitParams.None && newData4._weight > 0)
            {
                dataList._armpieceWeight._dataList.Add(newData4);
            }

            PropertyWeightData newData5 = new PropertyWeightData();
            newData5._type   = GetHitParam(data["LeggingsType"]);
            newData5._weight = GetInt(data["LeggingsWeight"]);
            if (newData5._type != AIHitParams.None && newData5._weight > 0)
            {
                dataList._leggingsWeight._dataList.Add(newData5);
            }

            PropertyWeightData newData6 = new PropertyWeightData();
            newData6._type   = GetHitParam(data["NecklaceType"]);
            newData6._weight = GetInt(data["NecklaceWeight"]);
            if (newData6._type != AIHitParams.None && newData6._weight > 0)
            {
                dataList._necklaceWeight._dataList.Add(newData6);
            }

            PropertyWeightData newData7 = new PropertyWeightData();
            newData7._type   = GetHitParam(data["RingType"]);
            newData7._weight = GetInt(data["RingWeight"]);
            if (newData7._type != AIHitParams.None && newData7._weight > 0)
            {
                dataList._ringWeight._dataList.Add(newData7);
            }
        }

        CreateWeightScriptObject(dataList._weaponWeight, outFileFolder, "weaponWeight");
        CreateWeightScriptObject(dataList._helmWeight, outFileFolder, "helmWeight");
        CreateWeightScriptObject(dataList._shoulderWeight, outFileFolder, "shoulderWeight");
        CreateWeightScriptObject(dataList._armpieceWeight, outFileFolder, "armpieceWeight");
        CreateWeightScriptObject(dataList._beltWeight, outFileFolder, "beltWeight");
        CreateWeightScriptObject(dataList._leggingsWeight, outFileFolder, "leggingsWeight");
        CreateWeightScriptObject(dataList._necklaceWeight, outFileFolder, "necklaceWeight");
        CreateWeightScriptObject(dataList._ringWeight, outFileFolder, "ringWeight");



        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }
    }
Example #4
0
    public static void Read()
    {
        Workbook workbook = Workbook.CreatWorkbook(fileName, sheetName);
        Sheet    sheet    = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName + " in " + fileName);
            return;
        }

        bool newFile = false;


        StoreDataList dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(StoreDataList));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(StoreDataList)) as StoreDataList;
        }
        else
        {
            dataList = oldFile as StoreDataList;
        }

        dataList._dataList.Clear();
        for (int i = 1; i < sheet._rows.Count; i++)
        {
            Row       data    = sheet._rows[i];
            StoreData newData = new StoreData();

            newData._id                = data["id"];
            newData._displayNameIds    = data["displayNameIds"];
            newData._order             = GetInt(data["order"]);
            newData._isVisibleOnStore  = GetBool(data["isVisibleOnStore"]);
            newData._visibleLevelMin   = GetInt(data["visibleLevelMin"]);
            newData._visibleLevelMax   = GetInt(data["visibleLevelMax"]);
            newData._order             = GetInt(data["order"]);
            newData._visibleStartTime  = data["visibleStartTime"];
            newData._visibleEndTime    = data["visibleEndTime"];
            newData._isRecommend       = GetBool(data["isRecommend"]);
            newData._isNew             = GetBool(data["isNew"]);
            newData._discount          = GetFloat(data["discount"]);
            newData._discountStartTime = data["discountStartTime"];
            newData._discountEndTime   = data["discountEndTime"];
            newData._storeType         = GetStoreItemType(data["storeType"]);
            newData._storeIconName     = data["storeIconName"];

            newData._normalInfo._itemID               = data["itemID"];
            newData._normalInfo._count                = GetInt(data["count"]);
            newData._normalInfo._hardCurrency         = GetInt(data["hardCurrency"]);
            newData._normalInfo._softCurrency         = GetInt(data["softCurrency"]);
            newData._normalInfo._dissountHardCurrency = GetInt(data["dissountHardCurrency"]);
            newData._normalInfo._discountSoftCurrency = GetInt(data["discountSoftCurrency"]);

            newData._iapInfo._iapId              = data["iapId"];
            newData._iapInfo._iapIdAndroid       = data["iapIdAndroid"];
            newData._iapInfo._hcCount            = GetInt(data["hcCount"]);
            newData._iapInfo._scCount            = GetInt(data["scCount"]);
            newData._iapInfo._bonusCount         = GetInt(data["bonusCount"]);
            newData._iapInfo._discountHcCount    = GetInt(data["discountHcCount"]);
            newData._iapInfo._discountScCount    = GetInt(data["discountScCount"]);
            newData._iapInfo._discountBonusCount = GetInt(data["discountBonusCount"]);
            newData._iapInfo._USD_price          = GetInt(data["USD_price"]);

            dataList._dataList.Add(newData);
        }

        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }
    }
Example #5
0
    public static void Read()
    {
        Workbook workbook = Workbook.CreatWorkbook(fileName, sheetName);
        Sheet    sheet    = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName + " in " + fileName);
            return;
        }

        bool newFile = false;


        SocketDataList dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(SocketDataList));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(SocketDataList)) as SocketDataList;
        }
        else
        {
            dataList = oldFile as SocketDataList;
        }

        dataList._dataList.Clear();
        for (int i = 1; i < sheet._rows.Count; i++)
        {
            Row        data    = sheet._rows[i];
            SocketData newData = new SocketData();

            newData._level     = GetInt(data["level"]);
            newData._rareLevel = GetInt(data["rareLevel"]);

            for (int k = 1; k <= 2; k++)
            {
                int    sc     = GetInt(data["socketSc" + k]);
                int    hc     = GetInt(data["socketHc" + k]);
                string itemId = data["socketItemId" + k];

                if (itemId.Length > 1)
                {
                    SocketNeed need = new SocketNeed();
                    need._itemId = itemId;
                    need._sc     = sc;
                    need._hc     = hc;
                    newData._need.Add(need);
                }
            }

            dataList._dataList.Add(newData);
        }

        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }
    }