예제 #1
0
        public NvcResource(string name, System.IO.Stream stream)
            : base(name, stream)
        {
            // load the Logic aliases
            foreach (Resource.InfoSection section in _sections)
            {
                if (section.Name.Equals("Logic", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Resource.InfoLine line in section.Lines)
                    {
                        _logic.Add(new KeyValuePair <string, string>(line.Attributes[0].Key, line.Attributes[0].Value.Replace("{", "").Replace("}", "")));
                    }
                }
            }

            foreach (Resource.InfoLine line in GlobalSection.Lines)
            {
                NounVerbCase nvc;
                nvc.Noun     = NounUtils.ConvertStringToNoun(line.Value);
                nvc.Verb     = VerbsUtils.ConvertStringToVerbs(line.Attributes[0].Key);
                nvc.Case     = line.Attributes[1].Key;
                nvc.CaseType = CaseUtils.ConvertStringToCase(line.Attributes[1].Key);

                string approach;
                if (line.TryGetAttribute("approach", out approach))
                {
                    if (approach.ToUpper() == "WALKTO")
                    {
                        nvc.Approach = NvcApproachType.WalkTo;
                    }
                    else if (approach.ToUpper() == "TURNTOMODEL")
                    {
                        nvc.Approach = NvcApproachType.TurnToModel;
                    }
                    else
                    {
                        nvc.Approach = NvcApproachType.None;
                    }
                }
                else
                {
                    nvc.Approach = NvcApproachType.None;
                }

                line.TryGetAttribute("target", out nvc.Target);
                line.TryGetAttribute("script", out nvc.Script);

                // remove any { } around the script
                // (normally they wouldn't mess anything up, but there are a few
                // that have no ; at the end, and those will mess up)
                int firstBracket = nvc.Script.IndexOf("{");
                int lastBracket  = nvc.Script.LastIndexOf("}");
                if (firstBracket >= 0 && lastBracket >= 0)
                {
                    nvc.Script = nvc.Script.Substring(firstBracket + 1, lastBracket - firstBracket - 1);
                }
                else if (firstBracket >= 0)
                {
                    nvc.Script = nvc.Script.Substring(firstBracket + 1);
                }
                else if (lastBracket >= 0)
                {
                    nvc.Script = nvc.Script.Substring(0, lastBracket);
                }

                add(nvc);
            }
        }
예제 #2
0
 public static void SetNounVerbCount(string noun, string verb, bool isGabe, int count)
 {
     _nounVerbCounts[new NounVerbCombination(NounUtils.ConvertStringToNoun(noun), VerbsUtils.ConvertStringToVerbs(verb), isGabe)] = count;
 }
예제 #3
0
 public static int GetTopicCount(string noun, string verb)
 {
     return(GetTopicCount(NounUtils.ConvertStringToNoun(noun), VerbsUtils.ConvertStringToVerbs(verb)));
 }
예제 #4
0
 public static int GetNounVerbCount(string noun, Verbs verb)
 {
     return(GetNounVerbCount(NounUtils.ConvertStringToNoun(noun),
                             verb, CurrentEgo == Ego.Gabriel));
 }