コード例 #1
0
        /// <summary>
        /// Build the talk scripts
        /// </summary>
        /// <param name="u5Directory">Directory with Ultima 5 data files</param>
        /// <param name="dataRef">DataOVL Reference provides compressed word details</param>
        public TalkScripts(string u5Directory, DataOvlReference dataRef)
        {
            // save the compressed words, we're gonna need them
            this._compressedWordRef = new CompressedWordReference(dataRef);

            // just a lazy array that is easier to enumerate than the enum
            SmallMapReferences.SingleMapReference.SmallMapMasterFiles[] smallMapRefs =
            {
                SmallMapReferences.SingleMapReference.SmallMapMasterFiles.Castle,
                SmallMapReferences.SingleMapReference.SmallMapMasterFiles.Towne,
                SmallMapReferences.SingleMapReference.SmallMapMasterFiles.Keep,
                SmallMapReferences.SingleMapReference.SmallMapMasterFiles.Dwelling
            };

            // for each of the maps we are going to initialize
            foreach (SmallMapReferences.SingleMapReference.SmallMapMasterFiles mapRef in smallMapRefs)
            {
                // initialize the raw component of the talk scripts
                InitializeTalkScriptsRaw(u5Directory, mapRef);

                // initialize and allocate the appropriately sized list of TalkScript(s)
                _talkScriptRefs.Add(mapRef, new Dictionary <int, TalkScript>(_talkRefs[mapRef].Count));

                // for each of the NPCs in the particular map, initialize the individual NPC talk script
                foreach (int key in _talkRefs[mapRef].Keys)
                {
                    _talkScriptRefs[mapRef][key] = InitializeTalkScriptFromRaw(mapRef, key);
                    if (_bIsDebug)
                    {
                        Console.WriteLine(@"TalkScript in " + mapRef.ToString() + @" with #" + key.ToString());
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Decompresses the strings and fills in each compressed word
        /// </summary>
        /// <param name="dataOvlReference"></param>
        private void BuildConversationTable(DataOvlReference dataOvlReference)
        {
            IEnumerable <string>    rawShoppeStrings        = _dataChunks.GetDataChunk(ShoppeKeeperChunkNames.AllData).GetChunkAsStringList().Strs;
            CompressedWordReference compressedWordReference = new CompressedWordReference(dataOvlReference);
            int i = 0;

            foreach (string rawShoppeString in rawShoppeStrings)
            {
                string convertedStr = compressedWordReference.ReplaceRawMerchantStringsWithCompressedWords(rawShoppeString);
                Console.WriteLine((i++) + @"," + @"""" + convertedStr.Replace('\n', '_').Replace('"', '+') + @"""");
                _merchantStrings.Add(convertedStr);
            }
        }