public static void SaveJsonFile(MonsterDropTableHandler monsterDropTable, string monsterName) { string jsonString = JsonUtility.ToJson(monsterDropTable); //TODO better way for path? File.WriteAllText(string.Concat(Application.dataPath, "/Resources/JSON/MonsterDropTable/", monsterName, ".json"), jsonString); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }
public void GetDropTableHandler(string name) { monsterDropTableHandler = JsonHandler.GetMonsterDropTableHandler(name); if (monsterDropTableHandler.preMadeTables.Count != 0) { foreach (MonsterDropTableHandler.TableInfo tableInfo in monsterDropTableHandler.preMadeTables) { MonsterDropTable table = JsonHandler.GetMonsterDropTable(tableInfo.name); table.weight = tableInfo.weight; monsterDropTableHandler.monsterDropTables.Add(table); } } monsterDropTableHandler.SetTotalLootCount(); }
private int GetWeightSum(MonsterDropTableHandler handler) { int weightSum = 0; foreach (MonsterDropTable.BasicLoot loot in handler.basicLoots) { weightSum += loot.weight; } foreach (MonsterDropTable table in handler.monsterDropTables) { weightSum += table.weight; } return(weightSum); }