Beispiel #1
0
 public Talk Clone()
 {
     return(new Talk {
         castName = (string)castName.Clone(),
         param = TalkParam.Clone(param),
         text = (string)text.Clone(),
     });
 }
Beispiel #2
0
        public static List <Talk> TextFileToTalks(string path)
        {
            List <Talk> talks = null;

            using (var fin = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                talks = new List <Talk>();
                var rxName      = new Regex(@"^\[(.+?)\]");
                var rxEmptyLine = new Regex(@"^\s*$");

                var   castName  = "";
                var   baseParam = new List <TalkParam>();
                float baseWait  = 0.0f;

                var    sr = new StreamReader(fin);
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var matcheName = rxName.Match(line);
                    if (matcheName.Success)
                    {
                        castName = matcheName.Groups[1].Value;

                        var cast = RemoteTalkProvider.FindCast(castName);
                        if (cast != null)
                        {
                            baseParam = TalkParam.Clone(cast.paramInfo).ToList();
                        }
                        else
                        {
                            baseParam.Clear();
                        }
                        TalkParam.Merge(baseParam, ExtractTalkParams(ref line, ref baseWait));
                    }
                    else if (!rxEmptyLine.IsMatch(line))
                    {
                        var   param = TalkParam.Clone(baseParam);
                        float wait  = -1.0f;
                        TalkParam.Merge(param, ExtractTalkParams(ref line, ref wait, true));
                        if (wait < 0.0f)
                        {
                            wait = baseWait;
                        }

                        var talk = new Talk();
                        talk.castName = castName;
                        talk.param    = param.ToArray();
                        talk.wait     = wait;
                        talk.text     = line;
                        talks.Add(talk);
                    }
                }
            }
            return(talks);
        }
Beispiel #3
0
        public bool ValidateParams()
        {
            var c = cast;

            if (c != null)
            {
                var prev = param;
                param = TalkParam.Clone(c.paramInfo);
                TalkParam.Merge(param, prev);
                return(true);
            }
            return(false);
        }