public static void HeartBeatExperienceCopyMap() { long nowTicks = TimeUtil.NOW(); if (nowTicks - ExperienceCopySceneManager.LastHeartBeatTicks >= 1000L) { ExperienceCopySceneManager.LastHeartBeatTicks = ((ExperienceCopySceneManager.LastHeartBeatTicks < 86400000L) ? nowTicks : (ExperienceCopySceneManager.LastHeartBeatTicks + 1000L)); List <CopyMap> CopyMapList = new List <CopyMap>(); lock (ExperienceCopySceneManager.m_ExperienceListCopyMaps) { foreach (CopyMap item in ExperienceCopySceneManager.m_ExperienceListCopyMaps.Values) { List <GameClient> clientsList = item.GetClientsList(); ExperienceCopyMapDataInfo tmp = null; tmp = Data.ExperienceCopyMapDataInfoList[item.MapCode]; if (tmp != null) { ExperienceCopyScene tmpExSceneInfo = null; lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo) { if (!ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(item.FuBenSeqID, out tmpExSceneInfo)) { continue; } } if (tmpExSceneInfo != null) { int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave; int nCount = tmp.MonsterIDList.Count; if (nWave < nCount) { if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 0) { if (clientsList.Count <GameClient>() != 0 && clientsList[0] != null) { ExperienceCopySceneManager.ExperienceCopyMapCreateMonster(clientsList[0], tmpExSceneInfo, tmp, nWave); } else { ExperienceCopySceneManager.ExperienceCopyMapCreateMonster(null, tmpExSceneInfo, tmp, nWave); } } } } } } } for (int i = 0; i < CopyMapList.Count; i++) { GameManager.CopyMapMgr.ProcessRemoveCopyMap(CopyMapList[i]); } } }
public static void ExperienceCopyMapKillMonster(GameClient client, Monster monster) { ExperienceCopyMapDataInfo TmpExInfo = null; if (Data.ExperienceCopyMapDataInfoList.TryGetValue(client.ClientData.MapCode, out TmpExInfo)) { ExperienceCopyScene tmpExSceneInfo = null; lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo) { if (!ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo)) { return; } } if (tmpExSceneInfo != null) { CopyMap TmpCopyMapInfo = null; if (ExperienceCopySceneManager.m_ExperienceListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out TmpCopyMapInfo)) { if (TmpCopyMapInfo != null) { tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum++; tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum++; tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum--; if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 1 && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum == tmpExSceneInfo.m_ExperienceCopyMapNeedKillMonsterNum) { tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag = 0; tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum = 0; tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterNum = 0; } if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave == TmpExInfo.MonsterIDList.Count && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum) { ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapAward(client); } int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave; if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum || tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum == 0) { nWave++; } ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapInfo(client, nWave); } } } } }
public static void ExperienceCopyMapCreateMonster(GameClient client, ExperienceCopyScene ExperienceMapInfo, ExperienceCopyMapDataInfo exMap, int nWave) { ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterFlag = 1; ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave++; GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(ExperienceMapInfo.m_MapCodeID, out gameMap)) { LogManager.WriteLog(LogTypes.Error, string.Format("经验副本 地图配置 ID = {0}", ExperienceMapInfo.m_MapCodeID), null, true); } else { int gridX = gameMap.CorrectWidthPointToGridPoint(exMap.posX) / gameMap.MapGridWidth; int gridY = gameMap.CorrectHeightPointToGridPoint(exMap.posZ) / gameMap.MapGridHeight; int gridNum = gameMap.CorrectWidthPointToGridPoint(exMap.Radius); int nTotal = 0; List <int> nListID = exMap.MonsterIDList[nWave]; List <int> nListNum = exMap.MonsterNumList[nWave]; for (int i = 0; i < nListID.Count; i++) { int nID = nListID[i]; int nNum = nListNum[i]; GameManager.MonsterZoneMgr.AddDynamicMonsters(ExperienceMapInfo.m_MapCodeID, nID, ExperienceMapInfo.m_CopyMapID, nNum, gridX, gridY, gridNum, 0, SceneUIClasses.Normal, null, null); nTotal += nNum; ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum += nNum; ExperienceMapInfo.m_ExperienceCopyMapRemainMonsterNum += nNum; } ExperienceMapInfo.m_ExperienceCopyMapNeedKillMonsterNum = ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum * exMap.CreateNextWaveMonsterCondition[nWave] / 100; if (client != null) { ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapInfo(client, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave); } } }
/// <summary> // 杀怪接口 /// </summary> static public void ExperienceCopyMapKillMonster(GameClient client, Monster monster) { ExperienceCopyMapDataInfo TmpExInfo = null; if (!Data.ExperienceCopyMapDataInfoList.TryGetValue(client.ClientData.MapCode, out TmpExInfo)) { return; } ExperienceCopyScene tmpExSceneInfo = null; // 此处需要加锁 lock (m_ExperienceListCopyMapsInfo) { if (!m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo)) { return; } //tmpExSceneInfo = m_ExperienceListCopyMapsInfo[client.ClientData.FuBenSeqID]; } if (tmpExSceneInfo == null) { return; } CopyMap TmpCopyMapInfo = null; //TmpCopyMapInfo = m_ExperienceListCopyMaps[client.ClientData.FuBenSeqID]; if (m_ExperienceListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out TmpCopyMapInfo)) { if (TmpCopyMapInfo == null) { return; } } else { return; } ++tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum; ++tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum; --tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum; if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 1 && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum == tmpExSceneInfo.m_ExperienceCopyMapNeedKillMonsterNum) { tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag = 0; tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum = 0; tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterNum = 0; } //if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum) { if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave == TmpExInfo.MonsterIDList.Count && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum) { SendMsgToClientForExperienceCopyMapAward(client); } int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave; if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum || tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum == 0) { nWave++; } SendMsgToClientForExperienceCopyMapInfo(client, nWave); } //System.Console.WriteLine("liaowei是帅哥 经验副本 {0} 里 杀怪了 剩余数量是 {1}!!!", TmpCopyMapInfo.FuBenSeqID, tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum); }
/// <summary> // 刷怪接口 /// </summary> static public void ExperienceCopyMapCreateMonster(GameClient client, ExperienceCopyScene ExperienceMapInfo, ExperienceCopyMapDataInfo exMap, int nWave) { ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterFlag = 1; ++ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave; GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(ExperienceMapInfo.m_MapCodeID, out gameMap)) { LogManager.WriteLog(LogTypes.Error, string.Format("经验副本 地图配置 ID = {0}", ExperienceMapInfo.m_MapCodeID)); return; } int gridX = gameMap.CorrectWidthPointToGridPoint(exMap.posX) / gameMap.MapGridWidth; int gridY = gameMap.CorrectHeightPointToGridPoint(exMap.posZ) / gameMap.MapGridHeight; int gridNum = gameMap.CorrectWidthPointToGridPoint(exMap.Radius); int nID = 0; int nNum = 0; int nTotal = 0; //for (int i = 0; i < exMap.MonsterIDList.Count; ++i) { List <int> nListID = exMap.MonsterIDList[nWave]; List <int> nListNum = exMap.MonsterNumList[nWave]; for (int j = 0; j < nListID.Count; ++j) { nID = nListID[j]; nNum = nListNum[j]; GameManager.MonsterZoneMgr.AddDynamicMonsters(ExperienceMapInfo.m_MapCodeID, nID, ExperienceMapInfo.m_CopyMapID, nNum, gridX, gridY, gridNum); nTotal += nNum; ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum += nNum; ExperienceMapInfo.m_ExperienceCopyMapRemainMonsterNum += nNum; } } // 计数要杀死怪的数量 ExperienceMapInfo.m_ExperienceCopyMapNeedKillMonsterNum = ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum * exMap.CreateNextWaveMonsterCondition[nWave] / 100; //System.Console.WriteLine("liaowei是帅哥 经验副本 {0} 里 刷怪了 数量是 {1} !!!", exMap.MapCodeID, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum); if (client != null) { SendMsgToClientForExperienceCopyMapInfo(client, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave); } }
/// <summary> // 心跳处理 /// </summary> public static void HeartBeatExperienceCopyMap() { long nowTicks = DateTime.Now.Ticks / 10000; if (nowTicks - LastHeartBeatTicks < (1000)) { return; } LastHeartBeatTicks = nowTicks; List <CopyMap> CopyMapList = new List <CopyMap>(); // lock住!!! lock (m_ExperienceListCopyMaps) { foreach (var item in m_ExperienceListCopyMaps.Values) { List <GameClient> clientsList = item.GetClientsList(); /*if (null != clientsList && clientsList.Count <= 0) * { * CopyMapList.Add(item); * continue; * }*/ ExperienceCopyMapDataInfo tmp = null; tmp = Data.ExperienceCopyMapDataInfoList[item.MapCode]; if (tmp == null) { continue; } ExperienceCopyScene tmpExSceneInfo = null; lock (m_ExperienceListCopyMapsInfo) { if (!m_ExperienceListCopyMapsInfo.TryGetValue(item.FuBenSeqID, out tmpExSceneInfo)) { continue; } //tmpExSceneInfo = m_ExperienceListCopyMapsInfo[item.FuBenSeqID]; } if (tmpExSceneInfo == null) { continue; } /*int fuBenID = FuBenManager.FindFuBenIDByMapCode(item.MapCode); * FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(fuBenID, item.MapCode); * if (null == fuBenMapItem) * continue; * * //是否超时 * if (nowTicks - tmpExSceneInfo.m_StartTimer >= (fuBenMapItem.MaxTime * 60L * 1000L)) * { * CopyMapList.Add(item); * continue; * }*/ int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave; int nCount = tmp.MonsterIDList.Count; // 一共有几波 if (nWave >= nCount) // 已经刷完了 { continue; } if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 0) { if (clientsList.Count() != 0 && clientsList[0] != null) { ExperienceCopyMapCreateMonster(clientsList[0], tmpExSceneInfo, tmp, nWave); } else { ExperienceCopyMapCreateMonster(null, tmpExSceneInfo, tmp, nWave); } } } } for (int i = 0; i < CopyMapList.Count; ++i) { GameManager.CopyMapMgr.ProcessRemoveCopyMap(CopyMapList[i]); } }