Ejemplo n.º 1
0
    public override void Init()
    {
        _viewProvider.Get <MenuView>(view =>
        {
            _menuView = view;

            MenuRenderData renderData = new MenuRenderData();
            renderData.StartGame      = OnStartGame;
            renderData.HighScore      = _serviceProvider.Get <MenuService>().GetHighScore();

            _menuView.Init(renderData);
            _menuView.gameObject.SetActive(true);
        });
    }
Ejemplo n.º 2
0
 public void Init(MenuRenderData renderData)
 {
     _renderData = renderData;
     _startButton.onClick.AddListener(OnStartGame);
     _highScoresText.text = string.Format("HighScore: {0}", renderData.HighScore);
 }
Ejemplo n.º 3
0
        public static MenuRenderData ParseRenderTemplate(string template)
        {
            if (!string.IsNullOrEmpty(template))
            {
                MenuRenderData result = new MenuRenderData();

                int activeindex = template.IndexOf("{activeclass:");
                if (activeindex >= 0)
                {
                    var endindex = template.IndexOf("}", activeindex);
                    if (endindex > 0)
                    {
                        var activeclass = template.Substring(activeindex, endindex - activeindex);
                        activeclass           = activeclass.Replace("{activeclass:", "");
                        result.HasActiveClass = true;
                        result.ActiveClass    = activeclass;
                    }

                    if (template.IndexOf(" class", StringComparison.OrdinalIgnoreCase) != -1)
                    {
                        // find the right place to insert
                        int index         = template.IndexOf(" class", StringComparison.OrdinalIgnoreCase);
                        int nextequalmark = template.IndexOf("=", index);
                        if (index > -1 && nextequalmark > -1)
                        {
                            string newtemplate    = template.Substring(0, activeindex) + template.Substring(endindex + 1);
                            var    insertposition = MenuHelper.FindClassInsertPosition(newtemplate);

                            if (insertposition > -1)
                            {
                                template = newtemplate.Substring(0, insertposition) + MenuHelper.MarkActiveClassReplacer + " " + newtemplate.Substring(insertposition);
                            }
                            else
                            {
                                template = template.Substring(0, activeindex) + "class='" + MenuHelper.MarkActiveClassReplacer + "'" + template.Substring(endindex + 1);
                            }
                        }
                        else
                        {
                            template = template.Substring(0, activeindex) + "class='" + MenuHelper.MarkActiveClassReplacer + "'" + template.Substring(endindex + 1);
                        }
                    }
                    else
                    {
                        template = template.Substring(0, activeindex) + "class='" + MenuHelper.MarkActiveClassReplacer + "'" + template.Substring(endindex + 1);
                    }
                }

                result.FineTemplate = template;

                if (template.IndexOf(MenuHelper.MarkParentId) > -1 || template.IndexOf(MenuHelper.MarkCurrentId) > -1)
                {
                    result.RenderId = true;
                }

                return(result);
            }
            else
            {
                return(new MenuRenderData()
                {
                    FineTemplate = template
                });
            }
        }