예제 #1
0
파일: MainScript.cs 프로젝트: meekr/Haima
    void mainMenuChangeHandler(GuiEvent e)
    {
        hidePage();
        hideSubMenu();

        _previousMenuElement = _currentMenuElement;
        if (_currentMenuElement != null){
            StartCoroutine(unloadSubMenuContent(_currentMenuElement));
        }

        XmlNode node = _xmlDoc.DocumentElement.SelectSingleNode("item["+(_mainmMenu.selectedItem.listIndex+1)+"]");
        if (node.Attributes["assetBundle"] != null){
            _currentMenuElement = MenuGenerator.GetMenuElement(node);
        }
        else
            _currentMenuElement = null;

        XmlNodeList nodes = _xmlDoc.DocumentElement.SelectNodes("item["+(_mainmMenu.selectedItem.listIndex+1)+"]/sub");
        if (_mainmMenu.selectedItem != null){
            _mainmMenu.selectedItem.tag = _currentMenuElement;
            if (nodes.Count > 0){
                _subMenu = new SubMenu(nodes);
                Stage.instance.addChildAt(0, _subMenu);
                _subMenu.y	= _mainMenuY;
                _subMenu.addEventListner(GuiEvent.CHANGE, new EventDispatcher.CallBack(subMenuChangeHandler));
                NanoTween.to(_subMenu, 0.3f, NanoTween.Pack("y", _mainMenuY-_subMenuHeight, "ease", Ease.easeOutExpo));

                // populate subMenu content
                StartCoroutine(loadSubMenuContent(_subMenu, _currentMenuElement));
            }
            else if (_currentMenuElement != null){
                _sceneScript.hideScene();

                // populate this menu content
                StartCoroutine(showMenuContent(node, _currentMenuElement));
            }
            else if (node.Attributes["iOSNativeCode"] != null){
                _sceneScript.hideScene();
            }
        }
    }