/// <summary> /// 完成任务 /// </summary> public bool CompleteTask(Task task) { if (!task) { return(false); } task = ResMgr.Instance.Load <Task>(task.TaskID); if (OnGoingTask != null && task.IsComplete) { cmpleteTask = task; task.IsOngoing = false; OnGoingTask = null; DoneTaskList.Add(task); GameDataMgr.Instance.CompleteTask(task); //如果该任务在中转站中,需要消除 if (TaskGiverMgr.Instance.GiverTransferStation.ContainsKey(task.CmpltNpcID)) { TaskGiverMgr.Instance.GiverTransferStation.Remove(task.CmpltNpcID); } foreach (Objective o in task.Objectives) { o.OnFinishThisEvent -= UpdateCollectObjectives; if (o is CollectObjective) { CollectObjective co = o as CollectObjective; GameDataMgr.Instance.RemoveTaskCoItem(co.ItemID, co.Amount); GameDataMgr.Instance.playerInfo.OnGetItemEvent -= co.UpdateCollectAmountUp; } if (o is KillObjective) { KillObjective ko = o as KillObjective; LevelManager.Instance.OnDeathEvent -= ko.UpdateKillAmount; } if (o is TalkObjective) { TalkObjective to = o as TalkObjective; if (TaskGiverMgr.Instance.CmpDbTransferStation.ContainsKey(to.TalkerID)) { TaskGiverMgr.Instance.CmpDbTransferStation.Remove(to.TalkerID); } TaskGiverMgr.Instance.OnTalkFinishEvent -= to.UpdateTalkStatus; } } //奖励 if (task.OnCmpltDialog != null) { DialogMgr.Instance.rewardEvent += Reward; } else { Reward(); } return(true); } return(false); }
/// <summary> /// 初始化 /// </summary> public void Init() { DoneTaskList.Clear(); OnGoingTask = null; foreach (string id in GameDataMgr.Instance.playerInfo.taskDoneList) { DoneTaskList.Add(ResMgr.Instance.Load <Task>(id)); } foreach (string id in GameDataMgr.Instance.playerInfo.currentTaskList) { OnGoingTask = ResMgr.Instance.Load <Task>(id); LoadTask(OnGoingTask); } }