/// <summary> /// 获取任务栏比指定任务排序优先级要高的任务数量 /// </summary> /// <param name="taskId"></param> /// <returns></returns> public uint GetVisibleOnBarHigherPriority2TasksNum(uint taskId) { uint num = 0; TaskDefine taskDefine = TaskDefine.MakeDefine(taskId); if (taskDefine != null) { foreach (Task task in VisibleOnBarTasks) { // 非主线和支线且不可接的任务不显示 if (task.Define.Type != GameConst.QUEST_MAIN && task.Define.Type != GameConst.QUEST_BRANCH && task.State == GameConst.QUEST_STATE_UNACCEPT) { continue; } // 没有帮派则不显示帮派任务 if (task.Define.Type == GameConst.QUEST_GUILD && xc.LocalPlayerManager.Instance.GuildID == 0) { continue; } // 排除已完成的任务 if (task.State == GameConst.QUEST_STATE_DONE) { continue; } if (task.Define.ShowPriority2 < taskDefine.ShowPriority2) { ++num; } } } return(num); }
public static void HandleServerData(ushort protocol, byte[] data) { switch (protocol) { case NetMsg.MSG_TASK_INFO: { S2CTaskInfo pack = S2CPackBase.DeserializePack <S2CTaskInfo>(data); // 首先所有任务的置顶取消 foreach (Task task in TaskManager.Instance.AllTasks) { task.IsOnTop = false; } IsFirstReceiveTaskInfo = !Game.Instance.AllSystemInited; List <Task> newTasks = new List <Task>(); newTasks.Clear(); List <Task> finishedTasks = new List <Task>(); finishedTasks.Clear(); List <Task> newAcceptTasks = new List <Task>(); newAcceptTasks.Clear(); List <Task> doneTasks = new List <Task>(); doneTasks.Clear(); List <Task> tasksToGuide = new List <Task>(); tasksToGuide.Clear(); bool isTitleTaskChanged = false; // 头衔任务是否改变 bool isEscortTaskChanged = false; // 护送任务是否改变 foreach (PkgTaskInfo taskInfo in pack.tasks) { bool isNewTask = false; if (TaskManager.Instance.HasTask(taskInfo.id)) { TaskManager.Instance.DeleteTask(taskInfo.id); } else { isNewTask = true; } var dbTask = TaskDefine.MakeDefine(taskInfo.id); if (dbTask == null) { GameDebug.LogError("Error!!! Can not find task data in db by id " + taskInfo.id); continue; } Task task = new Task(dbTask); uint index = 1; foreach (var step in dbTask.Steps) { Task.StepProgress stepProgress = new Task.StepProgress(); stepProgress.StepId = index; if (taskInfo.value.Count > 0) { stepProgress.CurrentValue = taskInfo.value[0]; } else { stepProgress.CurrentValue = 0; } task.StepProgresss.Add(stepProgress); ++index; } task.StepProgresss.Sort(); task.State = taskInfo.state; task.StartTime = taskInfo.start_time; if (taskInfo.step > 0) { task.CurrentStepIndex = taskInfo.step - 1; } else { task.CurrentStepIndex = 0; } // 提高任务显示优先级 if (IsFirstReceiveTaskInfo == false) { // 头衔任务不受动态排序规则影响 if (task.Define.Type != GameConst.QUEST_TITLE) { Task.IncreaseCurDynamicShowPriority(); task.DynamicShowPriority = Task.CurDynamicShowPriority; } } TaskManager.Instance.AddTask(task); if (task.State == GameConst.QUEST_STATE_DONE) { Task.StepProgress stepProgress = task.CurrentStepProgress; TaskDefine.TaskStep curStep = task.CurrentStep; if (stepProgress != null && curStep != null) { stepProgress.CurrentValue = curStep.ExpectResult; } } // 是否是新接取的任务 if (IsFirstReceiveTaskInfo == false && task.State == GameConst.QUEST_STATE_DOING) { if (task.CurrentStepProgress != null && task.CurrentStepProgress.CurrentValue == 0) { newAcceptTasks.Add(task); } } // 是否自动执行,进入游戏首次收到这个消息不执行副本状态下不执行,新任务不执行,不是在追踪状态的任务不执行 if (IsFirstReceiveTaskInfo == false && SceneHelp.Instance.IsInNormalWild() == true && task.Define.AutoRunType != TaskDefine.EAutoRunType.None) { // 不可接或者失效的任务不可自动执行 if (taskInfo.state != GameConst.QUEST_STATE_UNACCEPT && taskInfo.state != GameConst.QUEST_STATE_INVALID) { if ((task.Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun) { // 如果当前正在导航的任务的自动执行是ForceAutoRun2,则其他任务的自动执行不会打断它 Task navigatingTask = TaskManager.Instance.NavigatingTask; if (navigatingTask == null || navigatingTask.Define.AutoRunType != TaskDefine.EAutoRunType.ForceAutoRun2) { if (taskInfo.state == GameConst.QUEST_STATE_DOING || taskInfo.state == GameConst.QUEST_STATE_DONE) { tasksToGuide.Add(task); } } } else if (task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2) { tasksToGuide.Add(task); } } } if (IsFirstReceiveTaskInfo == false) { if (taskInfo.state == GameConst.QUEST_STATE_FIN) { finishedTasks.Add(task); } } if (IsFirstReceiveTaskInfo == false) { if (taskInfo.state == GameConst.QUEST_STATE_DONE) { doneTasks.Add(task); } } // 任务进度飘字 if (isNewTask == false && taskInfo.state == GameConst.QUEST_STATE_DONE) { TaskHelper.ShowTaskProgressTips(task); } if (IsFirstReceiveTaskInfo == false && isNewTask == true) { newTasks.Add(task); } if (task.Define.Type == GameConst.QUEST_TITLE) { isTitleTaskChanged = true; } if (task.Define.Type == GameConst.QUEST_ESCORT) { isEscortTaskChanged = true; } } //TaskManager.Instance.SortTaskList(); //ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CHANGED, null); StartTaskChangedCoroutine(); if (isTitleTaskChanged == true) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.TITLE_TASK_CHANGED, null); } if (isEscortTaskChanged == true) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.ESCORT_TASK_CHANGED, null); } if (finishedTasks.Count > 0) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_FINISHED, new CEventBaseArgs(finishedTasks[0].Define.Id)); if (finishedTasks[0].Define.SubmitedTimelineId > 0) { // 是否是婚宴剧情动画 if (finishedTasks[0].Define.SubmitedTimelineId == GameConstHelper.GetUint("GAME_WEDDING_DRAMA_TIMELINE_ID_1")) { TimelineManager.Instance.PlayWeddingChapelTimeline(); } else { TimelineManager.Instance.Play(finishedTasks[0].Define.SubmitedTimelineId); } } } if (newAcceptTasks.Count > 0) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_NEW_ACCEPTED, new CEventBaseArgs(newAcceptTasks[0].Define.Id)); if (newAcceptTasks[0].Define.ReceivedTimelineId > 0) { // 是否是婚宴剧情动画 if (newAcceptTasks[0].Define.ReceivedTimelineId == GameConstHelper.GetUint("GAME_WEDDING_DRAMA_TIMELINE_ID_1")) { TimelineManager.Instance.PlayWeddingChapelTimeline(); } else { TimelineManager.Instance.Play(newAcceptTasks[0].Define.ReceivedTimelineId); } } // 如果在副本里面接受了AutoRun的赏金任务或者帮派任务,则Post一个TASK_GUIDE的event,等退出副本再次导航这个任务 if (SceneHelp.Instance.IsInInstance == true) { if ((newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun || newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2) { BountyTaskInfo bountyTaskInfo = TaskManager.Instance.BountyTaskInfo; GuildTaskInfo guildTaskInfo = TaskManager.Instance.GuildTaskInfo; // bountyTaskInfo.id == 0即首次接取赏金任务时不自动执行 if (newAcceptTasks[0].Define.Type == GameConst.QUEST_SG && !(bountyTaskInfo != null && bountyTaskInfo.id == 0)) { ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.TASK_GUIDE, new CEventBaseArgs(newAcceptTasks[0].Define.Id)); } // guildTaskInfo.id == 0即首次接取帮派任务时不自动执行 else if (newAcceptTasks[0].Define.Type == GameConst.QUEST_GUILD && !(guildTaskInfo != null && guildTaskInfo.id == 0)) { ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.TASK_GUIDE, new CEventBaseArgs(newAcceptTasks[0].Define.Id)); } } } } if (doneTasks.Count > 0) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CAN_SUBMIT, new CEventBaseArgs(doneTasks)); } if (SceneHelp.Instance.IsInNormalWild() == true) { if (tasksToGuide.Count > 0) { BountyTaskInfo bountyTaskInfo = TaskManager.Instance.BountyTaskInfo; GuildTaskInfo guildTaskInfo = TaskManager.Instance.GuildTaskInfo; // DoNotAutoRunBountyTaskNextTime为true不自动执行,bountyTaskInfo.id == 0即首次接取赏金任务时不自动执行 if (tasksToGuide[0].Define.Type == GameConst.QUEST_SG && (TaskManager.Instance.DoNotAutoRunBountyTaskNextTime == true || (bountyTaskInfo != null && bountyTaskInfo.id == 0))) { TaskManager.Instance.DoNotAutoRunBountyTaskNextTime = false; } // DoNotAutoRunGuildTaskNextTime为true不自动执行,guildTaskInfo.id == 0即首次接取帮派任务时不自动执行 else if (tasksToGuide[0].Define.Type == GameConst.QUEST_GUILD && (TaskManager.Instance.DoNotAutoRunGuildTaskNextTime == true || (guildTaskInfo != null && guildTaskInfo.id == 0))) { TaskManager.Instance.DoNotAutoRunGuildTaskNextTime = false; } else { // 正在主线任务导航的时候,则不能自动执行其他类型的任务 if ((TaskManager.Instance.IsNavigatingMainTask == false && TaskHelper.MainTaskIsInGuideCoroutine == false) || tasksToGuide[0].Define.Type == GameConst.QUEST_MAIN) { if (tasksToGuide[0].State != GameConst.QUEST_STATE_UNACCEPT && tasksToGuide[0].State != GameConst.QUEST_STATE_FIN && tasksToGuide[0].State != GameConst.QUEST_STATE_INVALID) { if ((TaskManager.Instance.NavigatingTaskType == GameConst.QUEST_NONE || TaskManager.Instance.NavigatingTaskType == tasksToGuide[0].Define.Type) && (TaskHelper.TaskTypeInGuideCoroutine == GameConst.QUEST_NONE || TaskHelper.TaskTypeInGuideCoroutine == tasksToGuide[0].Define.Type)) { // 如果需要自动寻路的任务是第三级别的自动执行,则需要先停止其他的任务寻路 if (tasksToGuide[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2) { TargetPathManager.Instance.StopPlayerAndReset(); } TaskHelper.TaskGuide(tasksToGuide[0]); } } } } } } if (newTasks.Count > 0) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_ADDED, new CEventBaseArgs(newTasks[0].Define.Id)); } TaskNet.HaveReceivedTaskInfo = true; break; } case NetMsg.MSG_TASK_DELETE: { S2CTaskDelete pack = S2CPackBase.DeserializePack <S2CTaskDelete>(data); Task navigatingTask = TaskManager.Instance.NavigatingTask; if (navigatingTask != null && navigatingTask.Define.Id == pack.id) { TaskManager.Instance.NavigatingTask = null; TargetPathManager.Instance.StopPlayerAndReset(false); } TaskManager.Instance.DeleteTask(pack.id); //ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CHANGED, null); StartTaskChangedCoroutine(); break; } case NetMsg.MSG_TASK_VALUE: { S2CTaskValue pack = S2CPackBase.DeserializePack <S2CTaskValue>(data); // 其它所有任务的置顶取消 foreach (Task tempTask in TaskManager.Instance.AllTasks) { if (tempTask.Define.Id != pack.id) { tempTask.IsOnTop = false; } } bool isDone = false; uint value = 0; if (pack.value.Count > 0) { isDone = TaskManager.Instance.ChangeTaskCurStepValue(pack.id, pack.value[0]); value = pack.value[0]; } else { isDone = TaskManager.Instance.ChangeTaskCurStepValue(pack.id, 0); } Task task = TaskManager.Instance.GetTask(pack.id); // 提高任务显示优先级,头衔任务不受动态排序规则影响 if (task != null && task.Define.Type != GameConst.QUEST_TITLE) { Task.IncreaseCurDynamicShowPriority(); task.DynamicShowPriority = Task.CurDynamicShowPriority; } //TaskManager.Instance.SortTaskList(); if (SceneHelp.Instance.IsInNormalWild() == true) { if ((isDone == true || InstanceManager.Instance.IsAutoFighting == false) && task != null && task.Define.AutoRunType != TaskDefine.EAutoRunType.None) { if ((task.Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2) { // 正在主线任务导航的时候,则不能自动执行其他类型的任务 if ((TaskManager.Instance.IsNavigatingMainTask == false && TaskHelper.MainTaskIsInGuideCoroutine == false) || task.Define.Type == GameConst.QUEST_MAIN) { // 进度大于0才自动执行 if (value > 0) { if ((TaskManager.Instance.NavigatingTaskType == GameConst.QUEST_NONE || TaskManager.Instance.NavigatingTaskType == task.Define.Type) && (TaskHelper.TaskTypeInGuideCoroutine == GameConst.QUEST_NONE || TaskHelper.TaskTypeInGuideCoroutine == task.Define.Type)) { TaskHelper.TaskGuide(task); } } } } } } ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_PROGRESS_CHANGED, new CEventBaseArgs(pack.id)); break; } case NetMsg.MSG_TASK_SG_INFO: { S2CTaskSgInfo pack = S2CPackBase.DeserializePack <S2CTaskSgInfo>(data); TaskManager.Instance.BountyTaskInfo = new BountyTaskInfo(pack.id, pack.num, pack.is_reward); if (TaskManager.Instance.BountyTaskInfo.id > 0 || TaskManager.Instance.BountyTaskInfo.is_reward == 0) { TaskManager.Instance.BountyTaskCoinReward = 0; } ClientEventMgr.Instance.FireEvent((int)ClientEvent.BOUNTY_TASK_CHANGED, null); if (IsFirstReceiveBountyTaskInfo == false) { if (TaskManager.Instance.BountyTaskInfo.num >= TaskHelper.GetBountyTaskMaxTimes() && TaskManager.Instance.BountyTaskInfo.is_reward == 0) { if (SceneHelp.Instance.IsInWildInstance() == true) { xc.ui.ugui.UIManager.Instance.ShowSysWindow("UITaskWindow", xc.GameConst.QUEST_SG, null); } else { ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.OPEN_TASK_WINDOW, new CEventBaseArgs(xc.GameConst.QUEST_SG)); } } } IsFirstReceiveBountyTaskInfo = false; xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false); break; } case NetMsg.MSG_TASK_REWARD_SG: { S2CTaskRewardSg pack = S2CPackBase.DeserializePack <S2CTaskRewardSg>(data); TaskManager.Instance.BountyTaskCoinReward = pack.coin; ClientEventMgr.Instance.FireEvent((int)ClientEvent.BOUNTY_TASK_CHANGED, null); break; } case NetMsg.MSG_TASK_GUILD_INFO: { S2CTaskGuildInfo pack = S2CPackBase.DeserializePack <S2CTaskGuildInfo>(data); TaskManager.Instance.GuildTaskInfo = new GuildTaskInfo(pack.id, pack.num, pack.reward_state); //if (TaskManager.Instance.GuildTaskInfo.id > 0 || TaskManager.Instance.GuildTaskInfo.reward_state == 1) //{ // TaskManager.Instance.GuildTaskCtbReward = 0; //} ClientEventMgr.Instance.FireEvent((int)ClientEvent.GUILD_TASK_CHANGED, null); if (IsFirstReceiveGuildTaskInfo == false && TaskManager.Instance.GuildTaskInfo.reward_state == 1) { if (TaskManager.Instance.GuildTaskInfo.num >= GameConstHelper.GetInt("GAME_QUEST_GUILD_PRE_NUM")) { if (SceneHelp.Instance.IsInWildInstance() == true) { xc.ui.ugui.UIManager.Instance.ShowSysWindow("UITaskWindow", xc.GameConst.QUEST_GUILD, null); } else { ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.OPEN_TASK_WINDOW, new CEventBaseArgs(xc.GameConst.QUEST_GUILD)); } } } IsFirstReceiveGuildTaskInfo = false; xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false); break; } case NetMsg.MSG_TASK_REWARD_GUILD: { S2CTaskRewardGuild pack = S2CPackBase.DeserializePack <S2CTaskRewardGuild>(data); TaskManager.Instance.GuildTaskCtbReward = pack.ctb; ClientEventMgr.Instance.FireEvent((int)ClientEvent.GUILD_TASK_CHANGED, null); //UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("BAG_GET_GUILD_CTB"), pack.ctb)); break; } case NetMsg.MSG_TASK_TRANSFER_INFO: { S2CTaskTransferInfo pack = S2CPackBase.DeserializePack <S2CTaskTransferInfo>(data); TaskManager.Instance.TransferTaskInfo = pack; ClientEventMgr.Instance.FireEvent((int)ClientEvent.TRANSFER_TASK_CHANGED, null); break; } case NetMsg.MSG_TASK_REWARD_TRANSFER: { //暂时没有用到 break; } default: break; } }
/// <summary> /// 飞鞋 /// </summary> public static bool TravelBootsJump(Vector3 pos, uint instanceId = 0, bool isFree = false, uint line = 1, bool isAutoFighting = false) { if (instanceId == 0) { instanceId = SceneHelp.Instance.CurSceneID; } if (PKModeManagerEx.Instance.TryToOtherDungeonScene() == false) { return(false); } DBInstance.InstanceInfo instanceInfo = DBInstance.Instance.GetInstanceInfo(instanceId); if (instanceInfo == null) { GameDebug.LogError("Travel boots ump to scene " + instanceId + " error, can not find instance info!!!"); return(false); } // 本地玩家处于护送状态不能用飞鞋 if (CheckLocalPlayerEscortTaskState() == false) { return(false); } // 检查道具 if (isFree == false) { if (VipHelper.GetIsFlyFree() == false) { uint need_goods = GameConstHelper.GetUint("GAME_ITEM_TRAVEL_BOOTS"); if (need_goods > 0) { var num = ItemManager.Instance.GetGoodsNumForBagByTypeId(need_goods); if (num <= 0) { UINotice.Instance.ShowMessage(DBConstText.GetText("ITME_NUM_NOTENOUGH")); return(false); } } } } bool isInstance = false; if (instanceInfo.mWarType == GameConst.WAR_TYPE_DUNGEON) { isInstance = true; } // 检查是否达到等级 uint needLv = InstanceHelper.GetInstanceNeedRoleLevel(instanceId); if (LocalPlayerManager.Instance.LocalActorAttribute.Level < needLv) { // 巅峰等级 uint peakLv = 0; bool isPeak = TransferHelper.IsPeak(needLv, out peakLv); string levelStr = ""; if (isPeak) { levelStr = string.Format(DBConstText.GetText("UI_PLAYER_PEAK_LEVEL_FORMAT_2"), peakLv); // 巅峰{0} } else { levelStr = peakLv.ToString(); // {0} } if (isInstance == true) { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("INSTANCE_IS_NOT_UNLOCK_NEED_LEVEL"), levelStr)); } else { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("WILD_INSTANCE_IS_NOT_UNLOCK_NEED_LEVEL"), levelStr)); } return(false); } // 检查是否通关某主线任务 uint needTaskId = instanceInfo.mNeedTaskId; if (needTaskId > 0) { if (TaskHelper.MainTaskIsPassed(needTaskId) == false) { TaskDefine needTaskDefine = TaskDefine.MakeDefine(needTaskId); if (needTaskDefine != null) { // 巅峰等级 uint peakLv = 0; bool isPeak = TransferHelper.IsPeak((uint)needTaskDefine.RequestLevelMin, out peakLv); string levelStr = ""; if (isPeak) { levelStr = string.Format(DBConstText.GetText("UI_PLAYER_PEAK_LEVEL_FORMAT_2"), peakLv); // 巅峰{0} } else { levelStr = peakLv.ToString(); // {0} } if (isInstance == true) { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("INSTANCE_IS_NOT_UNLOCK_NEED_TASK"), levelStr, needTaskDefine.Name, instanceInfo.mName)); } else { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("WILD_INSTANCE_IS_NOT_UNLOCK_NEED_TASK"), levelStr, needTaskDefine.Name, instanceInfo.mName)); } } return(false); } } // 判断是否可到达 if (instanceId == SceneHelp.Instance.CurSceneID) { if (InstanceHelper.CanWalkTo(pos) == false) { UINotice.Instance.ShowMessage(DBConstText.GetText("MAP_POS_CAN_NOT_REACH")); return(false); } } // 跳往不同的场景需要加个转圈,防止同时多次跳转 if (instanceId != SceneHelp.Instance.CurSceneID) { ui.ugui.UIManager.GetInstance().ShowWaitScreen(true); } C2STravelBootsJump data = new C2STravelBootsJump(); data.dungeon_id = instanceId; data.line = line; PkgNwarPos pkgNwarPos = new PkgNwarPos(); pkgNwarPos.px = (int)(pos.x / GlobalConst.UnitScale); pkgNwarPos.py = (int)(pos.z / GlobalConst.UnitScale); data.pos = pkgNwarPos; if (isFree == true) { data.is_free = 1; } else { data.is_free = 0; } NetClient.BaseClient.SendData <C2STravelBootsJump>(NetMsg.MSG_TRAVEL_BOOTS_JUMP, data); SceneHelp.Instance.IsAutoFightingAfterSwitchInstance = isAutoFighting; InstanceManager.Instance.IsAutoFighting = false; return(true); }