public void GeneratePhrase(object data)
        {
            TemplateCluster cluster = data as TemplateCluster;

            generatedPhrase = cluster.Populate(_seed, true);
            IsDone          = true;
        }
예제 #2
0
        /// <summary>
        /// Generates a phrase from a template synchroniously. Use of this method is discouraged as it will cause the game to wait for it to finish and, depending on the length of the template,
        /// this can cause a noticable pause. Instead, use GeneratePhraseAsync if possible.
        /// </summary>
        /// <param name="template">The string value of the phrase template the new phrase will be generated from.</param>
        /// <param name="seed">(Optional) A seed to use in generation. If no seed is passed, a new one will be generated based on system time.</param>
        /// <returns>The newly generated phrase</returns>
        public string GeneratePhraseFromTemplateString(string template, int?seed = null)
        {
            TemplateCluster cluster = TemplateParser.ParseTemplate(template);
            int             _seed   = seed.HasValue ? seed.Value : System.Environment.TickCount;
            string          phrase  = cluster.Populate(_seed, true);

            return(phrase);
        }