Ejemplo n.º 1
0
        /// <summary>
        /// 攻击 CD 计时
        /// </summary>
        /// <param name="self"></param>
        public static void AttackTarget(this AttackComponent self)
        {
            if (self.delTime == 0)
            {
                //普通攻击,相当于施放技能41101,技能等级为0
                SkillItem skillItem = ComponentFactory.CreateWithId <SkillItem>(41101);

                skillItem.UpdateLevel(0);

                skillItem.GetComponent <ChangeType>().CastId = self.GetParent <Unit>().Id;

                skillItem.GetComponent <NumericComponent>().Set(NumericType.CaseBase, 14);

                self.target.GetComponent <AttackComponent>().TakeDamage(skillItem);

                self.startTime = TimeHelper.ClientNowSeconds();
            }

            long timeNow = TimeHelper.ClientNowSeconds();

            self.delTime = timeNow - self.startTime + 1;

            if (self.delTime > (self.attcdTime + 1))
            {
                self.delTime = 0;
            }
        }
        //生成ID的算法 通过时间过去式的思想 使之不会出现重复的ID
        public static long GenerateId()
        {
            //客户端现在的秒数
            long time = TimeHelper.ClientNowSeconds();

            return((appId << 48) + (time << 16) + ++value);
        }
Ejemplo n.º 3
0
        public static long GenerateId()
        {
            long time = TimeHelper.ClientNowSeconds();

            //appId*2的48次方+time*2的16次方+ value自增后的值
            return((appId << 48) + (time << 16) + ++value);
        }
Ejemplo n.º 4
0
    //创建Version.txt
    public static void Modify()
    {
        VersionConfig newVersionconfig = new VersionConfig();

        newVersionconfig.Version = (int)TimeHelper.ClientNowSeconds();

#if UNITY_ANDROID
        Log.Debug("创建新Android资源版本" + newVersionconfig.Version.ToString());
#elif UNITY_IOS
        Log.Debug("创建新iOS资源版本" + newVersionconfig.Version.ToString());
#elif UNITY_WEBGL
        Log.Debug("创建新WEBGL资源版本" + newVersionconfig.Version.ToString());
#elif UNITY_STANDALONE_OSX
        Log.Debug("创建新Mac资源版本" + newVersionconfig.Version.ToString());
#else
        Log.Debug("创建新PC资源版本" + newVersionconfig.Version.ToString());
#endif

        //获取本地热更新文件目录地址
        DirectoryInfo directoryInfo = new DirectoryInfo(PathHelper.AppHotfixResPath);
        if (directoryInfo.Exists)
        {
            long size = 0;
            //遍历本地文件 为每个文件建立一个FileVersionInfo
            FileInfo[] fileInfos = directoryInfo.GetFiles();
            foreach (FileInfo fileInfo in fileInfos)
            {
                if (fileInfo.Name.EndsWith("meta"))
                {
                    continue;
                }
                FileVersionInfo a = new FileVersionInfo();
                a.File = fileInfo.Name;
                a.MD5  = GetBundleMD5(fileInfo.Name);
                a.Size = GetBundleSize(fileInfo.Name);
                newVersionconfig.FileInfoDict.Add(fileInfo.Name, a);
                size = a.Size + size;
            }

            //添加Version.txt到目录
            FileVersionInfo version = new FileVersionInfo();
            version.File = "Version.txt";
            version.MD5  = "";
            version.Size = 0;
            newVersionconfig.FileInfoDict.Add("Version.txt", version);
            newVersionconfig.TotalSize = size;

            //输出为文件
            string path = PathHelper.AppHotfixResPath + "/Version.txt";
            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                byte[] data = System.Text.Encoding.ASCII.GetBytes(JsonHelper.ToJson(newVersionconfig));
                fs.Write(data, 0, data.Length);
            }
        }
        else
        {
            Log.Error("热更新目录不存在");
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 插入一条空白私聊信息
    /// </summary>
    /// <param name="playUid"></param>
    public static void CreationNullPrivateChatMessage(long playUid, int iconId, string iconUrl, string playName, int experience)
    {
        var privateChat = _privateChannelMessages.Find((data) =>
        {
            if (data.PrivateChatRoleUid == playUid)
            {
                return(true);
            }
            return(false);
        });

        if (privateChat == null)
        {
            PrivateChatSaveInfo priChat = new PrivateChatSaveInfo();
            priChat.PrivateChatRoleUid = playUid;
            priChat.iconId             = iconId;
            priChat._iconUrl           = iconUrl;
            priChat._playName          = playName;
            priChat._experience        = experience;
            priChat.LastTimeTicks      = TimeHelper.ClientNowSeconds();
            priChat.ChatInfos          = new List <ChatInfo>();
            _privateChannelMessages.Insert(0, priChat);
        }
        else
        {
            privateChat._playName   = playName;
            privateChat.iconId      = iconId;
            privateChat._iconUrl    = iconUrl;
            privateChat._experience = experience;
            _privateChannelMessages.Remove(privateChat);
            _privateChannelMessages.Insert(0, privateChat);
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// 生成指定大区的账号 参数为1以上的整数
        /// </summary>
        /// <param name="GateAppId"></param>
        /// <returns></returns>
        public static long GenerateId(int GateAppId)
        {
            long time = TimeHelper.ClientNowSeconds();

            //1540 2822 75   时间为10位数
            //区号取第11位数
            return(GateAppId * 100000000000 + time + ++value);
        }
Ejemplo n.º 7
0
        protected override void Run(Session session, C2G_HeartTick message, Action <G2C_HeartTick> reply)
        {
            if (session.GetComponent <HeartTickComponent>() != null)
            {
                session.GetComponent <HeartTickComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
            }
            G2C_HeartTick response = new G2C_HeartTick();

            reply(response);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 随机生成区号 1~
        /// </summary>
        public static long GenerateId()
        {
            //随机获得GateId 1~2
            int  randomGateAppId = RandomHelper.RandomNumber(0, StartConfigComponent.Instance.GateConfigs.Count) + 1;
            long time            = TimeHelper.ClientNowSeconds();

            //1540 2822 75   时间为10位数
            //区号取第11位数
            return(randomGateAppId * 100000000000 + time + ++value);
        }
Ejemplo n.º 9
0
        protected override void Run(Session session, C2G_HeartBeat message, Action <G2C_HeartBeat> reply)
        {
            Log.Info($"收到心跳");
            if (session.GetComponent <HeartBeatComponent>() != null)
            {
                session.GetComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
            }

            reply(new G2C_HeartBeat());
        }
        protected override async ETTask Run(Session session, C2G_HeartBeat message, G2C_HeartBeat response, Action reply)
        {
            if (session.GetComponent <HeartBeatComponent>() != null)
            {
                session.GetComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
            }

            reply();
            await ETTask.CompletedTask;
        }
Ejemplo n.º 11
0
 protected override void Run(Session session, C2R_HeartBeat message, Action <R2C_HeartBeat> reply)
 {
     if (session.GetComponent <HeartBeatComponent>() != null)
     {
         session.GetComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
     }
     Log.Info("心跳更新ID:" + session.Id);
     reply(new R2C_HeartBeat()
     {
     });
 }
Ejemplo n.º 12
0
        protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response, Action reply)
        {
            GateSessionKeyComponent gateSessionKeyComponent = Game.Scene.GetComponent <GateSessionKeyComponent>();
            //从已经分发的KEY里面寻找,如果没找到,说明非法用户,不给他连接gate服务器
            long playerID = gateSessionKeyComponent.Get(request.Key);

            if (playerID == 0)
            {
                response.Error   = ErrorCode.ERR_ConnectGateKeyError;
                response.Message = "Gate key验证失败!";
                reply();
                return;
            }

            //Key失效
            gateSessionKeyComponent.Remove(request.Key);

            //专门给这个玩家创建一个Player对象
            Player player = ComponentFactory.Create <Player, long>(playerID);

            player.AddComponent <UnitGateComponent, long>(session.InstanceId);

            //注册到PlayerComponent,方便管理
            Game.Scene.GetComponent <PlayerComponent>().Add(player);

            //给这个session安排上Player
            session.AddComponent <SessionPlayerComponent>().Player = player;

            // 增加掉线组件
            session.AddComponent <SessionOfflineComponent>();

            // 增加心跳包
            session.AddComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();

            //添加邮箱组件表示该session是一个Actor,接收的消息将会队列处理
            await session.AddComponent <MailBoxComponent, string>(MailboxType.GateSession).AddLocation();

            Log.Info($"gate的actorid为{session.Id}");
            //向登录服务器发送玩家上线消息
            StartConfigComponent config          = Game.Scene.GetComponent <StartConfigComponent>();
            IPEndPoint           realmIPEndPoint = config.RealmConfig.GetComponent <InnerConfig>().IPEndPoint;
            Session realmSession = Game.Scene.GetComponent <NetInnerComponent>().Get(realmIPEndPoint);

            await realmSession.Call(new G2R_PlayerOnline()
            {
                PlayerIDInPlayerComponent = player.Id, PlayerId = player.PlayerID, GateAppID = config.StartConfig.AppId
            });

            //Log.Info("发送离线消息完毕");

            //回复客户端的连接gate服务器请求
            reply();
            await ETTask.CompletedTask;
        }
Ejemplo n.º 13
0
        public async void Awake(long waitTime, Session _sessionWrap, Action action)
        {
            this.PingBackCall = action;

            var timerComponent = ETModel.Game.Scene.GetComponent <TimerComponent>();

            this._session = _sessionWrap;

            IsRun = true;

            while (IsRun)
            {
                try
                {
                    if (this._session == null)
                    {
                        Game.Scene.RemoveComponent <PingComponent>();

                        this.PingBackCall?.Invoke();

                        Debug.Log("超时断线了");

                        Game.EventSystem.Run(EventIdType.HeartBeatTimeOut);

                        break;
                    }

                    _sendTimer = TimeHelper.ClientNowSeconds();

                    await _session.Call(_request);

                    _receiveTimer = TimeHelper.ClientNowSeconds();

                    // 计算延时

                    Ping = ((_receiveTimer - _sendTimer) / 2) < 0 ? 0 : (_receiveTimer - _sendTimer) / 2;
                }
                catch (Exception)
                {
                    this._session = null;

                    Game.Scene.RemoveComponent <PingComponent>();

                    this.PingBackCall?.Invoke();

                    Debug.Log("异常断线了");

                    Game.EventSystem.Run(EventIdType.HeartBeatTimeOut);
                }

                await timerComponent.WaitAsync(waitTime);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 小怪巡逻
        /// </summary>
        /// <param name="self"></param>
        public static void UpdatePatrol(this PatrolComponent self)
        {
            if (self.isIdle)
            {
                //开始休息 4秒
                if (!self.startNull)
                {
                    self.startTime = TimeHelper.ClientNowSeconds();
                    self.startNull = true;
                }
                long timeNow = TimeHelper.ClientNowSeconds();
                if ((timeNow - self.startTime) > self.idleResTime)
                {
                    self.startNull   = false;
                    self.isStartWalk = true;
                    self.isIdle      = false;
                }
            }
            else
            {
                //发送坐标,开始行走,开始发送巡逻目标点坐标
                if (self.isStartWalk)
                {
                    self.SendPatrolPosition();
                    self.isStartWalk = false;
                }

                //如果到达目标点,开始休息,并计时4秒后 重置巡逻目标点
                float sqr = SqrDistanceComponentHelper.Distance(self.GetParent <Unit>().Position, self.goalPoint);
                if (sqr < 0.1f)
                {
                    self.isStartWalk = true;
                    self.isIdle      = true;
                    self.patolNull   = false;
                }

                //如果卡住在地图到达不了目标点 此计时40秒后 重置巡逻目标点
                if (!self.patolNull)
                {
                    self.patolTimer = TimeHelper.ClientNowSeconds();
                    self.patolNull  = true;
                }
                long timeNow = TimeHelper.ClientNowSeconds();
                if ((timeNow - self.patolTimer) > self.lifeCdTime)
                {
                    self.patolNull   = false;
                    self.isStartWalk = true;
                }
            }
        }
Ejemplo n.º 15
0
        protected override void Run(Session session, R2G_GetLoginKey message, Action <G2R_GetLoginKey> reply)
        {
            G2R_GetLoginKey response = new G2R_GetLoginKey();

            try
            {
                long key = RandomHelper.RandInt64();
                Game.Scene.GetComponent <GateSessionKeyComponent>().Add(key, message.userId);
                response.Key = key;

                session.AddComponent <HeartTickComponent>().CurrentTime = TimeHelper.ClientNowSeconds();

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Ejemplo n.º 16
0
        protected override async void Run(Session session, C2G_HeartBeat message, Action <G2C_HeartBeat> reply)
        {
            G2C_HeartBeat response = new G2C_HeartBeat();

            try
            {
                if (session.GetComponent <HeartBeatComponent>() != null)
                {
                    session.GetComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
                }
//                Log.Info("服务端发送心跳包");
                reply(response);
            }
            catch (Exception e)
            {
                Log.Debug(e.ToString());
                ReplyError(response, e, reply);
            }
        }
Ejemplo n.º 17
0
        public void Update()
        {
            long currSecond = TimeHelper.ClientNowSeconds();

            long passTime = currSecond - _recordDeltaTime;

            // 如果没有到达发包时间、直接返回
            if (!(passTime > UpdateInterval) || CurrentTime == 0)
            {
                return;
            }
            // 记录当前时间
            this._recordDeltaTime = currSecond;
            if ((currSecond - CurrentTime) > OutInterval)
            {
                // 移除Session
                Game.Scene.GetComponent <NetOuterComponent>().Remove(this.Entity.Id);
                Game.Scene.GetComponent <NetInnerComponent>().Remove(this.Entity.Id);
            }
        }
Ejemplo n.º 18
0
        public void Update()
        {
            // 如果没有到达发包时间、直接返回
            if (((TimeHelper.ClientNowSeconds() - this._recordDeltaTime) < this.UpdateInterval) || CurrentTime == 0)
            {
                return;
            }


            // 记录当前时间
            this._recordDeltaTime = TimeHelper.ClientNowSeconds();

            if ((TimeHelper.ClientNowSeconds() - CurrentTime) > OutInterval)
            {
                // 移除Session
                Log.Info("断开操作");

                //this.Parent.Dispose()
                //Game.Scene.GetComponent<NetOuterComponent>().Remove(this.Entity.GetComponent<Session>().Id);
                //Game.Scene.GetComponent<NetInnerComponent>().Remove(this.Entity.GetComponent<Session>().Id);
                //Game.Scene.GetComponent<GateSessionKeyComponent>().Remove(this.Entity.GetComponent<Session>().Id);
                Game.Scene.GetComponent <NetOuterComponent>().Remove(this.Parent.InstanceId);
                Game.Scene.GetComponent <NetInnerComponent>().Remove(this.Parent.InstanceId);
                Game.Scene.GetComponent <GateSessionKeyComponent>().Remove(this.Parent.InstanceId);
                this.Dispose();
                if (this.Entity.GetComponent <Session>() != null)
                {
                    this.Entity.GetComponent <Session>().Dispose();
                }
            }
            //每次检测Session

            //// 移除Session
            //Game.Scene.GetComponent<NetOuterComponent>().Remove(this.Parent.InstanceId);
            //Game.Scene.GetComponent<NetInnerComponent>().Remove(this.Parent.InstanceId);
            //Game.Scene.GetComponent<GateSessionKeyComponent>().Remove(this.Parent.InstanceId);
        }
Ejemplo n.º 19
0
        public async ETVoid Awake()
        {
            TimerComponent tiemr   = ETModel.Game.Scene.GetComponent <TimerComponent>();
            Session        session = this.GetParent <Session>();

            this.isStart = true;
            int connectCount = 0;

            while (isStart)
            {
                try
                {
                    //服务器太久没有接收到心跳,会踢掉客户端
                    _sendTimer = TimeHelper.ClientNowSeconds();
                    await session.Call(_request);

                    _receviceTimer = TimeHelper.ClientNowSeconds();
                    long time = (_receviceTimer - _sendTimer) / 2;
                    ping = time < 0 ? -1 : time;
                    if (ping == -1)
                    {
                        this.ReConnect(connectCount < 2);
                        connectCount++;
                        Log.Debug("Ping断线了");
                    }
                }
                catch (Exception e)
                {
                    //重连两次,或者弹窗跳到登录框界面
                    this.ReConnect(connectCount < 2);
                    connectCount++;
                    Log.Debug($"Ping异常(在这里重连):{e.Message}");
                }
                await tiemr.WaitAsync(interval);
            }
        }
Ejemplo n.º 20
0
        public static long GenerateId64()
        {
            var time = TimeHelper.ClientNowSeconds();

            return((AppId << 48) + (time << 16) + ++value);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 初始化时间
 /// </summary>
 public void InitTime()
 {
     Time      = DateTime.Now.ToString();//Debug.Log( DateTime.Now.ToString("yyyyMMdd_HH"));//年月日格式     20190604_10
     TimeTicks = TimeHelper.ClientNowSeconds();
 }
Ejemplo n.º 22
0
        public static long GenerateID()
        {
            long time = TimeHelper.ClientNowSeconds();

            return((appID << 48) + (time << 16) + ++value);
        }
Ejemplo n.º 23
0
        protected override async void Run(Session session, C2G_LoginGate message, Action <G2C_LoginGate> reply)
        {
            G2C_LoginGate response = new G2C_LoginGate();

            try
            {
                long userId = Game.Scene.GetComponent <NjmjGateSessionKeyComponent>().Get(message.Key);
                if (userId == 0)
                {
                    response.Error   = ErrorCode.ERR_ConnectGateKeyError;
                    response.Message = "Gate key验证失败!";
                    reply(response);
                    return;
                }

                // 检测是否已存在
                UserComponentSystem.CheckIsExistTheUser(userId);

                //创建User对象
                User user = UserFactory.Create(userId, session);
                await user.AddComponent <MailBoxComponent>().AddLocation();

                //添加心跳包
                session.AddComponent <HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
                //添加User对象关联到Session上
                session.AddComponent <SessionUserComponent>().User = user;

                //添加消息转发组件
                session.AddComponent <MailBoxComponent, string>(ActorType.GateSession);

                response.PlayerId = user.Id;
                response.Uid      = userId;

                ConfigComponent  configCom      = Game.Scene.GetComponent <ConfigComponent>();
                DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

                {
                    //商城
                    if (ShopData.getInstance().getDataList().Count == 0)
                    {
                        List <ShopConfig> shopList = new List <ShopConfig>();
                        for (int i = 1; i < configCom.GetAll(typeof(ShopConfig)).Length + 1; ++i)
                        {
                            int        id     = 1000 + i;
                            ShopConfig config = (ShopConfig)configCom.Get(typeof(ShopConfig), id);
                            shopList.Add(config);
                        }
                        ShopData.getInstance().getDataList().AddRange(shopList);
                    }

                    //#region AddShopInfo
                    List <ShopInfo> shopInfoList = new List <ShopInfo>();
                    for (int i = 0; i < ShopData.getInstance().getDataList().Count; ++i)
                    {
                        ShopConfig config = ShopData.getInstance().getDataList()[i];
                        ShopInfo   info   = new ShopInfo();
                        info.Id           = (int)config.Id;
                        info.Name         = config.Name;
                        info.Price        = config.Price;
                        info.ShopType     = config.shopType;
                        info.Desc         = config.Desc;
                        info.CurrencyType = config.CurrencyType;
                        info.Items        = config.Items;
                        info.Icon         = config.Icon;
                        info.VipPrice     = config.VipPrice;
                        shopInfoList.Add(info);
                    }
                    response.ShopInfoList = shopInfoList;
                }
                {
                    //任务
                    if (TaskData.getInstance().getDataList().Count == 0)
                    {
                        List <TaskConfig> taskList = new List <TaskConfig>();
                        for (int i = 1; i < configCom.GetAll(typeof(TaskConfig)).Length + 1; ++i)
                        {
                            int        id     = 100 + i;
                            TaskConfig config = (TaskConfig)configCom.Get(typeof(TaskConfig), id);
                            taskList.Add(config);
                        }
                        TaskData.getInstance().getDataList().AddRange(taskList);
                    }
                }

                {
                    //成就
                    if (ChengjiuData.getInstance().getDataList().Count == 0)
                    {
                        List <ChengjiuConfig> chengjiuList = new List <ChengjiuConfig>();
                        for (int i = 1; i < configCom.GetAll(typeof(ChengjiuConfig)).Length + 1; ++i)
                        {
                            int            id     = 100 + i;
                            ChengjiuConfig config = (ChengjiuConfig)configCom.Get(typeof(ChengjiuConfig), id);
                            chengjiuList.Add(config);
                        }
                        ChengjiuData.getInstance().getDataList().AddRange(chengjiuList);
                    }
                }

                List <UserBag> bagInfoList = await proxyComponent.QueryJson <UserBag>($"{{UId:{userId}}}");

                response.BagList = new List <Bag>();
                List <Bag> bagList = new List <Bag>();
                for (int i = 0; i < bagInfoList.Count; ++i)
                {
                    Bag bag = new Bag();
                    bag.ItemId = bagInfoList[i].BagId;
                    bag.Count  = bagInfoList[i].Count;
                    bagList.Add(bag);
                }
                response.BagList = bagList;

                PlayerBaseInfo playerBaseInfo = await DBCommonUtil.getPlayerBaseInfo(userId);

                // 老用户检测
                {
                    try
                    {
                        AccountInfo accountInfo = await DBCommonUtil.getAccountInfo(userId);

                        if (accountInfo.OldAccountState == 1)
                        {
                            string url = "http://fksq.hy51v.com:10086/CheckIsOldUser?machine_id=" + accountInfo.MachineId + "&game_id=217";
                            string str = HttpUtil.GetHttp(url);
                            Log.Debug("web地址:" + url);
                            Log.Debug("判断是否是老用户:" + str);

                            JObject result  = JObject.Parse(str);
                            string  old_uid = (string)result.GetValue("old_uid");

                            // 不是老用户
                            if (string.IsNullOrEmpty(old_uid))
                            {
                                accountInfo.OldAccountState = 3;
                                await proxyComponent.Save(accountInfo);
                            }
                            // 是老用户
                            else
                            {
                                List <Log_OldUserBind> log_OldUserBinds = await proxyComponent.QueryJson <Log_OldUserBind>($"{{macId:'{accountInfo.MachineId}'}}");

                                if (log_OldUserBinds.Count > 0)
                                {
                                    accountInfo.OldAccountState = 3;
                                    await proxyComponent.Save(accountInfo);
                                }
                                else
                                {
                                    accountInfo.OldAccountState = 2;
                                    await proxyComponent.Save(accountInfo);

                                    // 记录绑定日志
                                    {
                                        Log_OldUserBind log_OldUserBind = ComponentFactory.CreateWithId <Log_OldUserBind>(IdGenerater.GenerateId());
                                        log_OldUserBind.Uid          = userId;
                                        log_OldUserBind.OldUid       = old_uid;
                                        log_OldUserBind.macId        = accountInfo.MachineId;
                                        log_OldUserBind.isSendReward = 1;

                                        await proxyComponent.Save(log_OldUserBind);
                                    }

                                    {
                                        url = ("http://fksq.hy51v.com:10086/GetOldNjmjData?UserId=" + old_uid);
                                        str = HttpUtil.GetHttp(url);

                                        result = JObject.Parse(str);
                                        int moneyAmount  = (int)result.GetValue("moneyAmount");
                                        int gIngotAmount = (int)result.GetValue("gIngotAmount");

                                        Log.Debug("老用户金币=" + moneyAmount + "   元宝=" + gIngotAmount);

                                        playerBaseInfo.GoldNum = moneyAmount;
                                        playerBaseInfo.WingNum = gIngotAmount;
                                        await proxyComponent.Save(playerBaseInfo);

                                        await DBCommonUtil.changeWealthWithStr(userId, "111:10;2:10", "老用户赠送");
                                    }

                                    // 发送老用户广播
                                    Actor_OldUser actor_OldUser = new Actor_OldUser();
                                    actor_OldUser.OldAccount = old_uid;
                                    Game.Scene.GetComponent <UserComponent>().BroadCastToSingle(actor_OldUser, userId);
                                }
                            }
                        }
                        else if (accountInfo.OldAccountState == 2)
                        {
                            List <Log_OldUserBind> log_OldUserBinds = await proxyComponent.QueryJson <Log_OldUserBind>($"{{macId:'{accountInfo.MachineId}'}}");

                            if (log_OldUserBinds.Count > 0)
                            {
                                if (log_OldUserBinds[0].isSendReward != 1)
                                {
                                    log_OldUserBinds[0].isSendReward = 1;
                                    await proxyComponent.Save(log_OldUserBinds[0]);

                                    await DBCommonUtil.SendMail(userId, "更新游戏奖励", "亲爱的玩家,南京麻将最新版本更新了,特意送上更新奖励,请笑纳,祝您游戏愉快!", "111:10;2:10");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("检测是否是老用户出错:" + ex);
                    }
                }

                #region 用户活动所获得的头像数据
                List <OtherData> otherDatas = await proxyComponent.QueryJson <OtherData>($"{{UId:{userId}}}");

                if (otherDatas.Count > 0)
                {
                    response.ownIcon = otherDatas[0].OwnIcon;
                }
                #endregion

                reply(response);
                session.Send(new G2C_TestHotfixMessage()
                {
                    Info = "recv hotfix message success"
                });

                // vip上线全服广播
                {
                    if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0)
                    {
                        Actor_LaBa actor_LaBa = new Actor_LaBa();
                        actor_LaBa.LaBaContent = "贵族玩家" + playerBaseInfo.Name + "上线啦!";
                        Game.Scene.GetComponent <UserComponent>().BroadCast(actor_LaBa);
                    }
                }
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Ejemplo n.º 24
0
        public static ulong GenerateId()
        {
            long time = TimeHelper.ClientNowSeconds();

            return((AppId << 48) + ((ulong)time << 16) + ++value);
        }
Ejemplo n.º 25
0
        public static long GenerateId()
        {
            long time = TimeHelper.ClientNowSeconds();

            return(Head + (time << 18) + ++value);
        }