private void DBLoad_Character_Race() { DatabaseLoading("character_races", (reader) => { switch (reader.Name) { case "character_race": { int id = int.Parse(reader.GetAttribute("id")); string name = reader.GetAttribute("name"); string ages = reader.GetAttribute("ages"); string genders = reader.GetAttribute("genders"); int[] ageArray; if (!MathX.ParseIntArrayFromString(ages, out ageArray)) { Debug.LogError("ages cannot be parsed from character_races id: " + id + "!"); } int[] genderArray; if (!MathX.ParseIntArrayFromString(genders, out genderArray)) { Debug.LogError("genders cannot be parsed from character_races id: " + id + "!"); } List <db_character_age> tempAgeList = new List <db_character_age>(); for (int i = 0; i < ageArray.Length; i++) { int index = dbCharacterAgeList.FindIndex(x => x.id == ageArray[i]); Debug.Assert(index != -1, "character_races id:" + id + " is trying to access invalid ageId: " + ageArray[i] + "!"); tempAgeList.Add(dbCharacterAgeList[index]); } List <db_character_gender> tempGenderList = new List <db_character_gender>(); for (int i = 0; i < genderArray.Length; i++) { int index = dbCharacterGenderList.FindIndex(x => x.id == genderArray[i]); Debug.Assert(index != -1, "character_races id:" + id + " is trying to access invalid genderId: " + ageArray[i] + "!"); tempGenderList.Add(dbCharacterGenderList[index]); } db_character_race race = new db_character_race(); race.id = id; race.name = name; race.ages = tempAgeList.ToArray(); race.genders = tempGenderList.ToArray(); dbCharacterRaceList.Add(race); } break; } }); }
private void DBLoad_Character_SubModel() { DatabaseLoading("character_subModels", (reader) => { switch (reader.Name) { case "character_subModel": { int id = int.Parse(reader.GetAttribute("id")); string name = reader.GetAttribute("name"); string path = reader.GetAttribute("path"); int type = int.Parse(reader.GetAttribute("type")); string models = reader.GetAttribute("models"); int[] modelIds; MathX.ParseIntArrayFromString(models, out modelIds); List <db_character_model> tempModels = new List <db_character_model>(); for (int i = 0; i < modelIds.Length; i++) { int index = dbCharacterModelList.FindIndex(x => x.id == modelIds[i]); if (index == -1) { Debug.Log("subModel '" + id + "' is trying to access unknown model '" + modelIds[i] + "'"); continue; } tempModels.Add(dbCharacterModelList[index]); } db_character_submodel subModel = new db_character_submodel(); subModel.id = id; subModel.name = name; subModel.path = path; subModel.type = (db_character_submodel.Type)type; subModel.models = tempModels.ToArray(); dbCharacterSubModelList.Add(subModel); } break; } }); }