public static void InitNextWaveMonsterList(EMoLaiXiCopySence scene)
 {
     if (scene.m_CreateMonsterWave >= 0 && scene.m_CreateMonsterWave < EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.TotalWave)
     {
         int delay2   = 1;
         int totalNum = 0;
         scene.m_CreateWaveMonsterList.Clear();
         foreach (EMoLaiXiCopySenceMonster i in EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.EMoLaiXiCopySenceMonsterData)
         {
             if (i.m_Wave == scene.m_CreateMonsterWave + 1)
             {
                 EMoLaiXiCopySenceMonster em = i.CloneMini();
                 scene.m_CreateWaveMonsterList.Add(em);
                 int random = Global.GetRandomNumber(0, em.PathIDArray.Length);
                 int pathID = em.PathIDArray[random];
                 em.PatrolPath = EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.m_MonsterPatorlPathLists[pathID];
                 delay2        = Global.GMax(delay2, em.m_Delay2);
                 totalNum     += em.m_Num;
             }
         }
         scene.m_Delay2                    = (long)delay2;
         scene.m_TotalMonsterCount         = totalNum;
         scene.m_TotalMonsterCountAllWave += totalNum;
     }
 }
Beispiel #2
0
        public EMoLaiXiCopySenceMonster CloneMini()
        {
            EMoLaiXiCopySenceMonster em = new EMoLaiXiCopySenceMonster()
            {
                m_ID                 = m_ID,
                m_Wave               = m_Wave,
                PathIDArray          = PathIDArray,
                m_Num                = m_Num,
                m_MonsterID          = m_MonsterID,
                m_Delay1             = m_Delay1,
                m_CreateMonsterTick1 = m_CreateMonsterTick1,
                m_CreateMonsterCount = m_CreateMonsterCount,
                m_Delay2             = m_Delay2,
            };

            return(em);
        }
        /// <summary>
        /// 金币副本数据 [6/11/2014 LiaoWei]
        /// </summary>
        public static void LoadEMoLaiXiCopySceneInfo()
        {
            try
            {
                int totalWave = 0;//最大波数
                EMoLaiXiCopySencedata.FaildEscapeMonsterNum = (int)GameManager.systemParamsList.GetParamValueIntByName("BaoWeiZhan");

                XElement xmlFile = null;
                xmlFile = Global.GetGameResXml(string.Format("Config/EMoLaiXiLuXian.xml"));
                foreach (var args in xmlFile.Elements("Path"))
                {
                    int          id            = (int)Global.GetSafeAttributeLong(args, "ID");
                    string       sPatorlPathID = Global.GetSafeAttributeStr(args, "Path");
                    List <int[]> pointList     = new List <int[]>();
                    if (string.IsNullOrEmpty(sPatorlPathID))
                    {
                        LogManager.WriteLog(LogTypes.Warning, string.Format("金币副本怪路径为空"));
                    }
                    else
                    {
                        string[] fields = sPatorlPathID.Split('|');
                        if (fields.Length <= 0)
                        {
                            LogManager.WriteLog(LogTypes.Warning, string.Format("金币副本怪路径为空"));
                        }
                        else
                        {
                            for (int i = 0; i < fields.Length; i++)
                            {
                                string[] sa = fields[i].Split(',');
                                if (sa.Length != 2)
                                {
                                    LogManager.WriteLog(LogTypes.Warning, string.Format("解析{0}文件中的奖励项时失败,坐标有误", "Config/EMoLaiXiLuXian.xml"));
                                    continue;
                                }
                                int[] pos = Global.StringArray2IntArray(sa);
                                pointList.Add(pos);
                            }
                        }
                    }
                    EMoLaiXiCopySencedata.m_MonsterPatorlPathLists.Add(id, pointList);
                }

                xmlFile = Global.GetGameResXml(string.Format("Config/EMoLaiXi.xml"));
                IEnumerable <XElement> MonstersXEle = xmlFile.Elements("FuBen");
                foreach (var xmlItem in MonstersXEle)
                {
                    if (null != xmlItem)
                    {
                        EMoLaiXiCopySenceMonster tmpEMoLaiXiCopySceneMon = new EMoLaiXiCopySenceMonster();

                        tmpEMoLaiXiCopySceneMon.m_MonsterID = new List <int>();
                        int id = (int)Global.GetSafeAttributeLong(xmlItem, "ID");

                        tmpEMoLaiXiCopySceneMon.m_ID   = id;
                        tmpEMoLaiXiCopySceneMon.m_Wave = (int)Global.GetSafeAttributeLong(xmlItem, "WaveID");
                        //tmpEMoLaiXiCopySceneMon.m_Num = (int)Global.GetSafeAttributeLong(xmlItem, "Num");
                        tmpEMoLaiXiCopySceneMon.m_Delay1 = (int)Global.GetSafeAttributeLong(xmlItem, "Delay1");
                        tmpEMoLaiXiCopySceneMon.m_Delay2 = (int)Global.GetSafeAttributeLong(xmlItem, "Delay2");
                        string pathIDArray = Global.GetSafeAttributeStr(xmlItem, "PathID");;
                        tmpEMoLaiXiCopySceneMon.PathIDArray = Global.String2IntArray(pathIDArray);

                        string sMonstersID = Global.GetSafeAttributeStr(xmlItem, "MonsterList");
                        if (string.IsNullOrEmpty(sMonstersID))
                        {
                            LogManager.WriteLog(LogTypes.Warning, string.Format("金币副本怪ID为空"));
                        }
                        else
                        {
                            string[] fields = sMonstersID.Split('|');
                            if (fields.Length <= 0)
                            {
                                LogManager.WriteLog(LogTypes.Warning, string.Format("金币副本怪ID为空"));
                            }
                            else
                            {
                                for (int i = 0; i < fields.Length; i++)
                                {
                                    int[] Monsters = Global.String2IntArray(fields[i]);
                                    if (null != Monsters && Monsters.Length == 2 && Monsters[0] > 0 && Monsters[1] > 0)
                                    {
                                        for (int j = 0; j < Monsters[1]; j++)
                                        {
                                            tmpEMoLaiXiCopySceneMon.m_MonsterID.Add(Monsters[0]);
                                            tmpEMoLaiXiCopySceneMon.m_Num++;
                                        }
                                    }
                                }
                            }
                        }
                        EMoLaiXiCopySencedata.EMoLaiXiCopySenceMonsterData.Add(tmpEMoLaiXiCopySceneMon);
                        totalWave = Global.GMax(totalWave, tmpEMoLaiXiCopySceneMon.m_Wave);
                    }
                }
                EMoLaiXiCopySencedata.TotalWave = totalWave;
            }
            catch (Exception)
            {
                throw new Exception(string.Format("启动时加载xml文件: {0} 失败", string.Format("Config/JinBiFuBen.xml")));
            }
        }
        public static void OnSceneTimer(EMoLaiXiCopySence scene, List <GameClient> clientList, CopyMap copyMap, long nowTicks)
        {
            int  nWave            = scene.m_CreateMonsterWave;
            int  nCount           = EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.TotalWave;
            bool notifyWaveAndNum = false;
            bool notifyEnd        = false;
            int  escapeCount      = EMoLaiXiCopySceneManager.GetEscapeCount(scene.m_CopyMapID);

            if (escapeCount > 0)
            {
                scene.m_EscapedMonsterNum += escapeCount;
                notifyWaveAndNum           = true;
            }
            if (scene.m_LoginEnterFlag == 1)
            {
                if (nowTicks - scene.m_LoginEnterTimer > (long)EMoLaiXiCopySceneManager.m_DelayTime)
                {
                    scene.m_LoginEnterFlag = 0;
                    notifyWaveAndNum       = true;
                }
            }
            if (scene.m_EscapedMonsterNum >= EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.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 (clientList != null && 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 object[]
                                    {
                                        new DateTime(nowTicks * 10000L),
                                        copyMap.KilledDynamicMonsterNum,
                                        scene.m_EscapedMonsterNum,
                                        scene.m_TotalMonsterCountAllWave
                                    });
                                    LogManager.WriteLog(LogTypes.Error, log, null, true);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            }
            else if (nowTicks - scene.m_CreateMonsterTick2 > scene.m_Delay2 * 1000L)
            {
                if (scene.m_CreateMonsterWaveNotify == 0)
                {
                    scene.m_CreateMonsterWaveNotify = 1;
                    notifyWaveAndNum = true;
                }
                for (int i = 0; i < scene.m_CreateWaveMonsterList.Count; i++)
                {
                    EMoLaiXiCopySenceMonster tmpInfo = scene.m_CreateWaveMonsterList[i];
                    if (tmpInfo.m_CreateMonsterCount < tmpInfo.m_Num)
                    {
                        if (nowTicks - tmpInfo.m_CreateMonsterTick1 > (long)(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, null);
                            tmpInfo.m_CreateMonsterCount++;
                            scene.m_CreateMonsterCount++;
                            tmpInfo.m_CreateMonsterTick1 = nowTicks;
                        }
                    }
                }
                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   = 0L;
                    notifyWaveAndNum = true;
                    copyMap.TotalDynamicMonsterNum = scene.m_TotalMonsterCountAllWave;
                    if (scene.m_CreateMonsterWave >= EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.TotalWave)
                    {
                        scene.m_Delay2             = 2147483647L;
                        scene.m_bAllMonsterCreated = true;
                        notifyEnd = true;
                    }
                }
            }
            if (notifyWaveAndNum)
            {
                EMoLaiXiCopySceneManager.SendMsgToClientForEMoLaiXiCopySceneMonsterWave(clientList, scene.m_EscapedMonsterNum, scene.m_CreateMonsterWave, EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.TotalWave, EMoLaiXiCopySceneManager.EMoLaiXiCopySencedata.FaildEscapeMonsterNum);
            }
            if (notifyEnd && null != clientList)
            {
                foreach (GameClient client in clientList)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(108, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 处理刷怪,失败等活动逻辑
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="clientList"></param>
        /// <param name="copyMap"></param>
        /// <param name="nowTicks"></param>
        public static void OnSceneTimer(EMoLaiXiCopySence scene, List <GameClient> clientList, CopyMap copyMap, long nowTicks)
        {
            int nWave  = scene.m_CreateMonsterWave;
            int nCount = EMoLaiXiCopySencedata.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 >= EMoLaiXiCopySencedata.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++)
                    {
                        EMoLaiXiCopySenceMonster 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 >= EMoLaiXiCopySencedata.TotalWave)
                        {
                            scene.m_Delay2             = int.MaxValue;
                            scene.m_bAllMonsterCreated = true;
                            notifyEnd = true;
                        }
                    }
                }
            }

            if (notifyWaveAndNum)
            {
                SendMsgToClientForEMoLaiXiCopySceneMonsterWave(clientList, scene.m_EscapedMonsterNum, scene.m_CreateMonsterWave, EMoLaiXiCopySencedata.TotalWave, EMoLaiXiCopySencedata.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);
                }
            }
        }