/// <summary> /// 初期ステータスを読み込む /// </summary> /// <param name="jobName">Load job name</param> /// <returns>True is completed but false is not completed</returns> public static bool LoadFirstStatus() { // 職業、キャラクター、名前を引き継ぐ int job = playerData.job; int character = playerData.characterNumber; string name = (string)playerData.name.Clone(); // 新しくインスタンスを作成する playerData = new PlayerData(); // 名前を入れる playerData.name = name; // キャラクターの番号を入れる playerData.characterNumber = character; // 職業番号を入れる playerData.job = job; // 初期ステータスを読み込む Entity_FirstStatus.Param jobFirstStatus = firstStatus.sheets[playerData.job].list[0]; // 各ステータスを反映させる playerData.HP = playerData.MaxHP = jobFirstStatus.HP; playerData.SP = playerData.MaxSP = jobFirstStatus.SP; playerData.attack = jobFirstStatus.Attack; playerData.defense = jobFirstStatus.Defense; playerData.magicAttack = jobFirstStatus.MagicAttack; playerData.magicDefence = jobFirstStatus.MagicDefense; // 最初にボーナスステータスポイントとボーナススキルポイントを与える playerData.statusPoint = 10; playerData.skillPoint = 10; playerData.Lv = 1; return(true); }
/// <summary> /// ステータスの再計算 /// </summary> public static void UpdateStatus() { // 初期ステータスを読み込む Entity_FirstStatus.Param jobFirstStatus = firstStatus.sheets[playerData.job].list[0]; // ステータスを配列にまとめる int[] statusValue = { playerData.str, playerData.vit, playerData.intelligence, playerData.mnd }; // 各ステータスを反映させる playerData.MaxHP = jobFirstStatus.HP; playerData.MaxSP = jobFirstStatus.SP; playerData.attack = jobFirstStatus.Attack; playerData.defense = jobFirstStatus.Defense; playerData.magicAttack = jobFirstStatus.MagicAttack; playerData.magicDefence = jobFirstStatus.MagicDefense; // 現在の振れるステータスの値によってステータスを加算する for (int i = 0; i < statusValue.Length; i++) { // 上がり幅を計算する playerData.MaxHP += (int)(statusValue[i] * level_status.sheets[i].list[0].HP); playerData.MaxSP += (int)(statusValue[i] * level_status.sheets[i].list[0].SP); playerData.attack += (int)(statusValue[i] * level_status.sheets[i].list[0].Attack); playerData.defense += (int)(statusValue[i] * level_status.sheets[i].list[0].Defense); playerData.magicAttack += (int)(statusValue[i] * level_status.sheets[i].list[0].MagicAttack); playerData.magicDefence += (int)(statusValue[i] * level_status.sheets[i].list[0].MagicDefense); } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } Entity_FirstStatus data = (Entity_FirstStatus)AssetDatabase.LoadAssetAtPath(exportPath, typeof(Entity_FirstStatus)); if (data == null) { data = ScriptableObject.CreateInstance <Entity_FirstStatus> (); AssetDatabase.CreateAsset((ScriptableObject)data, exportPath); data.hideFlags = HideFlags.NotEditable; } data.sheets.Clear(); using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { IWorkbook book = new HSSFWorkbook(stream); foreach (string sheetName in sheetNames) { ISheet sheet = book.GetSheet(sheetName); if (sheet == null) { Debug.LogError("[QuestData] sheet not found:" + sheetName); continue; } Entity_FirstStatus.Sheet s = new Entity_FirstStatus.Sheet(); s.name = sheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; Entity_FirstStatus.Param p = new Entity_FirstStatus.Param(); cell = row.GetCell(0); p.HP = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(1); p.SP = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(2); p.Attack = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(3); p.Defense = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(4); p.MagicAttack = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(5); p.MagicDefense = (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); } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals (asset)) continue; Entity_FirstStatus data = (Entity_FirstStatus)AssetDatabase.LoadAssetAtPath (exportPath, typeof(Entity_FirstStatus)); if (data == null) { data = ScriptableObject.CreateInstance<Entity_FirstStatus> (); AssetDatabase.CreateAsset ((ScriptableObject)data, exportPath); data.hideFlags = HideFlags.NotEditable; } data.sheets.Clear (); using (FileStream stream = File.Open (filePath, FileMode.Open, FileAccess.Read)) { IWorkbook book = new HSSFWorkbook (stream); foreach(string sheetName in sheetNames) { ISheet sheet = book.GetSheet(sheetName); if( sheet == null ) { Debug.LogError("[QuestData] sheet not found:" + sheetName); continue; } Entity_FirstStatus.Sheet s = new Entity_FirstStatus.Sheet (); s.name = sheetName; for (int i=1; i<= sheet.LastRowNum; i++) { IRow row = sheet.GetRow (i); ICell cell = null; Entity_FirstStatus.Param p = new Entity_FirstStatus.Param (); cell = row.GetCell(0); p.HP = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(1); p.SP = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(2); p.Attack = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(3); p.Defense = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(4); p.MagicAttack = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(5); p.MagicDefense = (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); } }