Esempio n. 1
0
        public GwentClientService(HubConnection hubConnection, GlobalUIService globalUIService, ITranslator translator)
        {
            _translator      = translator;
            _globalUIService = globalUIService;
            /*待修改*/
            (sender, receiver) = Tube.CreateSimplex();
            /*待修改*/
            hubConnection.On <bool>("MatchResult", async x =>
            {
                await sender.SendAsync <bool>(x);
            });
            hubConnection.On("RepeatLogin", async() =>
            {
                SceneManager.LoadScene("LoginScene");
                await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox(_translator.GetText("logged_out_title"), _translator.GetText("logged_out"));
            });
            hubConnection.Closed += (async x =>
            {
                SceneManager.LoadScene("LoginScene");
                await _globalUIService.YNMessageBox(_translator.GetText("disconnected_title"),
                                                    _translator.GetText("disconnected").Replace("\\n", "\n"),
                                                    "ok_button", isOnlyYes: true);

                // LayoutRebuilder.ForceRebuildLayoutImmediate(Context);
                // var messageBox = GameObject.Find("GlobalUI").transform.Find("MessageBoxBg").gameObject.GetComponent<MessageBox>();//.Show("断开连接", "请尝试重新登陆\n注意! 在目前版本中,如果处于对局或匹配时断线,需要重新启动客户端,否则下次游戏开始时会异常卡死。\nNote!\nIn the current version, if you are disconnected when matching or Playing, you need to restart the client, otherwise the next game will start with an abnormal.".Replace("\\n", "\n"), isOnlyYes: true);
                // messageBox.Buttons.SetActive(true);
                // messageBox.YesButton.SetActive(true);
                // messageBox.NoButton.SetActive(false);
                // messageBox.TitleText.text = "断开连接";
                // messageBox.MessageText.text = "请尝试重新登陆\n注意! 在目前版本中,如果处于对局或匹配时断线,需要重新启动客户端,否则下次游戏开始时会异常卡死。\nNote!\nIn the current version, if you are disconnected when matching or Playing, you need to restart the client, otherwise the next game will start with an abnormal.".Replace("\\n", "\n");
                // messageBox.YesText.text = "确定";
                // messageBox.gameObject.SetActive(true);
                // await messageBox.receiver.ReceiveAsync<bool>();
                // LayoutRebuilder.ForceRebuildLayoutImmediate(messageBox.Context);
            });
            hubConnection.On("ExitGame", () =>
            {
                Application.Quit();
            });
            hubConnection.On <string, string, string, string, bool>("ShowMessageBox", (string title, string message, string yes, string no, bool isyes) =>
            {
                _globalUIService.YNMessageBox(title, message, yes, no, isyes);
            });
            hubConnection.On <string, string>("Wait", (string title, string message) =>
            {
                _globalUIService.Wait(title, message);
            });
            hubConnection.On("Close", () =>
            {
                _globalUIService.Close();
            });
            hubConnection.On <string>("Test", message => Debug.Log($"收到了服务端来自Debug的信息:{message}"));
            Player        = new LocalPlayer(hubConnection);
            HubConnection = hubConnection;
            hubConnection.StartAsync();
        }
 //--------------------------------
 public GwentClientGameService(GameCodeService codeService, GlobalUIService globalUIService)
 {
     _id             = DateTime.UtcNow.Ticks;
     GameCodeService = codeService;
     GlobalUIService = globalUIService;
 }