protected override void OnStoryUpdate(ParsedLine line, bool visited)
        {
            if (!line.isParsed)
            {
                this.speakerText.text = "";
                this.messageText.text = line.line;
            }
            else
            {
                string speaker = GetSpeaker(line);
                if (speaker != null)
                {
                    this.speakerText.text = speaker;
                    Sprite portrait = GetCharacterPortrait(speaker);
                    if (portrait != null)
                    {
                    }
                }

                string message = GetMessage(line);
                if (message != null)
                {
                    this.messageText.text = message;
                }
            }
        }
 protected abstract string GetMessage(ParsedLine line);
 //------------------------------------------------------------------------------------------/
 // Abstract
 //------------------------------------------------------------------------------------------/
 protected abstract string GetSpeaker(ParsedLine line);
示例#4
0
 public UpdateLineEvent(ParsedLine parse, bool visited)
 {
     this.parse   = parse;
     this.visited = visited;
 }
        //--------------------------------------------------------------------/
        // Methods
        //--------------------------------------------------------------------/
        /// <summary>
        /// Parses a line of ink dialog, using whatever parses have been set
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public override ParsedLine Parse(string line, List <string> tags)
        {
            Dictionary <string, StratusStoryParse> parses = new Dictionary <string, StratusStoryParse>();

            // Try every parse
            foreach (var category in patterns)
            {
                Regex             r     = new Regex(category.pattern, RegexOptions.IgnoreCase);
                string            value = null;
                StratusStoryParse parse = new StratusStoryParse(category.label);

                // Whether a match has been found
                bool foundMatch = false;
                // Whether to use capturing groups
                bool isGrouped = category.scope == Scope.Group;

                // Check the line
                if (category.target == Target.Line)
                {
                    Dictionary <string, string> groups = new Dictionary <string, string>();
                    if (isGrouped)
                    {
                        foundMatch = MatchGroups(ref groups, r, line);
                    }
                    else
                    {
                        foundMatch = Match(ref value, r, line);
                    }

                    if (foundMatch)
                    {
                        if (isGrouped)
                        {
                            parse.Add(groups);
                        }
                        else
                        {
                            parse.Add(value);
                        }

                        //category.onParse?.Invoke(parse);
                    }
                }

                // Check every tag
                else if (category.target == Target.Tag)
                {
                    // We need to check every tag
                    //Parse parse = new InkModule.Parse(category.label, )
                    foreach (var tag in tags)
                    {
                        Dictionary <string, string> groups = new Dictionary <string, string>();
                        if (isGrouped)
                        {
                            foundMatch = MatchGroups(ref groups, r, tag);
                        }
                        else
                        {
                            foundMatch = Match(ref value, r, tag);
                        }
                        if (foundMatch)
                        {
                            if (isGrouped)
                            {
                                parse.Add(groups);
                            }
                            else
                            {
                                parse.Add(value);
                            }
                        }
                    }
                }

                // If this parse captured anything, let's add it to the parsed line
                if (parse.isValid)
                {
                    category.onParse?.Invoke(parse);
                    parses.Add(parse.label, parse);
                }
            }

            var parsedLine = new ParsedLine(parses, tags, line);

            return(parsedLine);
        }
示例#6
0
 protected abstract void OnStoryUpdate(ParsedLine parse, bool visited);