Exemplo n.º 1
0
    public override void DoInitState()
    {
        base.DoInitState();

        Instance = this;

        if (UIWindowManager.Singleton.GetUIWindow <UIMap>() == null)
        {
            UIWindowManager.Singleton.CreateWindow <UIMainMenu>(UIWindowManager.Anchor.BottomLeft);
            UIWindowManager.Singleton.CreateWindow <UIQuitConfirm>();
            UIWindowManager.Singleton.CreateWindow <UIStageInfo>();
            UIWindowManager.Singleton.CreateWindow <UIMap>();
            UIWindowManager.Singleton.CreateWindow <UINoMoreHearts>();
            UIWindowManager.Singleton.CreateWindow <UIHowToPlay>();
            UIWindowManager.Singleton.CreateWindow <UIWindow>("UILoading", UIWindowManager.Anchor.Center);
            UIWindowManager.Singleton.CreateWindow <UIDialog>(UIWindowManager.Anchor.Bottom);
            UIWindowManager.Singleton.CreateWindow <UIStore>();
            //UIWindowManager.Singleton.CreateWindow<UIWait>();
            UIWindowManager.Singleton.CreateWindow <UIPurchaseNotEnoughMoney>();
            UIWindowManager.Singleton.CreateWindow <UIMessageBox>();
            UIWindowManager.Singleton.GetUIWindow <UIMap>().RefreshButtons();
        }

        if (GlobalVars.UseMusic)
        {
            UIToolkits.PlayMusic(CapsConfig.CurAudioList.MapMusic);
        }

        if (UIWindowManager.Singleton.GetUIWindow <UIMap>().Visible)
        {
            CurFlow = TLoginFlow.LoginFlow_Map;         //切换流程到显示地图
        }
    }
Exemplo n.º 2
0
    public override void OnCreate()
    {
        base.OnCreate();
        m_mainMenuExtend = UIWindowManager.Singleton.CreateWindow <UIWindow>("UIMainMenuExtend", UIWindowManager.Anchor.Left);

        m_quitBtn  = m_mainMenuExtend.GetChildComponent <UIButton>("QuitBtn");
        m_soundBtn = m_mainMenuExtend.GetChildComponent <UIButton>("SoundBtn");
        m_musicBtn = m_mainMenuExtend.GetChildComponent <UIButton>("MusicBtn");

        m_soundIcon = m_mainMenuExtend.GetChildComponent <UISprite>("SoundIcon");
        m_musicIcon = m_mainMenuExtend.GetChildComponent <UISprite>("MusicIcon");

        m_mainMenuBtnText = m_mainMenuExtend.GetChildComponent <UISprite>("QuitBtnText");

        m_mainMenuExtend.AddChildComponentMouseClick("QuitBtn", OnQuitClicked);
        m_mainMenuExtend.AddChildComponentMouseClick("HelpBtn", delegate()
        {
            UIWindowManager.Singleton.GetUIWindow <UIHowToPlay>().ShowWindow();
            m_mainMenuExtend.HideWindow();
        });

        m_mainMenuExtend.AddChildComponentMouseClick("SoundBtn", delegate()
        {
            GlobalVars.UseSFX = !GlobalVars.UseSFX;
            PlayerPrefs.SetInt("SFX", GlobalVars.UseSFX == true ? 1 : 0);
            RefreshIcons();
        });

        m_mainMenuExtend.AddChildComponentMouseClick("MusicBtn", delegate()
        {
            GlobalVars.UseMusic = !GlobalVars.UseMusic;
            PlayerPrefs.SetInt("Music", GlobalVars.UseMusic == true ? 1 : 0);
            if (GlobalVars.UseMusic == false)       //关闭音乐
            {
                UIToolkits.StopMusic();
            }
            else                                    //播放音乐
            {
                if (!UIToolkits.IsPlayingMusic())
                {
                    if (CapsApplication.Singleton.CurStateEnum != StateEnum.Game)
                    {
                        UIToolkits.PlayMusic(CapsConfig.CurAudioList.MapMusic);
                    }
                    else
                    {
                        GameLogic.Singleton.PlayMusic();
                    }
                }
            }
            RefreshIcons();
        });

        m_mainMenuExtend.AddChildComponentMouseClick("MainBtn", HideExtendMainMenu);

        m_mainMenuExtend.AddChildComponentMouseClick("HideBtn", HideExtendMainMenu);



        AddChildComponentMouseClick("MainBtn", delegate()
        {
            m_mainMenuExtend.ShowWindow();
            RefreshIcons();
            if (CapsApplication.Singleton.CurStateEnum != StateEnum.Game && !UIWindowManager.Singleton.GetUIWindow <UIMap>().Visible)        //Login画面
            {
                m_quitBtn.gameObject.SetActive(false);
            }
            else
            {
                m_quitBtn.gameObject.SetActive(true);
            }

            if (CapsApplication.Singleton.CurStateEnum == StateEnum.Game)
            {
                GameLogic.Singleton.PauseGame();
            }

            HideWindow();
        });
    }