/// <summary> /// 开始该任务 /// </summary> /// <param name="nTaskId"></param> public void GoTo(int nTaskId) { TaskGoToBase taskGoToBase = null; this.m_dicTaskGoToInfo.TryGetValue(nTaskId, out taskGoToBase); if (taskGoToBase != null) { taskGoToBase.Start(); } }
/// <summary> /// 创建任务,添加到List列表中 /// </summary> /// <param name="strGoTo"></param> /// <returns></returns> public TaskGoToBase CreateGoToEvent(string strGoTo) { TaskGoToBase taskGoToBase = this.AddTaskGoTo(strGoTo); if (taskGoToBase != null) { this.m_listTaskGoToBase.Add(taskGoToBase); } return(taskGoToBase); }
/// <summary> /// 添加任务到dic中 /// </summary> /// <param name="nTaskId"></param> public void AddTaskGoTo(int nTaskId) { if (!this.m_dicTaskGoToInfo.ContainsKey(nTaskId)) { TaskGoToBase taskGoToBase = null; TaskMain dataById = TaskMainManager.Instance.GetDataByID(nTaskId); if (dataById != null) { taskGoToBase = this.AddTaskGoTo(dataById.GoTo); } if (taskGoToBase != null) { this.m_dicTaskGoToInfo.Add(nTaskId, taskGoToBase); } } }
/// <summary> /// 每个任务都执行Update /// </summary> public void Update() { foreach (var current in this.m_dicTaskGoToInfo) { current.Value.Update(); } for (int i = this.m_listTaskGoToBase.Count - 1; i >= 0; i++) { TaskGoToBase taskGoToBase = this.m_listTaskGoToBase[i]; if (taskGoToBase != null) { taskGoToBase.Update(); //如果任务已经完成了,就移除该任务 if (taskGoToBase.IsFinish) { this.m_listTaskGoToBase.Remove(taskGoToBase); } } } }
private TaskGoToBase AddTaskGoTo(string strGoTo) { TaskGoToBase taskGoToBase = null; TaskGoToBase result; if (string.IsNullOrEmpty(strGoTo)) { result = taskGoToBase;//也就是为空 } else { try { int num = strGoTo.IndexOf(';'); bool flag = false; if (num < 0) { num = 1; flag = true; } switch (Convert.ToInt32(strGoTo.Substring(0, num))) { case 1: break; } if (taskGoToBase != null && !flag) { string strGoToMsg = strGoTo.Substring(num + 1); taskGoToBase.Init(strGoToMsg); } } catch (Exception e) { XLog.Log.Error(e.ToString()); } result = taskGoToBase; } return(result); }