Пример #1
0
    private void ConnectToGameserver()
    {
        if (state == eTitleState.idle)
        {
            Network.Instance.Init();
            state = eTitleState.init;
        }

        if (state == eTitleState.init)
        {
            Network.Instance.StartConnect();
            state = eTitleState.connecting;
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case eTitleState.idle:                                           //空闲的状态
        case eTitleState.init:                                           //初始化的状态
            m_LabelTouchToStart.text = Localization.Get("TouchToStart"); //初始化点击提示的文本
            if (Network.ConnectState == eConnectState.connecting || Network.ConnectState == eConnectState.connected)
            {
                state = eTitleState.connecting;                         //状态改为正在连接
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Popup.PopupInfo popup = Popup.Instance.GetCurrentPopup();
                if (popup == null)
                {
                    Popup.Instance.ShowConfirmKey(new PopupConfirm.Callback(OnExit), "ConfirmQuit");
                }
            }
            break;

        case eTitleState.connecting:
            m_LabelTouchToStart.text = Localization.Get("ConnectingToGameServer");

            if (Network.ConnectState == eConnectState.connected)
            {
                state = eTitleState.connected;
            }
            else if (Network.ConnectState == eConnectState.idle)
            {
                state = eTitleState.init;
                m_LabelTouchToStart.text = Localization.Get("TouchToStart");
                return;
            }

            break;

        case eTitleState.connected:
            Network.ShowIndicator();
            UnityEngine.SceneManagement.SceneManager.LoadScene("Main", UnityEngine.SceneManagement.LoadSceneMode.Single);                     //跳转到main场景
            //state = eTitleState.touchToStart;
            break;
        }
    }