static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } EXP_List data = (EXP_List)AssetDatabase.LoadAssetAtPath(exportPath, typeof(EXP_List)); if (data == null) { data = ScriptableObject.CreateInstance <EXP_List> (); 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; } EXP_List.Sheet s = new EXP_List.Sheet(); s.name = sheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; EXP_List.Param p = new EXP_List.Param(); cell = row.GetCell(0); p.CurrentLV = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(1); p.TotalExp = (int)(cell == null ? 0 : cell.NumericCellValue); s.list.Add(p); } data.sheets.Add(s); } } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); } }
// 経験値の獲得&レベルアップ処理 public bool AcquisitionExp(int id, int exp) { bool LevelUpFlag = false; if (StatusList[id - 1].LV < 99) { StatusList[id - 1].EXP += exp; EL = Resources.Load("ExcelData/EXP_List") as EXP_List; // レベルアップするために必要な総経験値 int levelUpExp = EL.sheets[0].list[StatusList[id - 1].LV - 1].TotalExp; while (StatusList[id - 1].EXP >= levelUpExp) { StatusList[id - 1].LV++; levelUpExp = EL.sheets[0].list[StatusList[id - 1].LV - 1].TotalExp; // レベルアップしたらtrueを返してレベルアップしたことを伝える LevelUpFlag = true; } } return(LevelUpFlag); }
// レベルアップまでに必要な経験値 public int GetNextLevelExp(int charID) { EL = Resources.Load("ExcelData/EXP_List") as EXP_List; return((EL.sheets[0].list[StatusList[charID - 1].LV - 1].TotalExp) - (StatusList[charID - 1].EXP)); }