Esempio n. 1
0
        /// <summary>
        /// 大波开始刷怪前,挑选路线,初始化刷怪列表,计算本波的最大大波间隔
        /// </summary>
        /// <param name="scene"></param>
        public static void InitNextWaveMonsterList(LuoLanFaZhenCopySence scene)
        {
            if (scene.m_CreateMonsterWave >= 0 && scene.m_CreateMonsterWave < LuoLanFaZhenCopySencedata.TotalWave)
            {
                int delay2   = 1;
                int totalNum = 0;

                scene.m_CreateWaveMonsterList.Clear();
                foreach (var m in LuoLanFaZhenCopySencedata.EMoLaiXiCopySenceMonsterData)
                {
                    if (m.m_Wave == scene.m_CreateMonsterWave + 1)
                    {
                        LuoLanFaZhenCopySenceMonster em = null;// m.CloneMini();
                        scene.m_CreateWaveMonsterList.Add(em);

                        int random = Global.GetRandomNumber(0, em.PathIDArray.Length);
                        int pathID = em.PathIDArray[random];
                        em.PatrolPath = LuoLanFaZhenCopySencedata.m_MonsterPatorlPathLists[pathID];
                        delay2        = Global.GMax(delay2, em.m_Delay2);
                        totalNum     += em.m_Num;
                    }
                }

                scene.m_Delay2                    = delay2;
                scene.m_TotalMonsterCount         = totalNum;
                scene.m_TotalMonsterCountAllWave += totalNum;
            }
        }
Esempio n. 2
0
        /// <summary>
        // 玩家登陆后进入金币副本
        /// </summary>
        public static bool EnterLuoLanFaZhenCopySenceWhenLogin(GameClient client, bool bContinue = true)
        {
            if (client != null)
            {
                CopyMap tmp = null;
                LuoLanFaZhenCopySence LuoLanFaZhenCopySenceInfo = null;

                lock (m_LuoLanFaZhenCopySceneLists)
                {
                    if (!m_LuoLanFaZhenCopySceneLists.TryGetValue(client.ClientData.FuBenSeqID, out tmp) || tmp == null)
                    {
                        return(false);
                    }
                }

                lock (m_LuoLanFaZhenCopySceneInfo)
                {
                    if (!m_LuoLanFaZhenCopySceneInfo.TryGetValue(client.ClientData.FuBenSeqID, out LuoLanFaZhenCopySenceInfo) || LuoLanFaZhenCopySenceInfo == null)
                    {
                        return(false);
                    }
                }

                if (LuoLanFaZhenCopySenceInfo.m_bFinished)
                {
                    return(false);
                }

                long ticks = TimeUtil.NOW();    // 当前tick
                LuoLanFaZhenCopySenceInfo.m_LoginEnterTimer = ticks;
                LuoLanFaZhenCopySenceInfo.m_LoginEnterFlag  = 1;

                /*if (bContinue == false)
                 * {
                 *  return true;
                 * }
                 *
                 * int fuBenID = FuBenManager.FindFuBenIDByMapCode(client.ClientData.MapCode);
                 * if (fuBenID > 0)
                 * {
                 *  List<GameClient> clientsList = tmp.GetClientsList();
                 *
                 *  if (clientsList.Count() != 0 && clientsList[0] != null)
                 *  {
                 *      string strcmd = string.Format("{0}:{1}", LuoLanFaZhenCopySenceInfo.m_CreateMonsterWave, Data.LuoLanFaZhenCopySencedata.LuoLanFaZhenCopySenceMonsterData.Count());//1.当前的波数 2.总波数
                 *      //TCPOutPacket tcpOutPacket = null;
                 *      //tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(Global._TCPManager.TcpOutPacketPool, strcmd, (int)TCPGameServerCmds.CMD_SPR_LuoLanFaZhenCopySenceMONSTERWAVE);
                 *      //Global._TCPManager.MySocketListener.SendData(clientsList[0].ClientSocket, tcpOutPacket);
                 *      GameManager.ClientMgr.SendToClient(clientsList[0], strcmd, (int)TCPGameServerCmds.CMD_SPR_LuoLanFaZhenCopySenceMONSTERWAVE);
                 *  }
                 * }*/

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public static void AddLuoLanFaZhenCopySceneList(int nID, CopyMap mapInfo)
        {
            bool bInsert = false;

            lock (m_LuoLanFaZhenCopySceneLists)
            {
                CopyMap tmp = null;

                if (!m_LuoLanFaZhenCopySceneLists.TryGetValue(nID, out tmp))
                {
                    m_LuoLanFaZhenCopySceneLists.Add(nID, mapInfo);
                    bInsert = true;
                }
                else
                {
                    if (tmp == null)
                    {
                        m_LuoLanFaZhenCopySceneLists[nID] = mapInfo;
                        bInsert = true;
                    }
                }

                lock (m_LuoLanFaZhenCopySceneInfo)
                {
                    if (bInsert == true)
                    {
                        LuoLanFaZhenCopySence LuoLanFaZhenCopySenceInfo = null;

                        if (!m_LuoLanFaZhenCopySceneInfo.TryGetValue(nID, out LuoLanFaZhenCopySenceInfo))
                        {
                            LuoLanFaZhenCopySenceInfo = new LuoLanFaZhenCopySence();

                            LuoLanFaZhenCopySenceInfo.InitInfo(mapInfo.MapCode, mapInfo.CopyMapID, nID);

                            LuoLanFaZhenCopySenceInfo.m_StartTimer = TimeUtil.NOW();

                            m_LuoLanFaZhenCopySceneInfo.Add(nID, LuoLanFaZhenCopySenceInfo);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 处理刷怪,失败等活动逻辑
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="clientList"></param>
        /// <param name="copyMap"></param>
        /// <param name="nowTicks"></param>
        public static void OnSceneTimer(LuoLanFaZhenCopySence scene, List <GameClient> clientList, CopyMap copyMap, long nowTicks)
        {
            int nWave  = scene.m_CreateMonsterWave;
            int nCount = LuoLanFaZhenCopySencedata.TotalWave;

            bool notifyWaveAndNum = false;
            bool notifyEnd        = false;
            int  escapeCount      = GetEscapeCount(scene.m_CopyMapID);

            if (escapeCount > 0)
            {
                scene.m_EscapedMonsterNum += escapeCount;
                notifyWaveAndNum           = true;
            }

            if (scene.m_LoginEnterFlag == 1)
            {
                if (nowTicks - scene.m_LoginEnterTimer > m_DelayTime)
                {
                    scene.m_LoginEnterFlag = 0;
                    notifyWaveAndNum       = true;
                }
            }

            if (scene.m_EscapedMonsterNum >= LuoLanFaZhenCopySencedata.FaildEscapeMonsterNum)
            {
                if (!scene.m_bFinished)
                {
                    GameManager.CopyMapMgr.CopyMapFaildForAll(clientList, copyMap);
                    scene.m_bFinished = true;
                }
                GameManager.CopyMapMgr.KillAllMonster(copyMap);
                notifyWaveAndNum = true;
            }
            else if (scene.m_bAllMonsterCreated)
            {
                if (!scene.m_bFinished)
                {
                    if (copyMap.KilledDynamicMonsterNum + scene.m_EscapedMonsterNum >= scene.m_TotalMonsterCountAllWave)
                    {
                        if (null != clientList && clientList.Count > 0)
                        {
                            notifyWaveAndNum = true;
                            GameManager.CopyMapMgr.CopyMapPassAwardForAll(clientList[0], copyMap, true);
                            scene.m_bFinished = true;

                            if (copyMap.KilledDynamicMonsterNum > copyMap.TotalDynamicMonsterNum)
                            {
                                try
                                {
                                    string log = string.Format("恶魔来袭已成功,但杀怪计数异常,结束时间{0},KilledDynamicMonsterNum:{1},m_EscapedMonsterNum:{2},m_TotalMonsterCountAllWave:{3}",
                                                               new DateTime(nowTicks * 10000), copyMap.KilledDynamicMonsterNum, scene.m_EscapedMonsterNum, scene.m_TotalMonsterCountAllWave);
                                    LogManager.WriteLog(LogTypes.Error, log);
                                } catch { }
                            }
                        }
                    }
                }
            }
            else
            {
                // 延迟间隔判断
                if (nowTicks - scene.m_CreateMonsterTick2 > scene.m_Delay2 * 1000)       // 大波间隔时间判断
                {
                    if (scene.m_CreateMonsterWaveNotify == 0)
                    {
                        scene.m_CreateMonsterWaveNotify = 1;
                        notifyWaveAndNum = true;
                    }

                    //刷怪
                    for (int i = 0; i < scene.m_CreateWaveMonsterList.Count; i++)
                    {
                        LuoLanFaZhenCopySenceMonster tmpInfo = scene.m_CreateWaveMonsterList[i];

                        if (tmpInfo.m_CreateMonsterCount < tmpInfo.m_Num)
                        {
                            if (nowTicks - tmpInfo.m_CreateMonsterTick1 > tmpInfo.m_Delay1 * 1000)   // 小波间隔时间判断
                            {
                                // 怪在列表中的索引
                                int nIndex = tmpInfo.m_CreateMonsterCount;

                                // 在起点刷怪
                                int[] pos = tmpInfo.PatrolPath[0];
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_MapCodeID, tmpInfo.m_MonsterID[nIndex], scene.m_CopyMapID, 1, pos[0], pos[1], 0, 0, SceneUIClasses.EMoLaiXiCopy, tmpInfo.PatrolPath);

                                tmpInfo.m_CreateMonsterCount++;
                                scene.m_CreateMonsterCount++;

                                tmpInfo.m_CreateMonsterTick1 = nowTicks; // 小波刷怪时间设定
                            }
                        }
                    }

                    // 第N大波刷完了
                    if (scene.m_CreateMonsterCount >= scene.m_TotalMonsterCount)
                    {
                        scene.m_CreateMonsterTick2 = nowTicks; // 设定大波刷完时间
                        scene.m_CreateMonsterWave++;
                        scene.m_CreateMonsterCount      = 0;
                        scene.m_CreateMonsterWaveNotify = 0;
                        scene.m_Delay2   = 0;
                        notifyWaveAndNum = true;
                        copyMap.TotalDynamicMonsterNum = scene.m_TotalMonsterCountAllWave;
                        if (scene.m_CreateMonsterWave >= LuoLanFaZhenCopySencedata.TotalWave)
                        {
                            scene.m_Delay2             = int.MaxValue;
                            scene.m_bAllMonsterCreated = true;
                            notifyEnd = true;
                        }
                    }
                }
            }

            if (notifyWaveAndNum)
            {
                SendMsgToClientForLuoLanFaZhenCopySceneMonsterWave(clientList, scene.m_EscapedMonsterNum, scene.m_CreateMonsterWave, LuoLanFaZhenCopySencedata.TotalWave, LuoLanFaZhenCopySencedata.FaildEscapeMonsterNum);
            }
            if (notifyEnd && null != clientList)
            {
                foreach (var client in clientList)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("恶魔来袭副本 刷怪结束了")), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, (int)HintErrCodeTypes.None);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public static void HeartBeatLuoLanFaZhenCopyScene()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks - LastHeartBeatTicks < TimeUtil.SECOND)
            {
                return;
            }

            LastHeartBeatTicks = nowTicks;

            // lock住!!!
            lock (m_LuoLanFaZhenCopySceneLists)
            {
                foreach (var item in m_LuoLanFaZhenCopySceneLists.Values)
                {
                    LuoLanFaZhenCopySence scene = null;

                    lock (m_LuoLanFaZhenCopySceneInfo)
                    {
                        if (!m_LuoLanFaZhenCopySceneInfo.TryGetValue(item.FuBenSeqID, out scene))
                        {
                            continue;
                        }

                        //tmpLuoLanFaZhenCopySenceData = m_LuoLanFaZhenCopySceneInfo[item.FuBenSeqID];
                    }

                    if (scene == null)
                    {
                        continue;
                    }

                    List <GameClient> clientsList = item.GetClientsList();
                    lock (scene)
                    {
                        if (scene.m_TimeNotifyFlag == 0)
                        {
                            //准备刷怪倒计时
                            if (nowTicks <= (scene.m_StartTimer + m_PrepareTime - TimeUtil.SECOND * (int)CountDownWindowTypes.ConstMaxNumber))
                            {
                                continue;
                            }
                            scene.m_TimeNotifyFlag = 1;

                            //格式: (roleID):窗口类型:参数1秒数:参数2类型:参数3文本
                            string msgCmd = string.Format("{0}:{1}${2}${3}", (int)ServerNotifyOpenWindowTypes.CountDownWindow, (int)CountDownWindowTypes.ConstMaxNumber, (int)CountDownWindowTypes.NumberOnly, "");
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFYOPENWINDOW, msgCmd, clientsList, true);
                        }

                        if (nowTicks >= (scene.m_StartTimer + m_PrepareTime))
                        {
                            if (scene.m_Delay2 > 0)
                            {
                                //战斗时间
                                OnSceneTimer(scene, clientsList, item, nowTicks);
                            }
                            else
                            {
                                InitNextWaveMonsterList(scene);
                            }
                        }
                    }
                }
            }
        }