Exemplo n.º 1
0
    void StatusInit()
    {
        PC = Resources.Load("ExcelData/player_chara") as player_charaList;
        PG = Resources.Load("ExcelData/playerGrow") as playerGrow;

        //  レベル1時の初期ステータスを取得
        for (int charID = 0; charID < 6; charID++)
        {
            StatusList[charID] = new statusData()
            {
                CharName = PC.sheets[0].list[charID].Name,
                LV       = 3,
                HP       = (int)PC.sheets[0].list[charID].HP,
                SP       = (int)PC.sheets[0].list[charID].SP,
                ATK      = (int)PC.sheets[0].list[charID].ATK,
                DEF      = (int)PC.sheets[0].list[charID].DEF,
                SPD      = (int)PC.sheets[0].list[charID].SPD,
                MAT      = (int)PC.sheets[0].list[charID].MAT,
                MDF      = (int)PC.sheets[0].list[charID].MDF,
                LUK      = (int)PC.sheets[0].list[charID].LUK,
                EXP      = 220
            };

            StatusGrowList[charID] = new statusData()
            {
                LV  = 1,
                HP  = (int)PG.sheets[0].list[charID].GROWHP,
                SP  = (int)PG.sheets[0].list[charID].GROWSP,
                ATK = (int)PG.sheets[0].list[charID].GROWATK,
                DEF = (int)PG.sheets[0].list[charID].GROWDEF,
                SPD = (int)PG.sheets[0].list[charID].GROWSPD,
                MAT = (int)PG.sheets[0].list[charID].GROWMAT,
                MDF = (int)PG.sheets[0].list[charID].GROWMDF,
                LUK = (int)PG.sheets[0].list[charID].GROWLUK,
                EXP = 0
            };
        }
    }
Exemplo n.º 2
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            playerGrow data = (playerGrow)AssetDatabase.LoadAssetAtPath(exportPath, typeof(playerGrow));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <playerGrow> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            data.sheets.Clear();
            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                IWorkbook book = null;
                if (Path.GetExtension(filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                foreach (string sheetName in sheetNames)
                {
                    ISheet sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[QuestData] sheet not found:" + sheetName);
                        continue;
                    }

                    playerGrow.Sheet s = new playerGrow.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        playerGrow.Param p = new playerGrow.Param();

                        cell = row.GetCell(0); p.ID = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.Name = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(2); p.GROWHP = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(3); p.GROWSP = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(4); p.GROWATK = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(5); p.GROWDEF = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(6); p.GROWSPD = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(7); p.GROWMAT = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(8); p.GROWMDF = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(9); p.GROWLUK = (cell == null ? 0.0 : cell.NumericCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }