示例#1
0
 /// <summary>
 /// 为单个离线挂机角色保存挂机时间信息
 /// </summary>
 /// <param name="liXianGuaJiRoleItem"></param>
 public static void SaveDBLiXianGuaJiTimeForRole(LiXianGuaJiRoleItem liXianGuaJiRoleItem)
 {
     GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_DB_UPDATEROLEPARAM,
                                   string.Format("{0}:{1}:{2}", liXianGuaJiRoleItem.RoleID, RoleParamName.MeditateTime, liXianGuaJiRoleItem.MeditateTime), null, GameManager.LocalServerIdForNotImplement);
     GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_DB_UPDATEROLEPARAM,
                                   string.Format("{0}:{1}:{2}", liXianGuaJiRoleItem.RoleID, RoleParamName.NotSafeMeditateTime, liXianGuaJiRoleItem.NotSafeMeditateTime), null, GameManager.LocalServerIdForNotImplement);
 }
示例#2
0
        /// <summary>
        // 处理冥想计时 [3/18/2014 LiaoWei]
        /// </summary>
        /// <param name="sl"></param>
        /// <param name="pool"></param>
        private void DoSpriteMeditateTime(LiXianGuaJiRoleItem c)
        {
            long lTicks     = 0;
            long lCurrticks = TimeUtil.NOW();

            lTicks = lCurrticks - c.MeditateTicks;

            // 每分钟计时一次
            if (lTicks < (60 * 1000))
            {
                return;
            }

            c.MeditateTicks = lCurrticks;

            // 判断是否在安全区中
            bool bIsInsafeArea = false;

            Point currentGrid = c.CurrentGrid;

            GameMap gameMap = null;

            if (GameManager.MapMgr.DictMaps.TryGetValue(c.MapCode, out gameMap))
            {
                bIsInsafeArea = gameMap.InSafeRegionList(currentGrid);
            }

            if (bIsInsafeArea)
            {
                int nTime  = c.MeditateTime;
                int nTime2 = c.NotSafeMeditateTime;
                if ((nTime + nTime2) < MaxMingXiangTicks)
                {
                    long msecs = Math.Max(lCurrticks - c.BiGuanTime, 0);
                    msecs = Math.Min(msecs + nTime, MaxMingXiangTicks - nTime2);   // 12个小时

                    c.MeditateTime = (int)msecs;
                }
            }
            else
            {
                int nTime  = c.MeditateTime;
                int nTime2 = c.NotSafeMeditateTime;

                if ((nTime + nTime2) < MaxMingXiangTicks)
                {
                    long msecs = Math.Max(lCurrticks - c.BiGuanTime, 0);
                    msecs = Math.Min(msecs + nTime2, MaxMingXiangTicks - nTime);   // 12个小时

                    c.NotSafeMeditateTime = (int)msecs;
                }
            }

            // 重置时间
            c.BiGuanTime = lCurrticks;

            return;
        }
        public static void GetBackLiXianGuaJiTime(GameClient client)
        {
            LiXianGuaJiRoleItem liXianGuaJiRoleItem = null;

            lock (LiXianGuaJiManager._LiXianRoleInfoDict)
            {
                if (LiXianGuaJiManager._LiXianRoleInfoDict.TryGetValue(client.ClientData.RoleID, out liXianGuaJiRoleItem))
                {
                    client.ClientData.MeditateTime        = liXianGuaJiRoleItem.MeditateTime;
                    client.ClientData.NotSafeMeditateTime = liXianGuaJiRoleItem.NotSafeMeditateTime;
                    Global.SaveRoleParamsInt32ValueToDB(client, "MeditateTime", client.ClientData.MeditateTime, true);
                    Global.SaveRoleParamsInt32ValueToDB(client, "NotSafeMeditateTime", client.ClientData.NotSafeMeditateTime, true);
                }
            }
        }
        public static bool DelFakeRoleByClient(GameClient client)
        {
            int fakeRoleID = -1;
            LiXianGuaJiRoleItem liXianGuaJiRoleItem = null;

            lock (LiXianGuaJiManager._LiXianRoleInfoDict)
            {
                if (!LiXianGuaJiManager._LiXianRoleInfoDict.TryGetValue(client.ClientData.RoleID, out liXianGuaJiRoleItem))
                {
                    return(false);
                }
                fakeRoleID = liXianGuaJiRoleItem.FakeRoleID;
            }
            if (fakeRoleID > 0)
            {
                FakeRoleManager.ProcessDelFakeRole(fakeRoleID, false);
            }
            return(true);
        }
        private void DoSpriteMeditateTime(LiXianGuaJiRoleItem c)
        {
            long lCurrticks = TimeUtil.NOW();
            long lTicks     = lCurrticks - c.MeditateTicks;

            if (lTicks >= 60000L)
            {
                c.MeditateTicks = lCurrticks;
                bool    bIsInsafeArea = false;
                Point   currentGrid   = c.CurrentGrid;
                GameMap gameMap       = null;
                if (GameManager.MapMgr.DictMaps.TryGetValue(c.MapCode, out gameMap))
                {
                    bIsInsafeArea = gameMap.InSafeRegionList(currentGrid);
                }
                if (bIsInsafeArea)
                {
                    int nTime  = c.MeditateTime;
                    int nTime2 = c.NotSafeMeditateTime;
                    if (nTime + nTime2 < 43200000)
                    {
                        long msecs = Math.Max(lCurrticks - c.BiGuanTime, 0L);
                        msecs          = Math.Min(msecs + (long)nTime, (long)(43200000 - nTime2));
                        c.MeditateTime = (int)msecs;
                    }
                }
                else
                {
                    int nTime  = c.MeditateTime;
                    int nTime2 = c.NotSafeMeditateTime;
                    if (nTime + nTime2 < 43200000)
                    {
                        long msecs = Math.Max(lCurrticks - c.BiGuanTime, 0L);
                        msecs = Math.Min(msecs + (long)nTime2, (long)(43200000 - nTime));
                        c.NotSafeMeditateTime = (int)msecs;
                    }
                }
                c.BiGuanTime = lCurrticks;
            }
        }
 public static void SaveDBLiXianGuaJiTimeForRole(LiXianGuaJiRoleItem liXianGuaJiRoleItem)
 {
     GameManager.DBCmdMgr.AddDBCmd(10100, string.Format("{0}:{1}:{2}", liXianGuaJiRoleItem.RoleID, "MeditateTime", liXianGuaJiRoleItem.MeditateTime), null, 0);
     GameManager.DBCmdMgr.AddDBCmd(10100, string.Format("{0}:{1}:{2}", liXianGuaJiRoleItem.RoleID, "NotSafeMeditateTime", liXianGuaJiRoleItem.NotSafeMeditateTime), null, 0);
 }