Ejemplo n.º 1
0
        public static DialogueObject CreateDialogueFactory(int dialogueLength, string data, TokenType type)
        {
            DialogueObject dialogueObject = new DialogueObject(dialogueLength);
            AToken         previousToken  = null;

            string[] words;
            if (type != TokenType.ANSWER &&
                type != TokenType.FIELD)
            {
                words = data.Split(' ');
            }
            else
            {
                words = new string[] { data };
            }

            foreach (string word in words)
            {
                AToken tokenObject = null;
                switch (type)
                {
                case TokenType.NORMAL:
                    tokenObject = new NormalToken(previousToken, word + " ");
                    break;

                case TokenType.SANCTUARY:
                    tokenObject = new SanctuaryToken(previousToken, word + " ");
                    break;

                case TokenType.ANSWER:
                    tokenObject = new AnswerToken(previousToken, word);
                    break;

                case TokenType.HEADER:
                    tokenObject = new HeaderToken(previousToken, word + " ");
                    break;

                case TokenType.FIELD:
                    tokenObject = new FieldToken(previousToken, word);
                    break;
                }

                if (previousToken != null)
                {
                    previousToken.NextToken = tokenObject;
                }

                dialogueObject.AddToken(tokenObject);

                previousToken = tokenObject;
            }

            return(dialogueObject);
        }
Ejemplo n.º 2
0
        public static DialogueObject CreateDialogueFactory(int dialogueLength, Dialogue data)
        {
            DialogueObject dialogueObject = new DialogueObject(dialogueLength);

            AToken        previousToken     = null;
            DialogueToken previousDataToken = null;

            foreach (DialogueToken token in data.DialoguesToken)
            {
                string[] words;
                if (token.Type != TokenType.ANSWER &&
                    token.Type != TokenType.FIELD)
                {
                    words = token.Token.Split(' ');
                }
                else
                {
                    words = new string[] { token.Token };
                }

                foreach (string word in words)
                {
                    AToken tokenObject = null;
                    switch (token.Type)
                    {
                    case TokenType.NORMAL:
                        if (previousDataToken != null && (previousDataToken.Type == TokenType.FIELD || previousDataToken.Type == TokenType.ANSWER))
                        {
                            tokenObject = new NormalToken(previousToken, " " + word + " ");
                        }
                        else
                        {
                            tokenObject = new NormalToken(previousToken, word + " ");
                        }
                        break;

                    case TokenType.SANCTUARY:
                        tokenObject = new SanctuaryToken(previousToken, word + " ");
                        break;

                    case TokenType.ANSWER:
                        tokenObject = new AnswerToken(previousToken, word);
                        break;

                    case TokenType.HEADER:
                        tokenObject = new HeaderToken(previousToken, word);
                        break;

                    case TokenType.FIELD:
                        tokenObject = new FieldToken(previousToken, word);
                        break;
                    }

                    if (previousToken != null)
                    {
                        previousToken.NextToken = tokenObject;
                    }

                    dialogueObject.AddToken(tokenObject);

                    previousToken     = tokenObject;
                    previousDataToken = token;
                }
            }

            return(dialogueObject);
        }