public User GetUserFormUserName(string username) { if (User0 != null && StringUtil.AreEqual(User0.username, username)) { return(User0); } if (User1 != null && StringUtil.AreEqual(User1.username, username)) { return(User1); } if (User2 != null && StringUtil.AreEqual(User2.username, username)) { return(User2); } if (User3 != null && StringUtil.AreEqual(User3.username, username)) { return(User3); } return(null); }
public static bool IsEmoji(string content) { for (int i = 0; i < Values.Length; i++) { if (StringUtil.AreEqual(content, Values[i])) { return(true); } } return(false); }
protected override void DoHandle(BTempLeave msg) { var user = _myUser.Read(); if (user == null) { return; } if (StringUtil.AreEqual(user.username, msg.username)) { user.temp_leave = msg.temp_leave_or_not; _myUser.Invalidate(Time.time); } }
public static bool IsCommodityEquiped(Bag bag, User user, Commodity data) { if (data == null) { return(false); } if (!HasCommodity(bag, data)) { return(false); } if (user == null) { return(false); } switch (data.type) { case CommodityType.Hair: if (StringUtil.AreEqual(data.name, user.hair)) { return(true); } break; case CommodityType.Body: if (StringUtil.AreEqual(data.name, user.body)) { return(true); } break; case CommodityType.DeskItem: if (user.item_show != null && user.item_show.Count >= 1 && StringUtil.AreEqual(data.name, user.item_show[0])) { return(true); } break; } return(false); }
public bool IsMySelf(User user) { if (user == null) { return(false); } var myUser = GetUserAtSeat(MySeat); if (myUser == null) { return(false); } return(StringUtil.AreEqual(user.username, myUser.username)); }
public int RankOf(User user) { if (user == null) { return(-1); } for (int i = 0; i < _ranks.Length; i++) { if (StringUtil.AreEqual(user.username, _ranks[i])) { return(i); } } return(-1); }
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)); }
private int MySeat() { var user = _myUser.Read(); if (user == null) { return(-1); } var userName = user.username; var table = _currentTable.Read(); if (table == null) { return(-1); } if (table.user1 != null && StringUtil.AreEqual(table.user1.username, userName)) { return(0); } if (table.user2 != null && StringUtil.AreEqual(table.user2.username, userName)) { return(1); } if (table.user3 != null && StringUtil.AreEqual(table.user3.username, userName)) { return(2); } if (table.user4 != null && StringUtil.AreEqual(table.user4.username, userName)) { return(3); } return(-1); }
public static bool HasCommodity(Bag bag, string cname) { if (bag == null) { return(false); } if (bag.item == null || bag.item.Count <= 0) { return(false); } for (int i = 0; i < bag.item.Count; i++) { var item = bag.item[i]; if (StringUtil.AreEqual(item.name, cname)) { return(true); } } return(false); }
public static Commodity GetCommodity(List <Commodity> commodityList, string cname) { if (string.IsNullOrEmpty(cname)) { return(null); } var list = commodityList; if (list == null || list.Count <= 0) { return(null); } for (int i = 0; i < list.Count; i++) { if (StringUtil.AreEqual(list[i].name, cname)) { return(list[i]); } } return(null); }
protected override void DoHandle(BRoundEnd msg) { var msgPlayingData = msg.playing_data; if (msgPlayingData != null) { _playingData.Write(msgPlayingData, Time.time); } _bRoundEnd.Write(msg, Time.time); var tableUser = _tableUserData.Read(); var table = _table.Read(); var myUser = _user.Read(); var room = _roomData.Read(); // 更新一下桌子的数据。 if (DataUtil.UpdateTable(msg.table, table)) { _table.Invalidate(Time.time); } // 更新玩家自己的数据。 var user = DataUtil.GetUser(msg.table, tableUser.MySeat); if (DataUtil.UpdateUserPublic(user, myUser)) { _user.Invalidate(Time.time); } // 重置玩家的状态。 ResetAllUserState(); if (_appController.IsSingleGameMode()) { return; } // 非单机模式下,进行统计。 if (msg.total_multiple > 1) { _analyticManager.EventValue("round_end_fanbei", null, msg.total_multiple); } var type = room == null ? CurrencyType.GOLDEN_EGG : room.currency_type; var count = 0; var userName = user == null ? null : user.username; if (StringUtil.AreEqual(msg.username1, userName)) { count = msg.final_money1; } else if (StringUtil.AreEqual(msg.username2, userName)) { count = msg.final_money2; } else if (StringUtil.AreEqual(msg.username3, userName)) { count = msg.final_money3; } else if (StringUtil.AreEqual(msg.username4, userName)) { count = msg.final_money4; } var currentRoomTaxRate = room == null ? 0 : room.tax_rate; var currentRoomId = room == null ? -1 : room.room_id; if (count > 0) { _analyticManager.Bonus( DataUtil.CalculateGeValue(type, count * (100 - currentRoomTaxRate) / 100), AwardType.RoundEndWin); } else if (count < 0) { var geVal = (int)DataUtil.CalculateGeValue(type, Math.Abs(count)); _analyticManager.Buy("round_end_lose", 1, geVal); // 统计结算带来的负金蛋流量。 var attrs = new Dictionary <string, string>(); attrs.Add("base_money", "" + currentRoomTaxRate); _analyticManager.EventValue("round_end_ge" + currentRoomId, attrs, geVal * currentRoomTaxRate / 100); } }
private void ProcessAlipayResult(AlipayResult res) { if (res == null) { // 支付失败了,支付宝结果数据解析失败。 EnableComponent(false, false, true); SetStateTxt(string.Format("<color=red>支付失败!</color>\n如有疑问请联系下方客服QQ{0}", !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : "")); StopPay(); AnalyticPayFail("alipay_res_parse_error"); return; } if (StringUtil.AreEqual(res.status, AlipayResult.StatusOk)) { var param = DataUtil.ParseParameter(res.result); if (param.ContainsKey("success") && StringUtil.AreEqual("true", param["success"])) { // 支付成功。 EnableComponent(false, true, true); SetStateTxt("恭喜您,充值成功^_^\n马上请求发货"); AnalyticPayOk(); } else { EnableComponent(false, false, true); if (StateTxt) { SetStateTxt(string.Format("<color=red>支付失败!</color>\n请联系下方客服QQ{0}", !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : "")); } StopPay(); AnalyticPayFail("alipay_status_ok_not_success"); } } else { // 支付失败。 if (StringUtil.AreEqual(res.status, AlipayResult.StatusProcessing)) { // 订单正在处理当中。 EnableComponent(false, false, true); SetStateTxt(string.Format("<color=red>支付宝未能处理订单!</color>\n请联系下方客服QQ{0}", !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : "")); AnalyticPayFail("alipay_processing"); } else if (StringUtil.AreEqual(res.status, AlipayResult.StatusFail)) { // 支付失败。 EnableComponent(false, false, true); SetStateTxt(string.Format("<color=red>支付失败!{0}</color>\n请联系下方客服QQ{1}", !string.IsNullOrEmpty(res.memo) ? "\n" + res.memo : "", !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : "")); AnalyticPayFail("alipay_fail"); } else if (StringUtil.AreEqual(res.status, AlipayResult.StatusCanceled)) { // 玩家取消支付。 EnableComponent(false, false, true); SetStateTxt("<color=red>玩家取消订单</color>"); AnalyticPayFail("alipay_cancel"); } else if (StringUtil.AreEqual(res.status, AlipayResult.StatusNetworkError)) { // 网络出错。 EnableComponent(false, false, true); SetStateTxt("<color=red>网络出错,无法连接支付宝</color>"); AnalyticPayFail("alipay_network_broken"); } else { // 未知原因失败。 EnableComponent(false, false, true); SetStateTxt(string.Format("<color=red>支付失败!</color>\n请联系下方客服QQ{0}", !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : "")); AnalyticPayFail("alipay_unknown_error"); } StopPay(); } }
/// <summary> /// 应用玩家数据。 /// </summary> /// <param name="data"></param> public void ApplyData(User data) { if (data == null) { Data = null; // Close function group when clear data. ShowFuncGroup(false); ShowKickOutCounter(false); if (SelfIndicator && SelfIndicator.gameObject.activeSelf) { SelfIndicator.gameObject.SetActive(false); } if (ReadyIndicator && ReadyIndicator.gameObject.activeSelf) { ReadyIndicator.gameObject.SetActive(false); } if (Level) { Level.text = ""; } if (LevelTitle) { LevelTitle.text = ""; } if (WinRate) { WinRate.text = ""; } if (Money) { Money.Clear(); } if (Nickname) { Nickname.Clear(); } if (Player) { Player.Clear(); } } else { // 之前的数据是空,或者数据发生了变化,则关闭倒计时和功能按钮。 if (Data == null || !StringUtil.AreEqual(data.username, Data.username)) { // FIXME bug就出在这里了。 ShowFuncGroup(false); ShowKickOutCounter(false); } Data = data; var tableUser = _tableUserData.Read(); var self = tableUser.IsMySelf(data); if (SelfIndicator && SelfIndicator.gameObject.activeSelf != self) { SelfIndicator.gameObject.SetActive(self); } var ready = data.ready == 1; if (ReadyIndicator && ReadyIndicator.gameObject.activeSelf != ready) { ReadyIndicator.gameObject.SetActive(ready); } if (Level) { Level.text = "" + data.level; } if (LevelTitle) { LevelTitle.text = "" + data.title; } if (WinRate) { float rate = data.round_count != 0 ? ((float)data.win_count) / data.round_count : 0; WinRate.text = DataUtil.FormatWinRate(rate); } if (Money) { var room = _room.Read(); var currencyType = room == null ? CurrencyType.GOLDEN_EGG : room.currency_type; Money.SetCurrency(DataUtil.GetCurrency(data, currencyType), currencyType); } if (Nickname) { Nickname.SetData(data); } if (Player) { Player.ApplyData(data); } } }