/// <summary> /// Read creature definition according to base /// </summary> /// <param name="reader"></param> /// <returns></returns> public static CreatureDefinition ReadFromFile(ResourceDataFile reader, Dictionary <int, CreatureDefinition> creatureBases) { if (creatureBases == null) { return(null); } CreatureDefinition definition = new CreatureDefinition(); definition.DefinitionId = reader.ReadInt(); int baseId = reader.ReadInt(); definition.InitialLevel = reader.ReadInt(); CreatureDefinition baseDef = creatureBases[baseId]; if (baseDef == null) { return(null); } definition.AnimationId = baseDef.AnimationId; definition.Name = baseDef.Name; definition.Race = baseDef.Race; definition.Occupation = baseDef.Occupation; definition.InitialAp = baseDef.InitialAp * definition.InitialLevel; definition.InitialDp = baseDef.InitialDp * definition.InitialLevel; definition.InitialDx = baseDef.InitialDx * definition.InitialLevel; definition.InitialHp = baseDef.InitialHp * definition.InitialLevel; definition.InitialMp = baseDef.InitialMp * definition.InitialLevel; definition.InitialMv = baseDef.InitialMv; definition.InitialEx = baseDef.InitialEx; int itemCount = reader.ReadInt(); for (int i = 0; i < itemCount; i++) { int itemId = reader.ReadInt(); definition.Items.Add(itemId); } int magicCount = reader.ReadInt(); for (int i = 0; i < magicCount; i++) { int magicId = reader.ReadInt(); definition.Magics.Add(magicId); } return(definition); }
/// <summary> /// Read creature base definition /// </summary> /// <param name="reader"></param> /// <returns></returns> public static CreatureDefinition ReadBaseFromFile(ResourceDataFile reader) { CreatureDefinition definition = new CreatureDefinition(); definition.DefinitionId = reader.ReadInt(); definition.AnimationId = definition.DefinitionId % 1000; definition.Name = ""; // TODO: Localize definition.Race = reader.ReadInt(); definition.Occupation = reader.ReadInt(); definition.InitialAp = reader.ReadInt(); definition.InitialDp = reader.ReadInt(); definition.InitialDx = reader.ReadInt(); definition.InitialHp = reader.ReadInt(); definition.InitialMp = reader.ReadInt(); definition.InitialMv = reader.ReadInt(); definition.InitialEx = reader.ReadInt(); return(definition); }
private void LoadCreatureDefinitions() { creatureDefinitions = new Dictionary <int, CreatureDefinition>(); ResourceDataFile fileReader = new ResourceDataFile(@"Data/Creature"); int creatureCount = fileReader.ReadInt(); for (int i = 0; i < creatureCount; i++) { CreatureDefinition def = CreatureDefinition.ReadFromFile(fileReader); creatureDefinitions[def.DefinitionId] = def; } creatureBaseDefinitions = new Dictionary <int, CreatureDefinition>(); ResourceDataFile fileReader2 = new ResourceDataFile(@"Data/LeveledCreature"); int creatureBaseCount = fileReader2.ReadInt(); for (int i = 0; i < creatureBaseCount; i++) { CreatureDefinition def = CreatureDefinition.ReadBaseFromFile(fileReader2); creatureBaseDefinitions[def.DefinitionId] = def; } }
/// <summary> /// Load two files: chapter_N.dat for json, chapter_N_data.dat for plain text /// </summary> /// <param name="chapterId"></param> /// <returns></returns> public ChapterDefinition LoadChapter(int chapterId) { if (chapterDefinitions == null) { chapterDefinitions = new Dictionary <int, ChapterDefinition>(); } if (chapterDefinitions.ContainsKey(chapterId)) { return(chapterDefinitions[chapterId]); } // Load Chapter ChapterDefinition chapter = ResourceJsonFile.Load <ChapterDefinition>(string.Format(@"Data/Chapters/Chapter_{0}", StringUtils.Digit2(chapterId))); chapter.ChapterId = chapterId; // Load Chapter ConversationId ResourceDataFile conversationIdFile = new ResourceDataFile(string.Format(@"Data/Chapters/Chapter_{0}_ConversationId", StringUtils.Digit2(chapterId))); chapter.ReadConversationIdsFromFile(conversationIdFile); // Load Chapter Creatures creatureChapterDefinitions = new Dictionary <int, CreatureDefinition>(); ResourceDataFile fileReader2 = new ResourceDataFile(string.Format(@"Data/Chapters/Chapter_{0}_Creature", StringUtils.Digit2(chapterId))); int cCount = fileReader2.ReadInt(); for (int i = 0; i < cCount; i++) { CreatureDefinition def = CreatureDefinition.ReadFromFile(fileReader2, creatureBaseDefinitions); creatureChapterDefinitions[def.DefinitionId] = def; } chapterDefinitions[chapterId] = chapter; return(chapter); }
public static CreatureDefinition ReadFromFile(ResourceDataFile reader) { CreatureDefinition definition = new CreatureDefinition(); definition.DefinitionId = reader.ReadInt(); definition.AnimationId = definition.DefinitionId % 1000; definition.Name = ""; // TODO: Localize definition.Race = reader.ReadInt(); definition.Occupation = reader.ReadInt(); definition.InitialLevel = reader.ReadInt(); definition.InitialAp = reader.ReadInt(); definition.InitialDp = reader.ReadInt(); definition.InitialDx = reader.ReadInt(); definition.InitialHp = reader.ReadInt(); definition.InitialMp = reader.ReadInt(); definition.InitialMv = reader.ReadInt(); definition.InitialEx = reader.ReadInt(); int itemCount = reader.ReadInt(); for (int i = 0; i < itemCount; i++) { int itemId = reader.ReadInt(); definition.Items.Add(itemId); } int magicCount = reader.ReadInt(); for (int i = 0; i < magicCount; i++) { int magicId = reader.ReadInt(); definition.Magics.Add(magicId); } return(definition); }