示例#1
0
        public HostViewContext()
        {
            RootPath       = GlobalCommon.HostCommon.RootPath;
            RunTimeLibPath = GlobalCommon.HostCommon.RootPath + HostJsConstants.COMPILED_ROOT_PATH;
            CommonLibPath  = GlobalCommon.HostCommon.RootPath;
            var viewdoc = new ViewDocument(_currentjse);

            _hostobject.Add(viewdoc.Name, viewdoc);
            var console = new ConsoleObject();

            _hostobject.Add(console.Name, console);
            var document = new JsDocument(_currentjse, RootPath);

            _hostobject.Add(document.Name, document);

            var loadtag = new LoadParser();
            var reftag  = new RefParser();
            var copytag = new CopyParser();
            var outtag  = new OutTag();
            var hjstag  = new HjsTag();

            //按照先后处理标签的顺序进行标签处理
            _hosttag.Add(loadtag.TagName, loadtag);
            _hosttag.Add(reftag.TagName, reftag);
            _hosttag.Add(copytag.TagName, copytag);
            //out会变为hjs标签
            _hosttag.Add(outtag.TagName, outtag);
            _hosttag.Add(hjstag.TagName, hjstag);
        }
    public void TranslateHTML(BigAl_pl game, string HTML)
    {
#if UNITY_EDITOR
        Logger.Log(HTML);
        System.IO.File.WriteAllText(testHtmlpath, HTML);
        if (openHTML)
        {
            StartCoroutine(ShowHTMLInBrowser());
        }
#endif

        _game             = game;
        inputSender._game = game;

        string HTMLafterActionSetup = HTML.Substring(HTML.IndexOf(actionInputString) + actionInputString.Length);
        int    actionLength         = HTMLafterActionSetup.IndexOf("'");
        string actionstring         = HTML.Substring(HTML.IndexOf(actionInputString) + actionInputString.Length, actionLength);

        string HTMLafterMoveNumSetup = HTML.Substring(HTML.IndexOf(movenumberInputString) + movenumberInputString.Length);
        int    movenumberLength      = HTMLafterMoveNumSetup.IndexOf("'");
        string movenumberstring      = HTML.Substring(HTML.IndexOf(movenumberInputString) + movenumberInputString.Length, movenumberLength);
        int    movenumberint;
        int.TryParse(movenumberstring, out movenumberint);

        document = new JsDocument()
        {
            forms = new JsForm[] { new JsForm()
                                   {
                                       action      = actionstring,
                                       move_number = movenumberint
                                   } }
        };

        UpdateUI(game, HTML);
    }