public void AddCopyScene(GameClient client, CopyMap copyMap, SceneUIClasses sceneType) { if (copyMap.MapCode == this.MapCode) { int fuBenSeqId = copyMap.FuBenSeqID; int mapCode = copyMap.MapCode; lock (this.copyDict) { MoRiJudgeCopy copy = null; if (!this.copyDict.TryGetValue(fuBenSeqId, out copy)) { copy = new MoRiJudgeCopy(); copy.MyCopyMap = copyMap; copy.GameId = Global.GetClientKuaFuServerLoginData(client).GameId; copy.StateTimeData.GameType = 3; copy.StartTime = TimeUtil.NowDateTime(); copy.EndTime = copy.StartTime.AddMinutes((double)this.CopyMaxAliveMinutes); copy.LimitKillCount = 0; copy.RoleCount = 1; copy.Passed = false; this.copyDict[fuBenSeqId] = copy; } else { copy.RoleCount++; } } FuBenManager.AddFuBenSeqID(client.ClientData.RoleID, copyMap.FuBenSeqID, 0, copyMap.FubenMapID); copyMap.IsKuaFuCopy = true; copyMap.SetRemoveTicks(TimeUtil.NOW() + (long)((this.CopyMaxAliveMinutes + 3) * 60000)); GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 1, 0, 0, 3); } }
public static void GetWanmotaSweepReward(GameClient client, int nFubenID) { FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(nFubenID, nFubenID); if (null != fuBenMapItem) { List <GoodsData> goodNormal = new List <GoodsData>(); List <int> goodsID = new List <int>(); WanMotaCopySceneManager.GetFubenItemReward(client, fuBenMapItem, false, goodNormal, goodsID); if (null == client.ClientData.LayerRewardData) { client.ClientData.LayerRewardData = new LayerRewardData(); } if (WanMotaCopySceneManager.IsWanMoTaMapCode(nFubenID)) { List <SingleLayerRewardData> listRewardData = null; SingleLayerRewardData layerReward = WanMotaCopySceneManager.AddSingleSweepReward(client, goodNormal, nFubenID - WanMotaCopySceneManager.nWanMoTaFirstFuBenOrder + 1, fuBenMapItem.Experience, fuBenMapItem.Money1, fuBenMapItem.nXingHunAward, out listRewardData); SweepWanMotaManager.UpdataSweepInfo(client, listRewardData); lock (client.ClientData.LayerRewardData) { client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Add(layerReward); } } } }
public static void SendMsgToClientForWanMoTaCopyMapAward(GameClient client, CopyMap copyMap, bool anyAlive) { if (copyMap != null) { int fuBenSeqID = FuBenManager.FindFuBenSeqIDByRoleID(client.ClientData.RoleID); FuBenTongGuanData fubenTongGuanData = null; bool bFirstPassWanMoTa = false; if (fuBenSeqID > 0) { FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(fuBenSeqID); if (null != fuBenInfoItem) { fuBenInfoItem.EndTicks = TimeUtil.NOW(); int addFuBenNum = 1; if (fuBenInfoItem.nDayOfYear != TimeUtil.NowDateTime().DayOfYear) { addFuBenNum = 0; } int fuBenID = FuBenManager.FindFuBenIDByMapCode(client.ClientData.MapCode); if (fuBenID > 0) { if (WanMotaCopySceneManager.IsWanMoTaMapCode(client.ClientData.MapCode)) { if (!Global.FuBenPassed(client, fuBenID)) { bFirstPassWanMoTa = true; } } int usedSecs = (int)((fuBenInfoItem.EndTicks - fuBenInfoItem.StartTicks) / 1000L); Global.UpdateFuBenDataForQuickPassTimer(client, fuBenID, usedSecs, addFuBenNum); FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(fuBenID, client.ClientData.MapCode); fubenTongGuanData = WanMotaCopySceneManager.GiveCopyMapGiftNoScore(client, fuBenMapItem, true); GameManager.DBCmdMgr.AddDBCmd(10053, string.Format("{0}:{1}:{2}:{3}", new object[] { client.ClientData.RoleID, Global.FormatRoleName(client, client.ClientData.RoleName), fuBenID, usedSecs }), null, client.ServerId); } } } GameManager.ClientMgr.NotifyAllFuBenBeginInfo(copyMap, client.ClientData.RoleID, !anyAlive); if (fubenTongGuanData != null && bFirstPassWanMoTa) { TCPOutPacket tcpOutPacket = DataHelper.ObjectToTCPOutPacket <FuBenTongGuanData>(fubenTongGuanData, Global._TCPManager.TcpOutPacketPool, 521); if (!Global._TCPManager.MySocketListener.SendData(client.ClientSocket, tcpOutPacket, true)) { } } } }
// 添加一个末日审判副本 public void AddCopyScene(GameClient client, CopyMap copyMap, SceneUIClasses sceneType) { if (copyMap.MapCode == this.MapCode) { int fuBenSeqId = copyMap.FuBenSeqID; int mapCode = copyMap.MapCode; lock (copyDict) { MoRiJudgeCopy copy = null; if (!copyDict.TryGetValue(fuBenSeqId, out copy)) { copy = new MoRiJudgeCopy(); copy.MyCopyMap = copyMap; copy.GameId = Global.GetClientKuaFuServerLoginData(client).GameId; copy.StateTimeData.GameType = (int)GameTypes.MoRiJudge; // 副本的统计信息 copy.StartTime = TimeUtil.NowDateTime(); copy.EndTime = copy.StartTime.AddMinutes(this.CopyMaxAliveMinutes); copy.LimitKillCount = 0; copy.RoleCount = 1; copy.Passed = false; copyDict[fuBenSeqId] = copy; } else { copy.RoleCount++; } } FuBenManager.AddFuBenSeqID(client.ClientData.RoleID, copyMap.FuBenSeqID, 0, copyMap.FubenMapID); copyMap.IsKuaFuCopy = true; // 增加清除时间 copyMap.SetRemoveTicks(TimeUtil.NOW() + (this.CopyMaxAliveMinutes + 3) * TimeUtil.MINITE); //更新状态 // MoRiJudgeClient.getInstance().GameFuBenRoleChangeState(client.ClientData.RoleID, (int)KuaFuRoleStates.StartGame); // 开始游戏统计 GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 1, 0, 0, (int)GameTypes.MoRiJudge); } }
//public void RunMapDynamicMonsters(SocketListener sl, TCPOutPacketPool pool) //{ // //执行添加动态的副本怪物 // for (int i = 0; i < MonsterZoneManager.MaxRunQueueNum; i++) // { // if (!RunAddCopyMapMonsters()) // { // break; // } // } // //执行销毁动态的副本怪物 // for (int i = 0; i < MonsterZoneManager.MaxRunQueueNum; i++) // { // if (!RunDestroyCopyMapMonsters()) // { // break; // } // } // //执行立刻刷新副本怪物的操作 // for (int i = 0; i < MonsterZoneManager.MaxRunQueueNum; i++) // { // if (!RunReloadCopyMapMonsters()) // { // break; // } // } // //执行立刻刷新普通地图怪物的操作 // for (int i = 0; i < MonsterZoneManager.MaxRunQueueNum; i++) // { // if (!RunReloadNormalMapMonsters()) // { // break; // } // } // /*//执行动态召唤怪物操作 // for (int i = 0; i < MonsterZoneManager.MaxRunQueueNum; i++) // { // if (!RunAddDynamicMonsters()) // { // break; // } // }*/ // //执行立刻刷新竞技场机器人的刷新 // for (int i = 0; i < MonsterZoneManager.MaxRunAddDynamicMonstersQueueNum; i++) // { // if (!RunAddRobots()) // { // break; // } // } // // 最多循环100次 // int Count = 0; // int loop_Count = 0; // while (Count < MaxRunAddDynamicMonstersQueueNum) // { // for (int i = 0; i < Max_WaitingAddDynamicMonsterQueneCount; i++) // { // loop_Count++; // if (RunAddDynamicMonsters(i)) // { // Count++; // } // } // if (loop_Count >= MonsterZoneManager.MaxRunQueueNum) // { // break; // } // } //} #endregion #region /// <summary> /// 添加动态爆怪区域,每个地图有一个,所有参数都动态生成 /// </summary> /// <param name="mapCode"></param> public void AddDynamicMonsterZone(int mapCode) { //判断是否是副本地图 bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode); CMonsterZone monsterZone = new CMonsterZone() { MapCode = mapCode, ID = MonsterDynamicZoneDict.Count + 10000, //动态配置 爆怪的区域ID,这个ID这样生成就可以 Code = -1, //动态配置---区域怪物ID,需要生成的时候动态配置 ToX = -1, //动态配置 ToY = -1, //动态配置 Radius = 300, //可以动态修改 TotalNum = 0, //动态 Timeslot = 1, IsFuBenMap = isFuBenMap, //意味着该区域的怪不管是在副本还说非副本,都由外部代码动态控制怪物的加载,怪物不会被程序定期循环复活 //同时该区域的怪物一旦死亡,直接销毁【将来或许需要加入一个针对这种类型的最大复活次数?】 BirthType = (int)MonsterBirthTypes.CrossMap, //这个字段非常重要,用于区分是动态刷怪区域还是 旧的系统怪区域!!!!!! ConfigBirthType = -1, //配置文件可没配置 BirthTimePointList = null, BirthRate = 10000, //必爆 }; //追踪范围,动态配置 monsterZone.PursuitRadius = 0; lock (InitMonsterZoneMutex) { //动态爆怪区域列表--->里面的怪物一旦死亡,移除 MonsterDynamicZoneDict.Add(mapCode, monsterZone); //加入列表 MonsterZoneList.Add(monsterZone); //加入爆怪区域 AddMap2MonsterZoneDict(monsterZone); } }
private bool InitConfig() { try { XElement xml = XElement.Load(Global.GameResPath("Config/MoRiShenPan.xml")); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement item in xmlItems) { MoRiMonster monster = new MoRiMonster(); monster.Id = (int)Global.GetSafeAttributeLong(item, "ID"); monster.Name = Global.GetSafeAttributeStr(item, "Name"); monster.MonsterId = (int)Global.GetSafeAttributeLong(item, "MonstersID"); monster.BirthX = (int)Global.GetSafeAttributeLong(item, "X"); monster.BirthY = (int)Global.GetSafeAttributeLong(item, "Y"); monster.KillLimitSecond = (int)Global.GetSafeAttributeLong(item, "Time"); string addBossProps = Global.GetSafeAttributeStr(item, "Props"); if (!string.IsNullOrEmpty(addBossProps) && addBossProps != "-1") { foreach (string prop in addBossProps.Split(new char[] { '|' })) { string[] prop_kv = prop.Split(new char[] { ',' }); if (prop_kv != null && prop_kv.Length == 2) { monster.ExtPropDict.Add((int)Enum.Parse(typeof(ExtPropIndexes), prop_kv[0]), (float)Convert.ToDouble(prop_kv[1])); } } } this.BossConfigList.Add(monster); } this.BossConfigList.Sort(delegate(MoRiMonster left, MoRiMonster right) { int result; if (left.Id < right.Id) { result = -1; } else if (left.Id > right.Id) { result = 1; } else { result = 0; } return(result); }); SystemXmlItem systemFuBenItem = null; if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(70000, out systemFuBenItem)) { LogManager.WriteLog(LogTypes.Fatal, string.Format("缺少末日审判副本配置 CopyID={0}", 70000), null, true); return(false); } this.MapCode = systemFuBenItem.GetIntValue("MapCode", -1); FuBenMapItem fubenItem = FuBenManager.FindMapCodeByFuBenID(70000, this.MapCode); if (fubenItem == null) { LogManager.WriteLog(LogTypes.Fatal, string.Format("末日审判地图 {0} 配置错误", this.MapCode), null, true); return(false); } this.CopyMaxAliveMinutes = fubenItem.MaxTime; GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(this.MapCode, out gameMap)) { LogManager.WriteLog(LogTypes.Fatal, string.Format("缺少末日审判地图 {0}", this.MapCode), null, true); return(false); } this.copyMapGirdWidth = gameMap.MapGridWidth; this.copyMapGirdHeight = gameMap.MapGridHeight; } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", "Config/MoRiShenPan.xml"), ex, true); return(false); } return(true); }
/// <summary> // 万魔塔副本层奖励 /// </summary> public static void SendMsgToClientForWanMoTaCopyMapAward(GameClient client, CopyMap copyMap, bool anyAlive) { CopyMap tmpCopyMap = copyMap; if (tmpCopyMap == null) { return; } int fuBenSeqID = FuBenManager.FindFuBenSeqIDByRoleID(client.ClientData.RoleID); FuBenTongGuanData fubenTongGuanData = null; bool bFirstPassWanMoTa = false; if (fuBenSeqID > 0) //如果副本不存在 { FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(fuBenSeqID); if (null != fuBenInfoItem) { fuBenInfoItem.EndTicks = DateTime.Now.Ticks / 10000; int addFuBenNum = 1; if (fuBenInfoItem.nDayOfYear != TimeUtil.NowDateTime().DayOfYear) { addFuBenNum = 0; } int fuBenID = FuBenManager.FindFuBenIDByMapCode(client.ClientData.MapCode); if (fuBenID > 0) { if (WanMotaCopySceneManager.IsWanMoTaMapCode(client.ClientData.MapCode)) { // 第一次通过万魔塔某层 if (!Global.FuBenPassed(client, fuBenID)) { bFirstPassWanMoTa = true; } } int usedSecs = (int)((fuBenInfoItem.EndTicks - fuBenInfoItem.StartTicks) / 1000); // 更新玩家通关时间信息 Global.UpdateFuBenDataForQuickPassTimer(client, fuBenID, usedSecs, addFuBenNum); // LogManager.WriteLog(LogTypes.Info, string.Format("万魔塔首次通关标记:{0}", bFirstPassWanMoTa)); // 给玩家物品 FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(fuBenID, client.ClientData.MapCode); fubenTongGuanData = GiveCopyMapGiftNoScore(client, fuBenMapItem, true); GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_DB_ADDFUBENHISTDATA, string.Format("{0}:{1}:{2}:{3}", client.ClientData.RoleID, Global.FormatRoleName(client, client.ClientData.RoleName), fuBenID, usedSecs), null); // 万魔塔通关不计活跃 ChenXiaojun //int nLev = -1; //SystemXmlItem systemFuBenItem = null; //if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(fuBenID, out systemFuBenItem)) //{ // nLev = systemFuBenItem.GetIntValue("FuBenLevel"); //} //GameManager.ClientMgr.UpdateRoleDailyData_FuBenNum(client, 1, nLev); //副本通关 //Global.BroadcastFuBenOk(client, usedSecs, fuBenID); } } } GameManager.ClientMgr.NotifyAllFuBenBeginInfo(client, !anyAlive); if (fubenTongGuanData != null && bFirstPassWanMoTa) { //发送奖励到客户端 TCPOutPacket tcpOutPacket = DataHelper.ObjectToTCPOutPacket <FuBenTongGuanData>(fubenTongGuanData, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_SPR_FUBENPASSNOTIFY); if (!Global._TCPManager.MySocketListener.SendData(client.ClientSocket, tcpOutPacket)) { ; } } }
/// <summary> /// 加载怪物 /// </summary> public void AddMapMonsters(int mapCode, GameMap gameMap) { AddDynamicMonsterZone(mapCode); string fileName = string.Format("Map/{0}/Monsters.xml", mapCode); XElement xml = null; try { xml = XElement.Load(Global.ResPath(fileName)); } catch (Exception) { throw new Exception(string.Format("加载地图怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName)); } IEnumerable <XElement> monsterItems = xml.Elements("Monsters").Elements(); if (null == monsterItems) { return; } //判断是否是副本地图 bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode); foreach (var monsterItem in monsterItems) { String timePoints = Global.GetSafeAttributeStr(monsterItem, "TimePoints"); int configBirthType = (int)Global.GetSafeAttributeLong(monsterItem, "BirthType"); int realBirthType = configBirthType; String realTimePoints = timePoints; int spawnMonstersAfterKaiFuDays = 0; int spawnMonstersDays = 0; List <BirthTimeForDayOfWeek> CreateMonstersDayOfWeek = new List <BirthTimeForDayOfWeek>(); List <BirthTimePoint> birthTimePointList = null; //对于开服多少天之后才开始刷怪,进行特殊配置 格式:开服多少天;连续刷多少天[负数0表示一直];刷怪方式0或1;0或1的配置 if ((int)MonsterBirthTypes.AfterKaiFuDays == configBirthType || (int)MonsterBirthTypes.AfterHeFuDays == configBirthType || (int)MonsterBirthTypes.AfterJieRiDays == configBirthType) { String[] arr = timePoints.Split(';'); if (4 != arr.Length) { throw new Exception(String.Format("地图{0}的类型4的刷怪配置参数个数不对!!!!", mapCode)); } spawnMonstersAfterKaiFuDays = int.Parse(arr[0]); spawnMonstersDays = int.Parse(arr[1]); realBirthType = int.Parse(arr[2]); realTimePoints = arr[3]; if ((int)MonsterBirthTypes.TimePoint != realBirthType && (int)MonsterBirthTypes.TimeSpan != realBirthType) { throw new Exception(String.Format("地图{0}的类型4的刷怪配置子类型不对!!!!", mapCode)); } } // MU新增 一周中的哪天刷 TimePoints 配置形式 周几,时间点|周几,时间点|周几,时间点... [1/10/2014 LiaoWei] if ((int)MonsterBirthTypes.CreateDayOfWeek == configBirthType) { String[] arrTime = timePoints.Split('|'); if (arrTime.Length > 0) { for (int nIndex = 0; nIndex < arrTime.Length; ++nIndex) { string sTimePoint = null; sTimePoint = arrTime[nIndex]; if (sTimePoint != null) { String[] sTime = null; sTime = sTimePoint.Split(','); if (sTime != null && sTime.Length == 2) { string sTimeString = null; int nDayOfWeek = -1; nDayOfWeek = int.Parse(sTime[0]); sTimeString = sTime[1]; if (nDayOfWeek != -1 && !string.IsNullOrEmpty(sTimeString)) { string[] fields2 = sTimeString.Split(':'); if (fields2.Length != 2) { continue; } string str1 = fields2[0].TrimStart('0'); string str2 = fields2[1].TrimStart('0'); BirthTimePoint birthTimePoint = new BirthTimePoint() { BirthHour = Global.SafeConvertToInt32(str1), BirthMinute = Global.SafeConvertToInt32(str2), }; BirthTimeForDayOfWeek BirthTimeTmp = new BirthTimeForDayOfWeek(); BirthTimeTmp.BirthDayOfWeek = nDayOfWeek; BirthTimeTmp.BirthTime = birthTimePoint; CreateMonstersDayOfWeek.Add(BirthTimeTmp); } } } } } } else { birthTimePointList = ParseBirthTimePoints(realTimePoints); } CMonsterZone cmonsterZone = new CMonsterZone() { MapCode = mapCode, ID = (int)Global.GetSafeAttributeLong(monsterItem, "ID"), Code = (int)Global.GetSafeAttributeLong(monsterItem, "Code"), ToX = (int)Global.GetSafeAttributeLong(monsterItem, "X") / gameMap.MapGridWidth, ToY = (int)Global.GetSafeAttributeLong(monsterItem, "Y") / gameMap.MapGridHeight, Radius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth, TotalNum = (int)Global.GetSafeAttributeLong(monsterItem, "Num"), Timeslot = (int)Global.GetSafeAttributeLong(monsterItem, "Timeslot"), IsFuBenMap = isFuBenMap, BirthType = realBirthType, ConfigBirthType = configBirthType, SpawnMonstersAfterKaiFuDays = spawnMonstersAfterKaiFuDays, SpawnMonstersDays = spawnMonstersDays, SpawnMonstersDayOfWeek = CreateMonstersDayOfWeek, BirthTimePointList = birthTimePointList, BirthRate = (int)(Global.GetSafeAttributeDouble(monsterItem, "BirthRate") * 10000), }; XAttribute attrib = monsterItem.Attribute("PursuitRadius"); if (null != attrib) { cmonsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "PursuitRadius"); } else { cmonsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius"); } lock (InitMonsterZoneMutex) { //加入列表 MonsterZoneList.Add(cmonsterZone); //加入爆怪区域 AddMap2MonsterZoneDict(cmonsterZone); } //加载静态的怪物信息 cmonsterZone.LoadStaticMonsterInfo(); //加载怪物 cmonsterZone.LoadMonsters();//暂时屏蔽怪物加载 } }