private void OnExecuteTask(uint nTaskID) { QuestTraceInfo questInfo = QuestTranceManager.Instance.GetQuestTraceInfo(nTaskID); if (questInfo == null) { Engine.Utility.Log.Error(" Get questinfo error {0}", nTaskID); return; } uint npcid = 0; if (questInfo.IsKillMonster(out npcid)) { Client.ISkillPart skillPart = Client.ClientGlobal.Instance().MainPlayer.GetPart(Client.EntityPart.Skill) as Client.ISkillPart; if (skillPart != null) { if (skillPart.GetCurSkillState() != (int)Client.SkillState.None) { m_nDoingTaskID = nTaskID; if (m_bAddSkillNoneListener) { return; } m_bAddSkillNoneListener = true; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.SKILLNONESTATE_ENTER, OnEvent); Engine.Utility.Log.Info("等待.......技能播放完毕 执行任务{0} {1}", m_nDoingTaskID, Client.ClientGlobal.Instance().MainPlayer.GetCurState()); return; } } } ProcessTask(questInfo); }
private void OnDoingTask(QuestTraceInfo taskInfo) { DataManager.Manager <TaskDataManager>().DoingTaskID = taskInfo.taskId; Client.IController controller = Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl(); if (controller == null) { Engine.Utility.Log.Error("IController is null"); return; } table.QuestDataBase questDB = taskInfo.QuestTable; if (questDB == null) { Engine.Utility.Log.Error("QuestTable is null"); return; } UnityEngine.Vector2 pos; uint npcid = 0; PanelID pid; int copyID; int tab = 0; uint jumpId; //背包满了 无法执行任务 if (false == taskInfo.TaskItemCanPutInKanpsack()) { TipsManager.Instance.ShowTips(LocalTextType.Task_Commond_3); return; } if (MainPlayerIsChangeBody()) { return; } else if (taskInfo.taskSubType == TaskSubType.SubmitLimit) //断档任务 { if (taskInfo.IsOpenUI(out jumpId)) { ItemManager.DoJump(jumpId); } else { string des = string.Format("将等级提升到{0}级继续主线任务", taskInfo.finishLevel); TipsManager.Instance.ShowTips(des); } return; } else if (taskInfo.IsDynamicCommitItem) //动态道具递交(蚩尤乱世除外) { taskInfo.DoJump(); return; } else if (DataManager.Manager <ComBatCopyDataManager>().IsEnterCopy == false && taskInfo.IsOpenUI(out jumpId)) { ItemManager.DoJump(jumpId); return; } else if (taskInfo.IsMoveToTargetPos(out pos)) { //if (DataManager.Manager<TaskDataManager>().IsShowSlider) if (DataManager.Manager <SliderDataManager>().IsReadingSlider) { return; } Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs == null) { return; } if (!m_bAddStopMoveListener) { m_bAddStopMoveListener = true; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); } if (EqualsMapID(questDB.destMapID)) { cs.GetCombatRobot().Stop(); DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { //if (!m_bAddStopMoveListener) //{ // m_bAddStopMoveListener = true; // Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); //} m_nDoingTaskID = taskInfo.taskId; controller.GotoMap(questDB.destMapID, new Vector3(pos.x, 0, -pos.y)); }, null); return; } else { DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { if (questDB.dwHelpDoing) { m_nDoingTaskID = taskInfo.taskId; //下载地图检查 if (!KHttpDown.Instance().SceneFileExists(questDB.destMapID)) { //打开下载界面 DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.DownloadPanel); return; } controller.GotoMapDirectly(questDB.destMapID, new Vector3(pos.x, 0, -pos.y), questDB.dwID); } }, null); } } else if (taskInfo.IsVisitCollectNpc(out npcid) || taskInfo.IsDeleverItem(out npcid)) { AddCollectNpcEffect(taskInfo); DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID); }, null); } else if (taskInfo.IsDirectlyVisitCopy(taskInfo.copyId) && false == EqualsMapID(questDB.destMapID)) { //直接跳副本 VisitCopy(taskInfo.copyId); } else if (taskInfo.IsKillMonster(out npcid)) { Client.ICombatRobot robot = Client.ClientGlobal.Instance().GetControllerSystem().GetCombatRobot(); if (robot == null) { Engine.Utility.Log.Error("robotis null"); return; } if (robot.Status == Client.CombatRobotStatus.RUNNING && robot.TargetId == npcid) { Engine.Utility.Log.Info("已经在挂机杀怪{0}", npcid); return; } //TODO 优化 bool getPos = false; if (EqualsMapID(questDB.destMapID)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { getPos = true; Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if ((mainPos - new Vector3(pos.x, mainPos.y, -pos.y)).sqrMagnitude < 5) { Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetCombatRobot().StartWithTarget((int)npcid); Engine.Utility.Log.LogGroup("ZCX", "挂机杀怪物{0}", npcid); return; } } } } DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { if (!m_bAddStopMoveListener) { m_bAddStopMoveListener = true; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent); } m_nDoingTaskID = taskInfo.taskId; if (getPos) { controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true); } else if (EqualsMapID(questDB.destMapID)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true); } } else { VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID); } }, null); } }
private void OnCommitTask(QuestTraceInfo taskInfo) { table.QuestDataBase questDB = taskInfo.QuestTable; if (questDB == null) { Engine.Utility.Log.Error("QuestTable is null"); return; } if (taskInfo.taskSubType == TaskSubType.Guild) { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.MissionMessagePanel, data: taskInfo.taskId); return; } PanelID pid; int tab = 0; int copyId = 0; uint jumpId; if (taskInfo.IsOpenUI(out jumpId)) { ItemManager.DoJump(jumpId); return; } else if (taskInfo.IsChangeBodyTask()) { //bool isChange = (bool)Client.ClientGlobal.Instance().MainPlayer.SendMessage(Client.EntityMessage.EntityCommand_IsChange, null); //if (!isChange) //{ // m_nDoingTaskID = taskInfo.taskId; // if (m_bAddChangeListener) // { // return; // } // m_bAddChangeListener = true; // Engine.Utility.Log.Info("{0}CanDone 等待.......变身回来 执行任务{1}", TAG, m_nDoingTaskID); // Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_CHANGE, OnEvent); // return; //} m_nDoingTaskID = taskInfo.taskId; if (false == m_bAddChangeListener && false == MainPlayerIsChangeBody()) { m_bAddChangeListener = true; Engine.Utility.Log.Info("{0}CanDone 等待.......变身回来 执行任务{1}", TAG, m_nDoingTaskID); Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_CHANGE, OnEvent); } VisitNpc(questDB.dwHelpCommit, questDB.submitMapID, questDB.dwEndNpc, questDB.dwID); return; } uint npcid = 0; if (taskInfo.IsKillMonster(out npcid)) { Client.ISkillPart skillPart = Client.ClientGlobal.Instance().MainPlayer.GetPart(Client.EntityPart.Skill) as Client.ISkillPart; if (skillPart != null) { if (skillPart.GetCurSkillState() != (int)Client.SkillState.None) { m_nDoingTaskID = taskInfo.taskId; Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.SKILLNONESTATE_ENTER, OnEvent); Engine.Utility.Log.Info("等待.......技能播放完毕 执行任务{0}", m_nDoingTaskID); return; } } } //令牌悬赏无交任务npc if (taskInfo.taskType != GameCmd.TaskType.TaskType_Token) { DataManager.Manager <RideManager>().TryUsingRide(delegate(object o) { VisitNpc(questDB.dwHelpCommit, questDB.submitMapID, questDB.dwEndNpc, questDB.dwID); }, null); } }
private void OnPlayerStopMove(ref Client.stEntityStopMove stopEntity, int nEventId) { if (!Client.ClientGlobal.Instance().IsMainPlayer(stopEntity.uid)) { return; } if (m_nDoingTaskID == 0) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; return; } QuestTraceInfo questInfo = QuestTranceManager.Instance.GetQuestTraceInfo(m_nDoingTaskID); if (questInfo == null) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; return; } if (EqualsMapID(questInfo.QuestTable.destMapID)) { Engine.Utility.EventEngine.Instance().RemoveEventListener(nEventId, OnEvent); m_bAddStopMoveListener = false; uint npcid; Vector2 pos; if (questInfo.IsKillMonster(out npcid)) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms.GetClienNpcPos((int)npcid, out pos)) { UnityEngine.Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if (mainPos.x == pos.x && mainPos.z == -pos.y) { Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetCombatRobot().StartWithTarget((int)npcid); Engine.Utility.Log.LogGroup("ZCX", "挂机杀怪物{0}", npcid); } } } } else if (questInfo.IsMoveToTargetPos(out pos)) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_SEARCHPATH, false); UnityEngine.Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos(); if (mainPos.x == pos.x && mainPos.z == -pos.y) { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MainUsePanel)) { return; } MainUsePanelData mainUsePanelData = new MainUsePanelData(); mainUsePanelData.type = 2; // type = 2为item mainUsePanelData.Id = questInfo.QuestTable.usecommitItemID; mainUsePanelData.onClick = MainUsePanelItemOnClick; this.usecommitItemID = questInfo.QuestTable.usecommitItemID; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.MainUsePanel, data: mainUsePanelData); // DataManager.Manager<UIPanelManager>().ShowPanel(PanelID.MainUsePanel, data: questInfo.QuestTable.usecommitItemID); } } } }