Пример #1
0
        /// <summary>
        // 心跳处理
        /// </summary>
        static public void HeartBeatDaimonSquareScene()
        {
            foreach (var DaimonSquareScenes in m_DaimonSquareListScenes)
            {
                DaimonSquareDataInfo bcDataTmp = Data.DaimonSquareDataInfoList[DaimonSquareScenes.Key];
                DaimonSquareScene    bcTmp     = GetDaimonSquareListScenes(DaimonSquareScenes.Key);
                if (bcTmp == null || bcDataTmp == null)
                {
                    continue;
                }

                int nRoleNum = 0;
                nRoleNum = GameManager.ClientMgr.GetMapClientsCount(bcTmp.m_nMapCode);
                if (nRoleNum <= 0)
                {
                    if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_BEGIN)
                    {
                        // 做清空处理  比如 所有动态刷出的怪 都delete掉
                        CleanDaimonSquareScene(bcTmp.m_nMapCode);
                        bcTmp.CleanAllInfo();
                        bcTmp.m_nMapCode = DaimonSquareScenes.Key;
                    }
                    //continue;
                }

                // 当前tick
                long ticks = DateTime.Now.Ticks / 10000;

                if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_NULL)
                {
                    bool bPushMsg = false;

                    if (Global.CanEnterDaimonSquareOnTime(bcDataTmp.BeginTime, 0))
                    {
                        // 场景开启
                        bcTmp.m_eStatus           = DaimonSquareStatus.FIGHT_STATUS_PREPARE;
                        bcTmp.m_lPrepareTime      = DateTime.Now.Ticks / 10000;
                        bcTmp.m_nMonsterTotalWave = bcDataTmp.MonsterID.Length;

                        // 消息推送
                        if (bPushMsg)
                        {
                            int nNow = DateTime.Now.DayOfYear;

                            if (bPushMsg && m_nPushMsgDayID != nNow)
                            {
                                //Global.DayActivityTiggerPushMessage((int)SpecialActivityTypes.DemoSque);

                                Global.UpdateDBGameConfigg(GameConfigNames.DemoSquarePushMsgDayID, nNow.ToString());

                                m_nPushMsgDayID = nNow;
                            }
                        }
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_PREPARE)
                {
                    if (ticks >= (bcTmp.m_lPrepareTime + (bcDataTmp.PrepareTime * 1000)))
                    {
                        // 准备战斗
                        bcTmp.m_eStatus = DaimonSquareStatus.FIGHT_STATUS_BEGIN;

                        bcTmp.m_lBeginTime = DateTime.Now.Ticks / 10000;
                        int nTimer = (int)((bcDataTmp.DurationTime * 1000 - (ticks - bcTmp.m_lBeginTime)) / 1000);

                        GameManager.ClientMgr.NotifyDaimonSquareMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                    (int)TCPGameServerCmds.CMD_SPR_QUERYDAIMONSQUARETIMERINFO, (int)DaimonSquareStatus.FIGHT_STATUS_BEGIN, nTimer, 0, 0, 0); // 战斗结束倒计时
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_BEGIN)
                {
                    // 开始战斗 -- 刷怪
                    if (bcTmp.m_nCreateMonsterFlag == 0 && bcTmp.m_nMonsterWave < bcTmp.m_nMonsterTotalWave)
                    {
                        DaimonSquareSceneCreateMonster(bcTmp, bcDataTmp);
                    }

                    if (ticks >= (bcTmp.m_lBeginTime + (bcDataTmp.DurationTime * 1000)) || bcTmp.m_nKillMonsterTotalNum == bcDataTmp.MonsterSum)
                    {
                        bcTmp.m_eStatus  = DaimonSquareStatus.FIGHT_STATUS_END;
                        bcTmp.m_lEndTime = DateTime.Now.Ticks / 10000;
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_END)
                {
                    // 战斗结束

                    int nTimer = (int)((bcDataTmp.LeaveTime * 1000 - (ticks - bcTmp.m_lEndTime)) / 1000);

                    if (bcTmp.m_bEndFlag == false)
                    {
                        GameManager.ClientMgr.NotifyDaimonSquareMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                    (int)TCPGameServerCmds.CMD_SPR_QUERYDAIMONSQUARETIMERINFO, (int)DaimonSquareStatus.FIGHT_STATUS_END, nTimer, 0, 0, 0);

                        // 剩余时间奖励
                        long nTimeInfo = 0;
                        nTimeInfo = bcTmp.m_lEndTime - bcTmp.m_lBeginTime;

                        long nRemain = 0;
                        nRemain = ((bcDataTmp.DurationTime * 1000) - nTimeInfo) / 1000;

                        if (nRemain >= bcDataTmp.DurationTime)
                        {
                            nRemain = bcDataTmp.DurationTime / 2;
                        }

                        int nTimeAward = 0;
                        nTimeAward = (int)(bcDataTmp.TimeModulus * nRemain);

                        if (nTimeAward < 0)
                        {
                            nTimeAward = 0;
                        }

                        GameManager.ClientMgr.NotifyDaimonSquareMsgEndFight(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                            (int)TCPGameServerCmds.CMD_SPR_DAIMONSQUAREENDFIGHT, nTimeAward);

                        bcTmp.m_bEndFlag = true;
                    }

                    if (ticks >= (bcTmp.m_lEndTime + (bcDataTmp.LeaveTime * 1000)))
                    {
                        // 清场
                        List <Object> objsList = GameManager.ClientMgr.GetMapClients(DaimonSquareScenes.Key);
                        if (objsList != null)
                        {
                            for (int n = 0; n < objsList.Count; ++n)
                            {
                                GameClient c = objsList[n] as GameClient;
                                if (c == null)
                                {
                                    continue;
                                }

                                if (c.ClientData.MapCode != DaimonSquareScenes.Key)
                                {
                                    continue;
                                }

                                //CompleteDaimonSquareScene(c, bcTmp, bcDataTmp);

                                // 根据公式和积分奖励经验
                                //GiveAwardDaimonSquareScene(c);

                                // 退出场景
                                int toMapCode = GameManager.MainMapCode;    //主城ID 防止意外
                                int toPosX    = -1;
                                int toPosY    = -1;
                                if (MapTypes.Normal == Global.GetMapType(c.ClientData.LastMapCode))
                                {
                                    if (GameManager.BattleMgr.BattleMapCode != c.ClientData.LastMapCode || GameManager.ArenaBattleMgr.BattleMapCode != c.ClientData.LastMapCode)
                                    {
                                        toMapCode = c.ClientData.LastMapCode;
                                        toPosX    = c.ClientData.LastPosX;
                                        toPosY    = c.ClientData.LastPosY;
                                    }
                                }

                                GameMap gameMap = null;
                                if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                {
                                    c.ClientData.bIsInDaimonSquareMap = false;
                                    GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, c, toMapCode, toPosX, toPosY, -1);
                                }
                            }
                        }

                        CleanDaimonSquareScene(DaimonSquareScenes.Key);
                        bcTmp.CleanAllInfo();
                        bcTmp.m_nMapCode = DaimonSquareScenes.Key;
                    }
                }
            }
        }
Пример #2
0
        private static int GetLeftCountByType(GameClient client, int type, int copyId)
        {
            int leftnum = 0;

            switch (type)
            {
            case 1:
            {
                DailyTaskData dailyTaskData = Global.FindDailyTaskDataByTaskClass(client, 8);
                if (null == dailyTaskData)
                {
                    return(10);
                }
                int maxnum = Global.GetMaxDailyTaskNum(client, 8, dailyTaskData);
                leftnum = maxnum - dailyTaskData.RecNum;
                goto IL_4AC;
            }

            case 5:
            {
                int nMapID = Global.GetDaimonSquareCopySceneIDForRole(client);
                DaimonSquareDataInfo bcDataTmp = null;
                Data.DaimonSquareDataInfoList.TryGetValue(nMapID, out bcDataTmp);
                int nDate  = TimeUtil.NowDateTime().DayOfYear;
                int nCount = Global.QueryDayActivityEnterCountToDB(client, client.ClientData.RoleID, nDate, 2);
                if (nCount < 0)
                {
                    nCount = 0;
                }
                int   nVipLev = client.ClientData.VipLevel;
                int   nNum    = 0;
                int[] nArry   = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPEnterDaimonSquareCountAddValue", ',');
                if (nVipLev > 0 && nArry != null && nArry[nVipLev] > 0)
                {
                    nNum = nArry[nVipLev];
                }
                leftnum = bcDataTmp.MaxEnterNum + nNum - nCount;
                goto IL_4AC;
            }

            case 6:
            {
                int nMapID = Global.GetBloodCastleCopySceneIDForRole(client);
                BloodCastleDataInfo bcDataTmp2 = null;
                if (!Data.BloodCastleDataInfoList.TryGetValue(nMapID, out bcDataTmp2))
                {
                    goto IL_4AC;
                }
                int nDate  = TimeUtil.NowDateTime().DayOfYear;
                int nType  = 1;
                int nCount = Global.QueryDayActivityEnterCountToDB(client, client.ClientData.RoleID, nDate, nType);
                if (nCount < 0)
                {
                    nCount = 0;
                }
                int   nVipLev = client.ClientData.VipLevel;
                int   nNum    = 0;
                int[] nArry   = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPEnterBloodCastleCountAddValue", ',');
                if (nVipLev > 0 && nArry != null && nArry[nVipLev] > 0)
                {
                    nNum = nArry[nVipLev];
                }
                leftnum = bcDataTmp2.MaxEnterNum + nNum - nCount;
                goto IL_4AC;
            }

            case 7:
            {
                DateTime      now            = TimeUtil.NowDateTime();
                string        nowTime        = TimeUtil.NowDateTime().ToString("HH:mm");
                List <string> timePointsList = GameManager.AngelTempleMgr.m_AngelTempleData.BeginTime;
                leftnum = 0;
                for (int i = 0; i < timePointsList.Count; i++)
                {
                    DateTime perpareTime = DateTime.Parse(timePointsList[i]).AddMinutes((double)(GameManager.AngelTempleMgr.m_AngelTempleData.PrepareTime / 60));
                    if (now <= perpareTime)
                    {
                        leftnum++;
                    }
                }
                goto IL_4AC;
            }

            case 8:
                leftnum = 1;
                if (SweepWanMotaManager.GetSweepCount(client) >= SweepWanMotaManager.nWanMoTaMaxSweepNum)
                {
                    leftnum = 0;
                }
                goto IL_4AC;

            case 9:
            {
                BufferData bufferData = Global.GetBufferDataByID(client, 34);
                leftnum = (int)(bufferData.BufferVal - (long)bufferData.BufferSecs);
                goto IL_4AC;
            }

            case 10:
                leftnum = GameManager.BattleMgr.LeftEnterCount();
                goto IL_4AC;

            case 11:
                leftnum = GameManager.ArenaBattleMgr.LeftEnterCount();
                goto IL_4AC;

            case 13:
                leftnum = JingJiChangManager.getInstance().GetLeftEnterCount(client);
                goto IL_4AC;

            case 15:
            {
                DailyTaskData dailyTaskData = Global.FindDailyTaskDataByTaskClass(client, 9);
                if (null == dailyTaskData)
                {
                    return(Global.MaxTaofaTaskNumForMU);
                }
                int maxnum = Global.GetMaxDailyTaskNum(client, 9, dailyTaskData);
                leftnum = maxnum - dailyTaskData.RecNum;
                goto IL_4AC;
            }

            case 16:
            {
                int temp = 0;
                CaiJiLogic.ReqCaiJiLastNum(client, 0, out temp);
                leftnum = temp;
                goto IL_4AC;
            }

            case 19:
                leftnum = HuanYingSiYuanManager.getInstance().GetLeftCount(client);
                goto IL_4AC;
            }
            if (copyId > 0)
            {
                SystemXmlItem systemFuBenItem = null;
                if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(copyId, out systemFuBenItem))
                {
                    return(-1);
                }
                int enternum  = systemFuBenItem.GetIntValue("EnterNumber", -1);
                int finishnum = systemFuBenItem.GetIntValue("FinishNumber", -1);
                int total     = (enternum < finishnum) ? finishnum : enternum;
                if (type == 4 || type == 3)
                {
                    int[] nAddNum = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPJinBiFuBenNum", ',');
                    if (type == 3)
                    {
                        nAddNum = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPJinYanFuBenNum", ',');
                    }
                    if (client.ClientData.VipLevel > 0 && client.ClientData.VipLevel <= VIPEumValue.VIPENUMVALUE_MAXLEVEL && nAddNum != null && nAddNum.Length > VIPEumValue.VIPENUMVALUE_MAXLEVEL)
                    {
                        total += nAddNum[client.ClientData.VipLevel];
                    }
                }
                FuBenData tmpfubdata = Global.GetFuBenData(client, copyId);
                if (null == tmpfubdata)
                {
                    return(total);
                }
                leftnum = total - tmpfubdata.EnterNum;
            }
IL_4AC:
            return(leftnum);
        }