public void SavePlayerInfo() { var dialogManager = GetDialogManager(); if (!HasChange()) { dialogManager.ShowToast("没有任何更改,不需要保存!", 2); return; } // 个性签名。 string description = null; // 城市。 string city = null; // 邮箱。 string email = null; if (_emailChanged && Email) { email = Email.text; if (!string.IsNullOrEmpty(email)) { email = email.Trim(); if (!DataUtil.ValidateEmail(email)) { dialogManager.ShowToast("请填写正确的Email,格式为[email protected]", 3); return; } } } dialogManager.ShowWaitingDialog(true); var remoteAPI = GetRemoteAPI(); var taskManager = GetTaskManager(); _editUserInfoResult.ClearAndInvalidate(Time.time); remoteAPI.EditUserInfo( // 现在不能编辑昵称了。 null, // 也不支持修改性别了。 -1, email, description, city ); taskManager.ExecuteTask( CheckEditUserInfoResult, () => dialogManager.ShowWaitingDialog(false)); // 不需要关闭保存按钮,如果编辑出错的话,之后还能够继续编辑。 }
public void BuyCommodity() { _dialogManager.ShowWaitingDialog(true); _buyCommodityResult.ClearAndInvalidate(Time.time); _remoteAPI.BuyCommodity(_currentSelected); _taskManager.ExecuteTask( CheckBuyCommodityResult, () => _dialogManager.ShowWaitingDialog(false)); }
private void InitYuanBaoConfigData() { _yuanBaoConfigResult.ClearAndInvalidate(Time.time); _remoteAPI.RequestYuanBaoConfigData(); _analyticManager.Event("yuanbao_show"); }
public void RefreshFriendList() { _sFriendListResult.ClearAndInvalidate(Time.time); _remoteAPI.RefreshFriendList(); _analyticManager.Event("refresh_friend_list_manually"); }
private void ClearPUData() { _versionResult.ClearNotInvalidate(); _billboardRead.ClearNotInvalidate(); _pLoginResult.ClearAndInvalidate(Time.time); }
private void UseCommodity(string cname, bool use) { if (string.IsNullOrEmpty(cname)) { return; } _dialogManager.ShowWaitingDialog(true); _useCommodityResult.ClearAndInvalidate(Time.time); _taskManager.ExecuteTask( CheckUseCommodityResult, () => _dialogManager.ShowWaitingDialog(false)); _remoteAPI.UseCommodity(cname, use); }
private void ExtractRooms() { _dialogManager.ShowWaitingDialog(true); _raceConfigList.ClearAndInvalidate(0); _task.ExecuteTask(CheckRaceConfigListResult, GetRaceConfigListComplete, () => { _dialogManager.ShowWaitingDialog(false); }, 5); _remoteAPI.RequestRaceConfigList(); }
protected override void DoHandle(StartRound msg) { var msgPlayingData = msg.playing_data; if (msgPlayingData != null) { _playingData.Write(msgPlayingData, Time.time); } var table = _currentTable.Read(); if (table != null) { // 开局刷新一下局数和HostInfo。 table.team1_host = msg.team1_host; table.team2_host = msg.team2_host; table.host_team = msg.host_team; table.round_count = msg.round_count; // 刷新桌面用户的数据。这里已经更新了MyUser DataUtil.UpdateUserPublic(msg.user1, table.user1); DataUtil.UpdateUserPublic(msg.user2, table.user2); DataUtil.UpdateUserPublic(msg.user3, table.user3); DataUtil.UpdateUserPublic(msg.user4, table.user4); _myUser.Invalidate(Time.time); // 更新桌子数据。 // 可以刷新游戏的状态。 _currentTable.Invalidate(Time.time); // 重置打牌数据。 var playingData = _playingData.Read(); if (playingData == null) { playingData = new PlayingData(); playingData.ResetAll(); playingData.period = TablePeriod.StartRound; _playingData.Write(playingData, Time.time); } //清空团团转数据 _ttzStartBroadcast.ClearAndInvalidate(0); // 开局的时候清空结算数据。 _bRoundEnd.ClearNotInvalidate(); _raceRoundEnd.ClearNotInvalidate(); // 设置开局时间。 _startRound.Write(msg, Time.time); //清空倒计时时间 _bCounter.ClearAndInvalidate(0); _kickOutCounter.ClearAndInvalidate(0); } }
public void ShowMyYuanBaoRecordDialog() { _dialogManager.ShowWaitingDialog(true); _myYuanBaoExchangeResult.ClearAndInvalidate(Time.time); _taskManager.ExecuteTask(CheckMyYuanBaoExchangeResult, () => _dialogManager.ShowWaitingDialog(false)); _remoteAPI.RequestMyYuanBaoExchange(); _analyticManager.Event("yuanbao_record_show"); }
/// <summary> /// 清空当前应用的状态。 /// </summary> public void ClearAppStateData() { _pLoginResult.ClearAndInvalidate(Time.time); _versionResult.ClearNotInvalidate(); _billboardRead.ClearNotInvalidate(); _hloginResult.ClearAndInvalidate(Time.time); _currentGameMode.Write(GameMode.Null, Time.time); _vipExchangeList.ClearNotInvalidate(); _treasureChestData.ClearNotInvalidate(); _friendListResult.ClearNotInvalidate(); }
public void DoRecheckin() { var dialogManager = GetDialogManager(); var remoteAPI = GetRemoteAPI(); var taskManager = GetTaskManager(); dialogManager.ShowWaitingDialog(true); _reCheckinResult.ClearAndInvalidate(Time.time); remoteAPI.ReCheckin(); taskManager.ExecuteTask(CheckReCheckinResult, () => dialogManager.ShowWaitingDialog(false)); }
public void ConfirmChooseNickname() { var user = _userContainer.Read(); var featureSwitch = _featureSwitchContainer.Read(); var isEnablePersonalIfo = false; var userSex = 1; if (user != null) { userSex = user.sex; } if (featureSwitch != null) { isEnablePersonalIfo = featureSwitch.personal_info; } string nickname = null; var sex = userSex; nickname = Nickname.text; if (isEnablePersonalIfo) { // 只有在开启personalInfo的情况下,才读取玩家选择的性别。 if (MaleToggle.isOn) { sex = 1; } if (FemaleToggle.isOn) { sex = 0; } } var dialogManager = GetDialogManager(); var remoteAPI = GetRemoteAPI(); var taskManager = GetTaskManager(); dialogManager.ShowWaitingDialog(true); _chooseNicknameResultContainer.ClearAndInvalidate(Time.time); remoteAPI.VisitorChooseNickname(nickname, sex); taskManager.ExecuteTask( CheckVisitorChooseNicknameResult, () => dialogManager.ShowWaitingDialog(false)); }
protected override void DoHandle(ChooseRoomFail msg) { _chooseRoomFail.Write(msg, Time.time); if (msg != null) { // 选房失败的情况。 _gLoginResult.ClearAndInvalidate(Time.time); } _dialogManager.ShowDialog <ChooseRoomFailDialog>(DialogName.ChooseRoomFailDialog, false, false, (dialog) => { dialog.ApplyData(msg); dialog.Show(); }); }
public void ConfirmChange() { string oldPassword = null; string newPassword = null; if (OldPasswordEdt) { oldPassword = OldPasswordEdt.text; } if (NewPasswordEdt) { newPassword = NewPasswordEdt.text; } var dialogManager = GetDialogManager(); if (string.IsNullOrEmpty(oldPassword)) { dialogManager.ShowToast("请输入旧密码!", 3, true); return; } if (string.IsNullOrEmpty(newPassword)) { dialogManager.ShowToast("请输入新密码!", 3, true); return; } if (StringUtil.AreEqual(oldPassword, newPassword)) { dialogManager.ShowToast("新密码与旧密码相同,无需修改!", 3); return; } dialogManager.ShowWaitingDialog(true); _changePasswordResult.ClearAndInvalidate(Time.time); GetRemoteAPI().ChangePassword(oldPassword, newPassword); GetTaskManager().ExecuteTask( CheckChangePasswordResult, () => dialogManager.ShowWaitingDialog(false)); }
public override void BeforeShow() { TipsTxt.text = "升级账号可以让您的账号更安全便捷!"; // 非微信用户才能升级微信。 var enableWechat = _user != null && _user.type != UserType.Wechat; var isEnablePersonalInfo = false; var featureSwitch = _featureSwitch.Read(); if (featureSwitch != null) { isEnablePersonalInfo = featureSwitch.personal_info; } if (!isEnablePersonalInfo) { enableWechat = false; } if (BindingWechatBtn.gameObject.activeSelf != enableWechat) { BindingWechatBtn.gameObject.SetActive(enableWechat); } // 游客账户可以升级账户。 var enableBindUsername = _user != null && _user.type == UserType.Visitor; if (BindingUserNameBtn.gameObject.activeSelf != enableBindUsername) { BindingUserNameBtn.gameObject.SetActive(enableBindUsername); } if (!enableWechat && !enableBindUsername) { TipsTxt.text = "您的账号无需升级"; } _getAuthCode = false; _wechatBindResult.ClearAndInvalidate(0); }
protected override void DoHandle(LeaveTableResult msg) { if (msg == null) { return; } _leaveTableResult.Write(msg, Time.time); if (msg.result == ResultCode.OK) { // 离桌成功,则清空选桌数据。 _chooseTableResult.ClearAndInvalidate(Time.time); // 离桌成功,清空开局和结算数据。 _startRound.ClearAndInvalidate(0); _roundEnd.ClearNotInvalidate(); _raceRoundEnd.ClearNotInvalidate(); } // 离桌不成功,则什么都不做。 _chooseTableResult.Invalidate(Time.time); if (msg.result == ResultCode.LEAVE_WILL_PUNISH) { var room = _currentRoom.Read(); _dialogManager.ShowDialog <PunishTipDialog>(DialogName.PunishTipDialog, false, false, (dialog) => { dialog.ApplyData( room, "依然退出", () => _remoteAPI.LeaveTable(true) ); dialog.Show(); }); } }
protected override void DoHandle(LeaveRoomResult res) { _leaveRoomResult.Write(res, Time.time); if (res == null) { return; } if (res.result == ResultCode.OK) { UpdateRoom(res.room); _chooseRoomResult.ClearNotInvalidate(); _chooseRoomFail.ClearNotInvalidate(); _gLoginResult.ClearAndInvalidate(Time.time); } if (res.result == ResultCode.LEAVE_WILL_PUNISH) { _dialogManager.ShowDialog <PunishTipDialog>(DialogName.PunishTipDialog, false, false, (dialog) => { dialog.ApplyData( _currentRoom.Read(), "依然退出", () => _remoteAPI.LeaveRoom(true) ); dialog.Show(); }); } if (_network.GetServer() == Server.GServer) { _network.StartConnectHServer(); } }
public void OnSignupBtnClick() { if (_raceConfig == null) { _dialogManager.ShowToast("报名失败", 2, true); return; } var fee = _raceConfig.fee; if (fee != null) { _dialogManager.ShowConfirmBox(string.Format("是否花费<color=green>{0}{1}</color>报名比赛?", fee.count, CurrencyType.LabelOf(fee.type)), true, "确定", () => { _dialogManager.ShowWaitingDialog(true); _applyRaceResult.ClearAndInvalidate(0); _task.ExecuteTask(CheckApplyRaceResult, GetApplyRaceResultComplete, () => { _dialogManager.ShowWaitingDialog(false); }, 5); _remoteAPI.ApplyRace(_raceConfig.race_id); }, true, "取消", null, true, false, true); } }
protected override void DoHandle(ChooseTableResult msg) { _chooseTableResult.Write(msg, Time.time); if (msg != null && msg.result == ResultCode.OK) { // 选房成功的情况下,更新一下自己的数据。 var tableUserData = _tableUser.Read(); var user = _user.Read(); var mySeat = tableUserData.MySeat; var msgUser = DataUtil.GetUser(msg.table, mySeat); if (DataUtil.UpdateUserPublic(msgUser, user)) { _user.Invalidate(Time.time); } // 进桌成功,清空开局和结算数据。 _startRound.ClearAndInvalidate(0); _roundEnd.ClearNotInvalidate(); _raceRoundEnd.ClearNotInvalidate(); } // 收到选桌命令的话,就应该清空踢人计数器。 _kickOutCounter.ClearAndInvalidate(Time.time); }
public void DoRegularize() { string username = null; string password = null; string repassword = null; string nickname = null; int sex = 0; username = UsernameEdt.text; password = PasswordEdt.text; repassword = RepasswordEdt.text; nickname = NicknameEdt.text; sex = MaleToggle.isOn ? 1 : 0; var dialogManager = GetDialogManager(); if (string.IsNullOrEmpty(username)) { dialogManager.ShowToast("请输入账号!", 2, true); return; } if (string.IsNullOrEmpty(password)) { dialogManager.ShowToast("请输入密码!", 2, true); return; } if (!password.Equals(repassword)) { dialogManager.ShowToast("两次输入的密码不相同!", 2, true); return; } if (string.IsNullOrEmpty(nickname)) { dialogManager.ShowToast("请输入昵称!", 2, true); return; } if (!DataUtil.ValidateUsername(username)) { dialogManager.ShowMessageBox("账号格式出错!\n账号只能由字母、数字、和下划线组成"); return; } if (!DataUtil.ValidatePassword(password)) { dialogManager.ShowMessageBox("密码格式出错!\n密码只能由字母、数字、和下划线组成"); return; } if (!DataUtil.ValidateNickname(nickname)) { dialogManager.ShowMessageBox("昵称不能超过16个字,不能包含换行"); return; } dialogManager.ShowWaitingDialog(true); _regularizeUsername = username; _regularizePassword = password; _visitorRegularizeResult.ClearAndInvalidate(Time.time); GetRemoteAPI().VisitorRegularize(username, nickname, password, sex); GetTaskManager().ExecuteTask( CheckVisitorRegularizeResult, () => dialogManager.ShowWaitingDialog(false)); GetAnalyticManager().Event("visitor_regularize_apply"); }
private IEnumerator BuildFirstCache() { var config = _context.GetConfigHolder(); var resVersion = config.ResourceVersion; using (var manifestReq = UnityWebRequest.GetAssetBundle( Path.Combine(StreamingAssetsPath, "StreamingAssets"), (uint)resVersion, (uint)0)) { manifestReq.SendWebRequest(); while (!manifestReq.isDone) { yield return(null); } if (manifestReq.isNetworkError || manifestReq.isHttpError) { MyLog.ErrorWithFrame(name, "加manifest失败 error " + manifestReq.error + " manifestPath = " + Path.Combine(StreamingAssetsPath, "StreamingAssets")); SetBuildFirstCacheResult(BuildFirstCacheResult.Error, string.Format("初始化资源列表失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.BuildFirstCacheFailCode)); yield break; } var manifestBundle = DownloadHandlerAssetBundle.GetContent(manifestReq); if (manifestBundle == null) { MyLog.ErrorWithFrame(name, " manifestBundle == null manifestPath = " + Path.Combine(StreamingAssetsPath, "StreamingAssets")); SetBuildFirstCacheResult(BuildFirstCacheResult.Error, string.Format("获取初始化资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.BuildFirstCacheFailCode)); yield break; } var manifest = manifestBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); if (manifest == null) { MyLog.ErrorWithFrame(name, " manifest =null " + Path.Combine(StreamingAssetsPath, "StreamingAssets")); SetBuildFirstCacheResult(BuildFirstCacheResult.Error, string.Format("获取初始化资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.BuildFirstCacheFailCode)); yield break; } var allAssetBundles = manifest.GetAllAssetBundles(); if (allAssetBundles == null || allAssetBundles.Length <= 0) { MyLog.ErrorWithFrame(name, "allAssetBundles == null manifest = " + Path.Combine(StreamingAssetsPath, "StreamingAssets")); SetBuildFirstCacheResult(BuildFirstCacheResult.Error, string.Format("获取初始化资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.BuildFirstCacheFailCode)); yield break; } var downloadAssetBundleInfo = new DownloadAssetBundleInfo(); downloadAssetBundleInfo.LoadType = DownloadAssetBundleInfo.DownloadType.FirstBuild; downloadAssetBundleInfo.TotalCount = allAssetBundles.Length; downloadAssetBundleInfo.CompleteCount = 0; foreach (var abName in allAssetBundles) { if (string.IsNullOrEmpty(abName)) { continue; } _downloadAssetBundleInfo.Write(downloadAssetBundleInfo, Time.time); using (var bundleReq = UnityWebRequest.GetAssetBundle( Path.Combine(StreamingAssetsPath, abName), (uint)resVersion, (uint)0)) { bundleReq.SendWebRequest(); while (!bundleReq.isDone) { yield return(null); } if (bundleReq.isNetworkError || bundleReq.isHttpError) { MyLog.ErrorWithFrame(name, abName + " upload to cache fail "); SetBuildFirstCacheResult(BuildFirstCacheResult.Error, string.Format( "下载获取初始化资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.BuildFirstCacheFailCode)); yield break; } downloadAssetBundleInfo.CompleteCount++; } } yield return(null); _downloadAssetBundleInfo.ClearAndInvalidate(Time.time); MyLog.InfoWithFrame(name, " upload all resource succ >>>>>>>>>>>>> UnloadAllAssetBundles >>>>>>>>>>>"); SetBuildFirstCacheResult(BuildFirstCacheResult.Ok, ""); AssetBundle.UnloadAllAssetBundles(false); } }
private void RefreshChat() { if (ChatRefreshTime >= _bTextMsg.Timestamp) { return; } ChatRefreshTime = _bTextMsg.Timestamp; var msg = _bTextMsg.Read(); if (msg == null) { return; } var tableUser = _tableuserData.Read(); var seat = tableUser.GetSeatOfUser(msg.from_username); if (seat == -1) // 不是当前桌子上的人发的消息,就直接忽略吧。 { return; } if (string.IsNullOrEmpty(msg.content)) // 聊天内容为空的时候,也直接忽略。 { return; } RectTransform container = null; switch (seat) { case 0: container = SouthChatContainer; break; case 1: container = EastChatContainer; break; case 2: container = NorthChatContainer; break; case 3: container = WestChatContainer; break; } if (!container) { return; } // 初始化一个ChatBubble用来显示聊天的内容。 var bubble = _chatBubbleFactory.Create(); if (!bubble) { return; } bubble.transform.SetParent(container, false); bubble.transform.localPosition = Vector3.zero; if (Emoji.IsEmoji(msg.content)) { bubble.SetEmoji(msg.content); } else { bubble.SetText(msg.content); } bubble.Show(); // 清空当前数据。 _bTextMsg.ClearAndInvalidate(0); }