private bool currentTasksCompleted(List <string> taskSet) { foreach (string taskName in taskSet) { Task task = PlayerVariables.getTaskByName(taskName); if (task != null) { if (task.progress < task.steps) { return(false); } } } return(true); }
private void OnTriggerEnter2D(Collider2D collision) { if (currentTaskSet >= taskSets.Count) { // we finished all of our tasks already return; } List <string> taskSet = taskSets[currentTaskSet]; if (currentTasksCompleted(taskSet)) { foreach (string taskName in taskSet) { Task task = PlayerVariables.getTaskByName(taskName); if (task != null) { task.visible = false; } } currentTaskSet += 1; if (currentTaskSet >= taskSets.Count) { // we finished all of our tasks, yippee! return; } List <string> newTaskSet = taskSets[currentTaskSet]; foreach (string taskName in newTaskSet) { Task task = PlayerVariables.getTaskByName(taskName); GiveCorrespondingItemToTask(task); if (task != null) { task.visible = true; } } } }