Exemplo n.º 1
0
 void CreateAndSendTagToEngine(TagInfo tagInfo)
 {
     AbstractTag tag = TagFactory.Create(tagInfo, _currentPhraseLineNo);
     if (tag != null)
     {
        // ScriptEngine.Instance.AddCommand(tag);
        //_uploadTags.Add(tag);
         _scenario.AddCommand(tag);
     }
     else
         Debug.LogFormat("Tag:{0} is not implemented!", tagInfo.TagName);
 }
Exemplo n.º 2
0
        public static AbstractTag CreateEmptyParamsTag(string className, int lineNo)
        {
            string cn = "Sov.AVGPart" + "." + className.ToString();
            Type type = Type.GetType(cn);
            AbstractTag tag = null;
            try
            {
                tag = (AbstractTag)Activator.CreateInstance(type);
            }
            catch (Exception e)
            {
                //Debug.Log(e.ToString());
            }

            if (tag != null)
            {
                TagInfo i = new TagInfo("");
                tag.Init(i, lineNo);

                tag.CheckVital();

            }
            return tag;
        }
Exemplo n.º 3
0
        public static AbstractTag Create(TagInfo info, int lineNo)
        {
            /*
             * tagName: 全小写  e.g. settext
             * ClassName 首字母大写 e.g. SettextTag
             */
            StringBuilder className = new StringBuilder(info.TagName);
            className[0] = Char.ToUpper(className[0]);
            className.Append("Tag");
            //className.Append("Sov.AVGPart" + ".", 0);
            string cn = "Sov.AVGPart" + "." + className.ToString();
            Type type = Type.GetType(cn);

            AbstractTag tag = null;
            try
            {
                tag = (AbstractTag)Activator.CreateInstance(type);
            }

            catch (Exception e)
            {
                //Debug.Log(e.ToString());
            }

            if (tag != null)
            {
                tag.Init(info, lineNo);

                tag.CheckVital();

            }
            return tag;
        }
Exemplo n.º 4
0
        public void Init(TagInfo info, int lineNo)
        {
            _tagInfo = info;
            LineInScript = lineNo;

            //set default value
            Params = new Dictionary<string, string>(_defaultParamSet);

            //set script value
            foreach (KeyValuePair<string, string> i in info.Params)
            {
                Params[i.Key] =  i.Value;
            }
        }
Exemplo n.º 5
0
        void PhraseALine(KAGWords line)
        {
            KAGWord op = line[0];
            if (op.WordType == KAGWord.Type.TEXT)
            {
                PhraseText(line);

            }
            else if(op.WordType == KAGWord.Type.NAME)
            {
                PhraseName(line);
            }
            else
            {
                TagInfo tagInfo = new TagInfo(op.Value.ToLower());
                foreach (KAGWord param in line)
                {
                    if (op != param)
                    {
                        tagInfo.Params[param.Name] = param.Value;
                    }
                }
                CreateAndSendTagToEngine(tagInfo);
            }
        }
Exemplo n.º 6
0
        /*
        void PhraseScenario(KAGWords line)
        {

            OpCommand command = new OpCommand(Opcode.SCENARIO);

            foreach (KAGWord word in line)
            {
                string name = word.Name;
                if (name == "scenario")
                {
                    command.Params["scenario"] = word.Value;
                }
            }

            ScriptEngine.Instance.AddCommand(command);
        }

        void PhraseScenario(KAGWords line)
        {
            TagInfo tagInfo = new TagInfo("scenario");
            foreach (KAGWord param in line)
            {
                tagInfo.Params[param.Name] = param.Value;
            }
            ScriptEngine.Instance.AddCommand(TagFactory.Create(tagInfo));
        }*/
        void PhraseText(KAGWords line)
        {
            TagInfo tagInfo = new TagInfo("print");

            foreach (KAGWord word in line)
            {
                string name = word.Name;
                if (name == "text")
                {
                    tagInfo.Params["text"] = word.Value;
                    CreateAndSendTagToEngine(tagInfo);
                }
                else if (name == "op")
                {
                    TagInfo tagInfo1 = new TagInfo(word.Value.ToLower());
                    CreateAndSendTagToEngine(tagInfo1);
                }
            }
        }
Exemplo n.º 7
0
        void PhraseName(KAGWords line)
        {
            TagInfo tagInfo = new TagInfo("setname");

            foreach (KAGWord word in line)
            {
                string name = word.Name;
                if (name == "text")
                {
                    tagInfo.Params["text"] = word.Value;
                    CreateAndSendTagToEngine(tagInfo);
                }
            }
        }