/// <summary> /// 处理任务 /// </summary> /// <param name="client"></param> /// <param name="npcID"></param> /// <param name="extensionID"></param> /// <param name="goodsID"></param> /// <param name="taskType"></param> public void HandleTask(GameClient client, int npcID, int extensionID, int goodsID, int taskType) { ProcessTask.Process(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, npcID, extensionID, goodsID, (TaskTypes)taskType); }
public static int ReqFinishCaiJi(GameClient client, int monsterId) { int result; if (monsterId != client.ClientData.CaijTargetId || client.ClientData.CaiJiStartTick == 0U || client.ClientData.CaijTargetId == 0) { CaiJiLogic.CancelCaiJiState(client); result = -3; } else if (client.ClientData.CurrentLifeV <= 0) { CaiJiLogic.CancelCaiJiState(client); result = -3; } else { Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId); if (null == monster) { CaiJiLogic.CancelCaiJiState(client); result = -1; } else if (monster.UniqueID != client.ClientData.CaiJiTargetUniqueID) { CaiJiLogic.CancelCaiJiState(client); result = -1; } else if (monster.MonsterType != 1601) { CaiJiLogic.CancelCaiJiState(client); result = -4; } else { SystemXmlItem CaiJiMonsterXmlItem = null; SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode); GetCaiJiTimeEventObject eventObj = new GetCaiJiTimeEventObject(client, monster); bool handled = GlobalEventSource4Scene.getInstance().fireEvent(eventObj, (int)sceneType); int GatherTime; if (handled) { if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0) { return(-301); } GatherTime = eventObj.GatherTime; if (GatherTime < 0) { return(GatherTime); } } else if (sceneType == SceneUIClasses.HuanYingSiYuan) { GatherTime = HuanYingSiYuanManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else if (sceneType == SceneUIClasses.YongZheZhanChang) { GatherTime = YongZheZhanChangManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else if (sceneType == SceneUIClasses.KingOfBattle) { GatherTime = KingOfBattleManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else if (sceneType == SceneUIClasses.Comp) { GatherTime = CompManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else if (sceneType == SceneUIClasses.KarenEast) { GatherTime = KarenBattleManager_MapEast.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else if (sceneType == SceneUIClasses.LingDiCaiJi) { GatherTime = LingDiCaiJiManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { CaiJiLogic.CancelCaiJiState(client); return(GatherTime); } } else if (sceneType == SceneUIClasses.EscapeBattle) { GatherTime = EscapeBattleManager.getInstance().GetCaiJiMonsterTime(client, monster); if (GatherTime < 0) { return(-4); } } else { if (sceneType == SceneUIClasses.ShuiJingHuanJing) { if (client.ClientData.DailyCrystalCollectNum >= CaiJiLogic.DailyNum) { CaiJiLogic.CancelCaiJiState(client); return(-6); } } if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem) { CaiJiLogic.CancelCaiJiState(client); return(-4); } GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime", -1); } GatherTime = GatherTime * CaiJiLogic.GatherTimePer / 100; uint intervalmsec = TimeUtil.timeGetTime() - client.ClientData.CaiJiStartTick; if ((ulong)intervalmsec < (ulong)((long)(GatherTime * 1000))) { CaiJiLogic.CancelCaiJiState(client); LogManager.WriteLog(LogTypes.Error, string.Format("采集读条时间不足intervalmsec={0}", intervalmsec), null, true); result = -5; } else { CaiJiLogic.CancelCaiJiState(client); if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400.0) { result = -2; } else { lock (monster.CaiJiStateLock) { if (monster.IsCollected) { return(-4); } monster.IsCollected = true; } if (!GlobalEventSource4Scene.getInstance().fireEvent(new CaiJiEventObject(client, monster), (int)sceneType)) { if (sceneType == SceneUIClasses.HuanYingSiYuan) { HuanYingSiYuanManager.getInstance().OnCaiJiFinish(client, monster); } else if (sceneType == SceneUIClasses.LingDiCaiJi) { LingDiCaiJiManager.getInstance().OnCaiJiFinish(client, monster); } else { CaiJiLogic.UpdateCaiJiData(client); CaiJiLogic.NotifyCollectLastNum(client, 0, CaiJiLogic.DailyNum - client.ClientData.DailyCrystalCollectNum); float AwardRate = 1f; int rangeIndex = CaiJiLogic.JugeDateTimeInTimeRange(TimeUtil.NowDateTime(), CaiJiLogic.dateTimeRangeArray, true); if (rangeIndex >= 0) { AwardRate = CaiJiLogic.dateTimeRangeArray[rangeIndex].DoubleAwardRate; } int ExpAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("ExpAward", -1)); int XingHunAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("XingHunAward", -1)); int BindZuanShiAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("BindZuanShiAward", -1)); int BindJinBiAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("BindJinBiAward", -1)); int MoJingAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("MoJingAward", -1)); if (ExpAward > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, (long)ExpAward, true, true, false, "none"); } if (XingHunAward > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, XingHunAward, "采集获得星魂", true, true); } if (BindZuanShiAward > 0) { GameManager.ClientMgr.AddUserGold(client, BindZuanShiAward, "采集获得绑钻"); } if (BindJinBiAward > 0) { GameManager.ClientMgr.AddMoney1(client, BindJinBiAward, "采集获得绑金", true); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(28, new object[0]), new object[] { BindJinBiAward }), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, 0); } if (MoJingAward > 0) { GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, MoJingAward, "采集获得魔晶", true, true, false); } ProcessTask.ProcessAddTaskVal(client, TaskTypes.CaiJi_ShuiJingHuanJing, -1, 1, new object[0]); } } GameManager.MonsterMgr.DeadMonsterImmediately(monster); ProcessTask.Process(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, monster.RoleID, monster.MonsterInfo.ExtensionID, -1, TaskTypes.CaiJiGoods, null, 0, -1L, null); result = 0; } } } } return(result); }