protected override async void Run(Session session, C2G_GateLogin message, Action <G2C_GateLogin> reply) { G2C_GateLogin response = new G2C_GateLogin(); try { long userId = Game.Scene.GetComponent <GateSessionKeyComponent>().Get(message.Key); //添加收取Actor消息组件 并且本地化一下 就是所有服务器都能向这个对象发 并添加一个消息拦截器 await session.AddComponent <MailBoxComponent, string>(ActorInterceptType.GateSession).AddLocation(); //通知GateUserComponent组件和用户服玩家上线 并获取User实体 User user = await Game.Scene.GetComponent <GateUserComponent>().UserOnLine(userId, session.Id); if (user == null) { response.Message = "用户信息查询不到"; reply(response); return; } //记录客户端session在User中 user.AddComponent <UserClientSessionComponent>().session = session; //给Session组件添加下线监听组件和添加User实体 session.AddComponent <SessionUserComponent>().user = user; //返回客户端User信息和 当前服务器时间 response.User = user; response.ServerTime = TimeTool.GetCurrenTimeStamp(); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
//进去签到 public static async Task <bool> UserTodaySingIn(this SingInActivityComponent singInActivityComponent, long userId) { List <UserSingInState> userSingInStates = await singInActivityComponent.dbProxyComponent.Query <UserSingInState>(userSingInState => userSingInState.UserId == userId); if (userSingInStates.Count > 0) { if (userSingInStates[0].SingInTime != 0 && TimeTool.TimeStampIsToday(userSingInStates[0].SingInTime)) { return(false); } } UserSingInState sueSingInState = ComponentFactory.CreateWithId <UserSingInState>(userId); sueSingInState.SingInTime = TimeTool.GetCurrenTimeStamp(); sueSingInState.UserId = userId; sueSingInState.SingInDays = 1; if (userSingInStates.Count > 0) { sueSingInState.SingInDays = userSingInStates[0].SingInDays + 1; } await singInActivityComponent.SendUserGetGoods(userId, sueSingInState.SingInDays); await singInActivityComponent.dbProxyComponent.Save(sueSingInState); return(true); }
//用户登陆 public static async Task <AccountInfo> LoginOrRegister(this UserComponent userComponent, string dataStr, int loginType) { AccountInfo accountInfo = null; switch (loginType) { case LoginType.Editor: case LoginType.Tourist: accountInfo = await userComponent.EditorLogin(dataStr); break; case LoginType.WeChat: accountInfo = await userComponent.WeChatLogin(dataStr); break; case LoginType.Voucher: //检验凭证 accountInfo = await userComponent.VoucherLogin(dataStr); break; default: Log.Error("不存在的登陆方式:" + loginType); break; } //更新最后登录时间 if (accountInfo != null) { accountInfo.LastLoginTime = TimeTool.GetCurrenTimeStamp(); await userComponent.dbProxyComponent.Save(accountInfo); } return(accountInfo); }
protected override async void Run(Session session, C2L_GetEverydayShareAward message, Action <L2C_GetEverydayShareAward> reply) { L2C_GetEverydayShareAward response = new L2C_GetEverydayShareAward(); try { List <EverydayShareInfo> everydayShareInfos = await GameLobby.Ins.dbProxyComponent.Query <EverydayShareInfo>(every => every.UserId == message.UserId); if (everydayShareInfos.Count > 0) { if (TimeTool.TimeStampIsToday(everydayShareInfos[0].ShareTime)) { response.Message = "今日已经领取过奖励"; reply(response); return; } everydayShareInfos[0].ShareTime = TimeTool.GetCurrenTimeStamp(); } else { EverydayShareInfo everydayShareInfo = ComponentFactory.Create <EverydayShareInfo>(); everydayShareInfo.UserId = message.UserId; everydayShareInfo.ShareTime = TimeTool.GetCurrenTimeStamp(); everydayShareInfos.Add(everydayShareInfo); } UserHelp.GoodsChange(message.UserId, GoodsId.Jewel, GameLobby._TheFirstShareAwarNum, GoodsChangeType.EverydayShare, true); await GameLobby.Ins.dbProxyComponent.Save(everydayShareInfos[0]); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
public static FreeDrawLottery Create(long userId) { FreeDrawLottery freeDrawLottery = ComponentFactory.Create <FreeDrawLottery>(); freeDrawLottery.UserId = userId; freeDrawLottery.Count = 1; freeDrawLottery.UpAddFreeDrawLotteryTime = TimeTool.GetCurrenTimeStamp(); return(freeDrawLottery); }
//记录销售信息 public static async void RecordMarketInfo(this AgencyComponent agencyComponent, long sellerUserId, User buyerUser, int jewelNum) { MarketInfo marketInfo = ComponentFactory.Create <MarketInfo>(); marketInfo.SellUserId = sellerUserId; marketInfo.MaiJiaUserId = buyerUser.UserId; marketInfo.MaiJiaName = buyerUser.Name; marketInfo.JewelNum = jewelNum; marketInfo.Time = TimeTool.GetCurrenTimeStamp(); await agencyComponent.dbProxyComponent.Save(marketInfo); marketInfo.Dispose(); }
public static TopUpRecord Create(string orderId, long userId, Commodity commodity) { TopUpRecord topUpRecord = ComponentFactory.Create <TopUpRecord>(); topUpRecord.OrderId = orderId; topUpRecord.TopUpUserId = userId; topUpRecord.Money = commodity.Price; topUpRecord.GoodsId = commodity.CommodityType; topUpRecord.GoodsAmount = commodity.Amount; topUpRecord.TopUpState = TopUpStateType.NoPay; topUpRecord.Time = TimeTool.GetCurrenTimeStamp(); return(topUpRecord); }
public static async Task StopSealOperate(this UserComponent userComponent, StopSealRecord stopSealRecord, IResponse iResponse) { List <AccountInfo> accountInfos = await userComponent.dbProxyComponent.Query <AccountInfo>(coount => coount.UserId == stopSealRecord.StopSealUserId); if (accountInfos.Count > 0) { accountInfos[0].IsStopSeal = stopSealRecord.IsStopSeal; await userComponent.dbProxyComponent.Save(accountInfos[0]); } else { iResponse.Message = "用户不存在"; } stopSealRecord.Time = TimeTool.GetCurrenTimeStamp(); await userComponent.dbProxyComponent.Save(stopSealRecord); }
//存储小局战绩信息 public static void SaveParticularMiltary(this FiveStarRoom fiveStarRoom, Actor_FiveStar_SmallResult actorFiveStarSmall) { //只有房卡才记录 if (fiveStarRoom.RoomType != RoomType.RoomCard) { return; } ParticularMiltary particularMiltary = ComponentFactory.Create <ParticularMiltary>(); particularMiltary.DataId = fiveStarRoom.StartVideoDataId + fiveStarRoom.CurrOfficNum; //录像数据ID particularMiltary.Time = TimeTool.GetCurrenTimeStamp(); //当前时间 for (int i = 0; i < actorFiveStarSmall.SmallPlayerResults.Count; i++) { particularMiltary.GetScoreInfos.Add(actorFiveStarSmall.SmallPlayerResults[i].GetScore); //得分情况 } fiveStarRoom.ParticularMiltarys.Add(particularMiltary); //添加到小局信息里面 fiveStarRoom.SaveParticularMiltaryRecordData(particularMiltary.DataId); //存储当前小局对战具体信息 }
//获取大局记录信息 public static async Task <List <Miltary> > GetMiltary(this MiltaryComponent miltaryComponent, long userId, int friendCircleId) { List <Miltary> miltaries = null; long beforeMoths = TimeTool.GetCurrenTimeStamp() - TimeTool.MonthsTime;//一个月之前的时间 if (friendCircleId == 0) { miltaries = await miltaryComponent.dbProxyComponent.Query <Miltary>(miltary => miltary.PlayerUserIds.Contains(userId) && miltary.Time > beforeMoths); } else if (userId == 0) { miltaries = await miltaryComponent.dbProxyComponent.Query <Miltary>(miltary => miltary.FriendCircleId == friendCircleId && miltary.Time > beforeMoths); } else { miltaries = await miltaryComponent.dbProxyComponent.Query <Miltary>(miltary => miltary.PlayerUserIds.Contains(userId) && miltary.FriendCircleId == friendCircleId && miltary.Time > beforeMoths); } return(miltaries); }
//记录中奖信息 public static async void RecordWinPrizeInfo(this TurntableComponent turntableComponent, long userId, TurntableGoods goods) { if (goods.GoodsId == GoodsId.None) { return; } WinPrizeRecord winPrizeRecord = ComponentFactory.Create <WinPrizeRecord>(); if (goods.GoodsId == GoodsId.Besans || goods.GoodsId == GoodsId.Jewel) { winPrizeRecord.Type = 1; //默认Type是0 其他就是兑奖了 } winPrizeRecord.WinPrizeId = turntableComponent.GetWinPrizeId(); //获取中奖记录Id winPrizeRecord.UserId = userId; winPrizeRecord.Time = TimeTool.GetCurrenTimeStamp(); winPrizeRecord.Amount = goods.Amount; winPrizeRecord.GoodsId = goods.GoodsId; await turntableComponent.dbProxyComponent.Save(winPrizeRecord); }
public void InitPanel() { muChuangView = mMuChuangViewGo.AddItem <MuChuangView>(); mRightBtnViewGo.AddItem <RightBtnView>(); mUserInfoViewGo.AddItem <UserInfoView>(); mTopBtnViewGo.AddItem <TopBtnView>(); broadcastView = mBroadcastViewGo.AddItem <BroadcastView>(); mRecordPerformanceBtn.Add(RecordPerformanceBtnEvent); SdkCall.Ins.LocationAction = Location; //定位回调 SdkCall.Ins.UrlOpenAppAction = UrlOpenApp; //网页打开APP回调 SdkMgr.Ins.GetLocation(); //第一次进入大厅 请求定位一下 long upLoginTime = long.Parse(PlayerPrefs.GetString(UpLoginTimeKey, "0")); if (!TimeTool.TimeStampIsToday(upLoginTime)) { //打开签到界面 UIComponent.GetUiView <ActivityAndAnnouncementPanelComponent>().ShowSignInActivity(); } PlayerPrefs.SetString(UpLoginTimeKey, TimeTool.GetCurrenTimeStamp().ToString()); }
//微信登陆 public static async Task <AccountInfo> WeChatLogin(this UserComponent userComponent, string accessTokenAndOpenid) { WeChatJsonData weChatJsonData = WeChatJsonAnalysis.HttpGetUserInfoJson(accessTokenAndOpenid); if (weChatJsonData == null) { return(null); } List <AccountInfo> accountInfos = await userComponent.dbProxyComponent.Query <AccountInfo>(AccountInfo => AccountInfo.Account == weChatJsonData.unionid); if (accountInfos.Count == 0) { AccountInfo accountInfo = await UserFactory.WeChatRegisterCreatUser(weChatJsonData); accountInfos.Add(accountInfo); } accountInfos[0].Password = TimeTool.GetCurrenTimeStamp().ToString(); await userComponent.dbProxyComponent.Save(accountInfos[0]); return(accountInfos[0]); }
protected override async void Run(Session session, C2L_GetReliefPayment message, Action <L2C_GetReliefPayment> reply) { L2C_GetReliefPayment response = new L2C_GetReliefPayment(); try { List <ReliefPaymentInfo> reliefPaymentInfos = await GameLobby.Ins.dbProxyComponent.Query <ReliefPaymentInfo>(info => info.UserId == message.UserId); if (reliefPaymentInfos.Count <= 0) { ReliefPaymentInfo reliefPaymentInfo = ComponentFactory.Create <ReliefPaymentInfo>(); reliefPaymentInfo.UserId = message.UserId; reliefPaymentInfo.Number = 0; reliefPaymentInfos.Add(reliefPaymentInfo); } if (!TimeTool.TimeStampIsToday(reliefPaymentInfos[0].Time))//如果上次领取的时机 不是今天 次数重置为0 { reliefPaymentInfos[0].Number = 0; } if (reliefPaymentInfos[0].Number >= GameLobby.ReliefPaymentNumber) { response.Message = "今日领取救济金达到上限"; reply(response); return; } reliefPaymentInfos[0].Time = TimeTool.GetCurrenTimeStamp(); //记录当前领取的时机 reliefPaymentInfos[0].Number++; //领取的次数++ //给用户加上豆子 await UserHelp.GoodsChange(message.UserId, GoodsId.Besans, GameLobby.ReliefPaymentBeansNum, GoodsChangeType.None, false); await GameLobby.Ins.dbProxyComponent.Save(reliefPaymentInfos[0]);//存储 领取救济金信息 reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
//存储大局战绩记录 public static async Task SaveTotalMiltary(this FiveStarRoom fiveStarRoom) { //只有房卡才记录 如果一局小局信息都没有 就不用保存大局录像了 if (fiveStarRoom.RoomType != RoomType.RoomCard || fiveStarRoom.ParticularMiltarys.Count == 0) { return; } Miltary miltary = ComponentFactory.Create <Miltary>(); miltary.MiltaryId = FiveStarRoomComponent.Ins.GetMiltaryVideoId(); //大局录像Id miltary.RoomNumber = fiveStarRoom.RoomId; //房号 miltary.FriendCircleId = fiveStarRoom.FriendsCircleId; //所属亲友ID miltary.ToyGameId = ToyGameId.CardFiveStar; //游戏类型 miltary.Time = TimeTool.GetCurrenTimeStamp(); //当前时间 miltary.PlayerInofs = fiveStarRoom.GetMiltaryPlayerInfo(); //玩家信息 for (int i = 0; i < miltary.PlayerInofs.Count; i++) { miltary.PlayerUserIds.Add(miltary.PlayerInofs[i].UserId); } fiveStarRoom.SaveMiltarySmallInfo(miltary.MiltaryId); await FiveStarRoomComponent.Ins.SaveVideo(miltary);//存储大局战绩到数据库 miltary.Dispose(); }