Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="TranslatablePhrase"/> class.
        /// </summary>
        /// <param name="originalPhrase">The original phrase. (Possibly a user-added phrase, in
        /// which case it will be a GUID, prefaced by Question.kGuidPrefix) </param>
        /// <param name="modifiedPhrase">The modified phrase.</param>
        /// ------------------------------------------------------------------------------------
        public TranslatablePhrase(string originalPhrase, string modifiedPhrase)
        {
            OriginalPhrase = originalPhrase.Normalize(NormalizationForm.FormC);
            if (!IsNullOrEmpty(modifiedPhrase))
            {
                m_sModifiedPhrase = modifiedPhrase.Normalize(NormalizationForm.FormC);
            }
            if (!IsNullOrEmpty(OriginalPhrase))
            {
                switch (PhraseInUse[PhraseInUse.Length - 1])
                {
                case '?': m_type = TypeOfPhrase.Question; break;

                case '.': m_type = TypeOfPhrase.StatementOrImperative; break;

                default: m_type = TypeOfPhrase.Unknown; break;
                }
                if (m_type == TypeOfPhrase.Unknown && OriginalPhrase.StartsWith(Question.kGuidPrefix))
                {
                    OriginalPhrase = Empty;
                    m_type         = TypeOfPhrase.NoEnglishVersion;
                }
            }
        }
Example #2
0
        public override void Execute()
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(OriginalPhrase));

            PrintedPhrase = OriginalPhrase.Trim(new char[] { ' ', '"', '\'' }).FirstCharToUpper();

            if (PrintedPhrase.Length == 0 || !Char.IsPunctuation(PrintedPhrase[PrintedPhrase.Length - 1]))
            {
                PrintedPhrase += ".";
            }

            ProcessedPhrase = PrintedPhrase.Trim(new char[] { '.', '?', '!' }).ToLower();

            ProcessEvents(EventType.BeforePrintSayText);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            gOut.Print("Okay, \"{0}\"", PrintedPhrase);

            ProcessEvents(EventType.AfterPrintSayText);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }