Exemple #1
0
        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;
            }
        }
Exemple #2
0
        /// <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);
        }