private void InitData() { //初始化自己的信息 UserVO myVo = new UserVO() { userID = GamePrefs.GetUserId(), headId = UserDataHelper.UserInfo.HeadId, sex = UserDataHelper.UserInfo.Gender, gold = UserDataHelper.UserInfo.Gold, nickName = UserDataHelper.UserInfo.Nickname, seatID = 0 }; DataCenterComponent.Instance.userInfo.httpUserInfo = myVo; DataCenterComponent.Instance.userInfo.addUser(myVo); //播放背景音乐 SoundComponent.Instance.Stop(DataCenterComponent.Instance.soundInfo.bg_hall); var _soundVolume = PlayerPrefs.GetFloat("SoundVolume", 1); this.CurrentSoundName = DataCenterComponent.Instance.soundInfo.ddzbg + UnityEngine.Random.Range(1, 3); SoundComponent.Instance.PlayMusic(this.CurrentSoundName, 0, _soundVolume, true); }
/// <summary> /// 点击获取邮件 /// </summary> private async void GetMail() { Title01.SetActive(false); Title02.SetActive(true); RecyleRecordItem(); //请求公告信息数据 var resp = (G2C_MailReturn_Res)await SessionComponent.Instance.Session.Call( new C2G_MailAsk_Req() { UserId = GamePrefs.GetUserId() }); if (resp.Error == 0) { NoMsgTips.SetActive(resp.Info.count == 0); for (int i = 0; i < resp.Info.Count; i++) { CreateRecordListsItem(null, resp.Info[i], 2); } } else { Game.PopupComponent.ShowTips(resp.Message); return; } }
private async void OnDDZ_LevelButton() { try { Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.EnterSubGameTip); var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_JionRoom_Req() { AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, GameId = DDZGameHelper.CurrentGameInfo.GameId, UserId = GamePrefs.GetUserId(), }); Game.PopupComponent.CloseLoadingLockUI(); if (response.Error != 0) { Game.PopupComponent.ShowMessageBox(response.Message); return; } DDZGameHelper.RoomId = response.RoomId; GameLobbyFactory.Remove(); DDZUIFactory.gameScene.Create(); } catch (Exception e) { Game.PopupComponent.ShowMessageBox(e.Message); throw; } }
/// <summary> /// 请求准备 /// </summary> public async void RequestPrepare(bool _IsPrepare = true) { var resp = (G2C_DDZPrepare_Res)await SessionComponent.Instance.Session.Call( new C2G_DDZPrepare_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId, IsPrepare = _IsPrepare }); if (resp.Error != 0) { Game.PopupComponent.ShowMessageBox(resp.Message); return; } //将准备面板销毁 this.DDZReadyPlugin.Reset(); //将准备标识显示出来 this.DDZReadyPlugin.SetReadyByIndex(0, true); }
/// <summary> /// 请求出牌 /// </summary> /// <param name="_PlayCardStatue">出牌状态 0-出牌 1-要不起</param> /// <param name="_PlayCard">要出的牌数组</param> public async void RequestPlayCard(int _PlayCardStatue, DDZCard _PlayCard) { var resp = (G2C_DDZPlayCard_Res)await SessionComponent.Instance.Session.Call( new C2G_DDZPlayCard_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId, PlayCardStatue = _PlayCardStatue, PlayCard = _PlayCard }); //由于服务器修正了,这里还是走DDZOutCardError事件 if (resp.Error != 0 && resp.Error != 200225) { Game.PopupComponent.ShowMessageBox(resp.Message); this.DDZHandCardPlugin.ReSelect(); return; } if (resp.Error == 200225) { return; } //隐藏掉交互界面 this.DDZInteractivePlugin.Hide(); //刷新最新的手牌 if (resp.Card != null) { DDZGameConfigComponent.Instance.myHandCard = resp.Card; //修改:用服务器返回的数据刷新 //this.DDZHandCardPlugin.ShowHandCard(resp.Card); } //根据出的牌,将牌隐藏掉,如果是不出,则不移。 if (_PlayCardStatue != 1) { this.DDZHandCardPlugin.RemoveCard2();//临时 } else { this.DDZHandCardPlugin.ReSelect(); } //刷新倍数 DDZGameConfigComponent.Instance.Times = resp.Times; this.DDZTopPlugin.SetBeiSu(); //播放语音 this.PlayOutCardSound(resp.PlayCard); }
/// <summary> /// 修改密码 /// </summary> private async void OnChangePwd() { ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click); if (_isRequest) { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.ModifyPasswordNotRepeatTip); return; } OnEndEditOldPwdInputField(_oldPwdInput.text); OnEndEditNewPwdInputField(_newPwdInput.text); OnEndEditConfirmPwdInputField(_confirmPwdInput.text); if (!_oldPwdVertify || !_newPwdVertify || !_confirmPwdVertify) { return; } try { Game.PopupComponent.ShowLoadingLockUI(); _isRequest = true; var response = (G2C_ResetPassword_Res)await SessionComponent.Instance.Session.Call( new C2G_ResetPassword_Req() { UserId = GamePrefs.GetUserId(), OldPassword = _oldPwdInput.text, NewPassword = _newPwdInput.text }); if (response.Error != 0) { Game.PopupComponent.ShowMessageBox(response.Message); _isRequest = false; Game.PopupComponent.CloseLoadingLockUI(); return; } GamePrefs.SetUserPwd(_confirmPwdInput.text); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordSuccTip); OnCloseMask(); Game.PopupComponent.CloseLoadingLockUI(); } catch (Exception e) { Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordFailTip); Debug.LogError("修改密码失败: " + e.Message); Game.PopupComponent.CloseLoadingLockUI(); throw; } finally { _isRequest = false; } }
/// <summary> /// 请求叫地主 /// </summary> /// <param name="_Score">叫分 0-不抢</param> public async void RequestAskScore(int _Score = 0) { var resp = (G2C_DDZAskScore_Res)await SessionComponent.Instance.Session.Call( new C2G_DDZAskScore_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId, Score = _Score }); if (resp.Error != 0) { Game.PopupComponent.ShowMessageBox(resp.Message); return; } //流局 if (resp.NextChairId == -1) { Log.Debug("当前是流局啦!!!!"); this.DDZCallScorePlugin.Hide(); DDZGameConfigComponent.Instance.ActiveChairId = -1; this.DDZOpTipPlugin.Reset(); return; } //显示叫了几分 int realSeatID = DDZGameHelper.ChangeSeat(resp.ChairId); this.DDZOpTipPlugin.CallScoreById(realSeatID, _Score); //把叫分面板隐藏掉 this.DDZCallScorePlugin.Hide(); //如果下一个玩家的操作是出牌 if (resp.DoType < 2) { //下一个玩家操作 int nextSeatID = DDZGameHelper.ChangeSeat(resp.NextChairId); //高亮显示头像 DDZGameConfigComponent.Instance.ActiveChairId = resp.NextChairId; Log.Debug("玩家" + nextSeatID + "操作!!"); } //播放音效 SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_Call_prefix + _Score); }
/// <summary> /// 请求换桌 /// </summary> public async void RequestChangeRoom() { G2C_ChangerRoom_Res response = (G2C_ChangerRoom_Res)await SessionComponent.Instance.Session.Call(new C2G_ChangerRoom_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId, RoomId = DDZGameHelper.RoomId, UserId = GamePrefs.GetUserId() }); if (response.Error == 0) { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.ChangeTableTip); //手动退出房间 this._BackHall = false; this.QuitGame(); try { var respons = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_JionRoom_Req() { AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId, GameId = DDZGameHelper.CurrentGameInfo.GameId, UserId = GamePrefs.GetUserId(), RoomId = response.RoomId }); if (respons.Error != 0) { Game.PopupComponent.ShowMessageBox(respons.Message); return; } DDZGameHelper.RoomId = respons.RoomId; DDZUIFactory.gameScene.Create(); } catch (Exception e) { Game.PopupComponent.ShowMessageBox(e.Message); throw; } } }
/// <summary> /// 确认切换头像 /// </summary> private async void OnConfirmChangeHead() { ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click); if (ChangeHeadIndex == UserDataHelper.UserInfo.HeadId) { ChangeHeadView.SetActive(false); NormalInfoView.SetActive(true); return; } if (_isRequest) { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NotRepeatModifyTip); return; } _isRequest = true; try { G2C_ChangerUserInfo_Res chagerHead = (G2C_ChangerUserInfo_Res)await SessionComponent.Instance.Session. Call(new C2G_ChangerUserInfo_Req() { UserId = GamePrefs.GetUserId(), Type = 0, HeadId = ChangeHeadIndex }); if (chagerHead.Error != 0) { Debug.Log(chagerHead.Message); // GameHelper.ShowMessageBox(chagerHead.Message); Game.PopupComponent.ShowMessageBox(chagerHead.Message); _isRequest = false; return; } ChangeHeadView.SetActive(false); NormalInfoView.SetActive(true); _isRequest = false; } catch (Exception e) { Log.Debug("修改头像错误:" + e.Message); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyHeadIdFailTip); _isRequest = false; } // GameHelper.ShowMessageBox("修改头像成功!"); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyHeadIdSuccTip); // 刷新显示 await UserDataHelper.GetUserInfo(true); }
/// <summary> /// Resume 事件处理 /// </summary> public async void OnApplicationResume() { Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.ResumeSceneTip); await Task.Delay(DataCenterComponent.Instance.gameInfo.ApplicationResumeWaitTime); GameHelper.ApplicationIsPause = false; var uiC = Game.Scene.GetComponent <UIComponent>(); if (uiC.Get(UIType.UIMessageBoxPanel) != null) { Log.Info("存在断线重联界面,不走Resume逻辑!!"); Game.PopupComponent.CloseLoadingLockUI(); return; } //销毁当前界面,但不重新创建大厅,否则相关数据会被清掉 this._BackHall = false; this.QuitGame(); Game.PopupComponent.CloseLoadingLockUI(); try { var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_JionRoom_Req() { AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, GameId = DDZGameHelper.CurrentGameInfo.GameId, UserId = GamePrefs.GetUserId(), }); if (response.Error != 0) { Game.PopupComponent.ShowMessageBox(response.Message); return; } DDZGameHelper.RoomId = response.RoomId; DDZUIFactory.gameScene.Create(); } catch (Exception e) { Game.PopupComponent.ShowMessageBox(e.Message); throw; } }
/// <summary> /// 通用加入房间方法 /// </summary> /// <param name="areaIndex"></param> public async void RequestJoinRoom(int areaIndex) { ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click); var index = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId].Count; if (index > areaIndex) { index = areaIndex; } else { index -= 1; } try { Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.EnterSubGameTip); var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_JionRoom_Req() { AreaId = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId][index].AreaId, GameId = GameHelper.CurrentGameInfo.GameId, UserId = GamePrefs.GetUserId(), }); Game.PopupComponent.CloseLoadingLockUI(); if (response.Error != 0) { Game.PopupComponent.ShowMessageBox(response.Message); return; } GameHelper.CurrentAreaInfo = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId][index]; GameHelper.CurrentRoomId = response.RoomId; GameHelper.CurrentFieldId = index; this.EnterSubGame(); Game.EventSystem.Run(EventIdType.RemoveGameLobby); } catch (Exception e) { Debug.LogError(e.Message); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.JoinRoomFailTip); } }
/// <summary> /// 内部获取用户信息 /// </summary> /// <returns></returns> private static async ETTask <bool> INTERNAL_GET_USERINFO() { Game.PopupComponent.ShowLoadingLockUI(); try { var getUserInfoRes = (G2C_GetUserInfo_Res)await SessionComponent.Instance.Session.Call (new C2G_GetUserInfo_Req() { UserId = GamePrefs.GetUserId() }); if (getUserInfoRes.Error != 0) { Debug.LogError(getUserInfoRes.Message); // GameHelper.ShowMessageBox(getUserInfoRes.Message); Game.PopupComponent.ShowMessageBox(getUserInfoRes.Message); Game.PopupComponent.CloseLoadingLockUI(); return(false); } // 获取用户信息成功 UserInfo = getUserInfoRes.UserInfo; // 设置我的数据 SetMyDataCenter(); // 通知所有引用 for (var i = _dependViews.Count - 1; i >= 0; i--) { if (_dependViews[i].HeadImg == null || _dependViews[i].NickNameText == null || _dependViews[i].GoldText == null) { _dependViews.RemoveAt(i); continue; } INTERNAL_SET_USERINFOVIEW(_dependViews[i], UserInfo); } Game.PopupComponent.CloseLoadingLockUI(); return(true); } catch (Exception exception) { Console.WriteLine(exception); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GetPlayerInfoFailTip); Game.PopupComponent.CloseLoadingLockUI(); throw; } }
/// <summary> /// 战绩请求用例 /// </summary> /// <returns></returns> private async Task StressTest_MyRecordReq() { var resp = (G2C_MyRecord_Res)await SessionComponent.Instance.Session.Call ( new C2G_MyRecord_Req() { UserId = GamePrefs.GetUserId(), }); if (resp.Error == 0) { Log.Debug("获取战绩成功=>数量:" + resp.Recordlist.Count); } else { Log.Debug("获取战绩失败" + resp.Message); } }
public async void Start() { RecyleRecordItem(); //请求战绩数据 var resp = (G2C_MyRecord_Res)await SessionComponent.Instance.Session.Call ( new C2G_MyRecord_Req() { UserId = GamePrefs.GetUserId(), }); if (resp.Error == 0) { _RecordViewTipsText.SetActive(resp.Recordlist.Count == 0); for (int i = 0; i < resp.Recordlist.Count; i++) { CreateRecordListsItem(resp.Recordlist[i], i); } } }
public async void ShowMessageBox() { if (this.backData == null) { return; } //增加:先向服务器验证,如果通过再弹窗口 var response = (G2C_IsBoltback_Res)await SessionComponent.Instance.Session.Call( new C2G_IsBoltback_Req() { AreaId = this.backData.AreaId, GameId = this.backData.GameId, UserId = GamePrefs.GetUserId(), RoomId = this.backData.RoomId }); if (!response.IsBoltback) { Log.Debug("服务器验证失败,不弹重回窗口!!"); return; } MessageData messData = new MessageData(); messData.onlyOk = false; messData.ok = OkAction; messData.cancel = NoAction; messData.titleStr = DataCenterComponent.Instance.tipInfo.Tips; messData.mes = DataCenterComponent.Instance.tipInfo.HasGameRebackTip; messData.okStr = DataCenterComponent.Instance.tipInfo.OkStrTip; Game.PopupComponent.ShowMessageBox(messData.mes, messData); }
/// <summary> /// 离开游戏 /// </summary> private async void QuitGame() { var resp = (G2C_QuitRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_QuitRoom_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId }); if (resp.Error == 0) { this.FastQuitGame(); } else { Game.PopupComponent.ShowTips(resp.Message); } }
public async void Init() { DDZGameHelper.IsGetRoomDetails = false; DDZGameHelper.IsJoinRoom = true; Game.PopupComponent.ShowNoticeUI(DataCenterComponent.Instance.MarqueeInfo.SubGameDefault); //进入存储重回数据 this.SaveReBackData(); //请求房间详情 var resp = (G2C_GetRoomInfo_Res)await SessionComponent.Instance.Session.Call( new C2G_GetRoomInfo_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId }); On_G2C_GetRoomInfo_Res(resp); }
/// <summary> /// 重新加入房间 /// </summary> /// <param name="GameId"></param> /// <param name="AreaId"></param> /// <param name="RoomId"></param> private async void RequestJoinRoom(int GameId, int AreaId, int RoomId = 0, int Index = 0) { try { var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call( new C2G_JionRoom_Req() { AreaId = AreaId, GameId = GameId, UserId = GamePrefs.GetUserId(), RoomId = RoomId }); //去掉小菊花,并清掉缓存 Game.PopupComponent.CloseLoadingLockUI(); if (response.Error != 0) { Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GameRebackErrorTip); this.ClearReBackData(); return; } //将子游戏重回处理,分发到各子游戏模块 Game.EventSystem.Run(EventIdType.HandleSubGameReBack, GameId, response.RoomId, backData); } catch (Exception e) { Game.PopupComponent.CloseLoadingLockUI(); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GameRebackErrorTip); throw; } }
/// <summary> /// 确认修改用户名 /// </summary> private async void OnConfirmChangeName() { ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click); var changeName = NameInputField.text.Trim(); if (string.IsNullOrEmpty(changeName) || changeName.Equals(PlayerName.text)) { Game.PopupComponent.ShowMessageBox("昵称不可为空"); OnCancelChangeName(); return; } var isMatch = Regex.IsMatch(NameInputField.text, _nameRegexStr); // if (!isMatch) // { // var matchA = Regex.IsMatch(_changeNameInput.text, _nameRegexStrGroupA); // if (matchA) // { // // 找到了汉字和字母数字的混合 // isMatch = Regex.IsMatch(_changeNameInput.text, _nameRegexStrGroupB); // } // } if (!isMatch) { Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.NickNameNotMatchTip); return; } if (_isRequest) { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NotRepeatModifyTip); return; } _isRequest = true; try { Game.PopupComponent.ShowLoadingLockUI(); G2C_ChangerUserInfo_Res chagerHead = (G2C_ChangerUserInfo_Res)await SessionComponent.Instance.Session. Call(new C2G_ChangerUserInfo_Req() { UserId = GamePrefs.GetUserId(), Type = 1, NickName = changeName }); if (chagerHead.Error != 0) { Debug.Log(chagerHead.Message); // GameHelper.ShowMessageBox(chagerHead.Message); Game.PopupComponent.ShowMessageBox(chagerHead.Message); _isRequest = false; Game.PopupComponent.CloseLoadingLockUI(); return; } _isRequest = false; await UserDataHelper.GetUserInfo(true); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyNickNameSuccTip); PlayerName.gameObject.SetActive(true); _changePlayerName.SetActive(true); _changeNameInput.text = ""; _changeNameInput.gameObject.SetActive(false); _confirmChangeName.SetActive(false); _cancelChangeName.SetActive(false); ChangeNameView.SetActive(false); Game.PopupComponent.CloseLoadingLockUI(); } catch (Exception e) { Log.Debug($"修改昵称错误:{e.Message}"); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyNickNameFailTip); _isRequest = false; Game.PopupComponent.CloseLoadingLockUI(); } }
public void Awake() { _rf = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); Root = _rf.Get <GameObject>("Root"); QRCode = _rf.Get <GameObject>("QRCode").GetComponent <Image>(); CodeText = _rf.Get <GameObject>("CodeText").Get <Text>(); QRCode.sprite = ETModel.Game.Scene.GetComponent <QRCodeComponent>().GenerateQRImage(GameHelper.GetShareQRCodeURL() + GamePrefs.GetUserId(), 512, 512); CodeText.text = UserDataHelper.UserInfo.PlayerId.ToString(); ButtonHelper.RegisterButtonEvent(_rf, "mask", OnClose); }