Exemplo n.º 1
0
    private void LoadDummyTasks(int currentTaskCount)
    {
        // load the dummy tasks
        List <Task> allTasks = JsonHelper.DeserializeFromFile <List <Task> >(Path.Combine(Application.streamingAssetsPath, GetDummyTaskFileName()));

        // reduce the tasks to the tasks which are supported by the interaction technique and do correspond with study type
        List <Task> possibleDummyTasks = new List <Task>();
        InteractionTechniqueConf it    = chosenTechniques[0];

        foreach (Task task in allTasks)
        {
            if (TechniqueSupportsTask(currentPhase, it, task) && TaskInStudy(task))
            {
                possibleDummyTasks.Add(task);
            }
        }

        // determine needed number of dummy tasks
        int dummyTasksCount = (isSelectionStudy() ? targetTaskCountSelection : targetTaskCountManipulation) - currentTaskCount;

        // add needed number of dummy tasks to list
        dummyTasks = new List <Task>();
        for (int i = 0; i < dummyTasksCount; i++)
        {
            dummyTasks.Add(possibleDummyTasks[i % possibleDummyTasks.Count]);
        }
        dummyTasks = dummyTasks.OrderBy(a => Random.value).ToList();

        // reset dummy count
        taskCount = GetCurrentTaskCount();
    }
Exemplo n.º 2
0
    /// <summary>
    /// Checks whether the interaction technique supports the required tasks types.
    /// </summary>
    private bool TechniqueSupportsTask(TaskPhase taskPhase, InteractionTechniqueConf technique, Task task)
    {
        // technique does not support required distance
        if (task.distance > technique.maxSupportedDistance)
        {
            return(false);
        }

        // task does not support required task
        if (taskPhase != TaskPhase.Training && !technique.supportedTaskTypes.HasFlag(task.taskTypes))
        {
            return(false);
        }

        if (taskPhase == TaskPhase.Training)
        {
            // task requires selection but technique does not support it
            if (task.taskTypes.HasFlag(TaskType.Selection) && !technique.supportedTaskTypes.HasFlag(TaskType.Selection))
            {
                return(false);
            }

            // task requires manipulation task but technique does not support it
            // it is sufficient if technique supports any manipulation if a manipulation task type is required in a training task
            // the task will be adapted in the training phase so we don't need a training task for each task type and distance
            if (task.taskTypes > TaskType.Selection && technique.supportedTaskTypes <= TaskType.Selection)
            {
                return(false);
            }
        }

        return(true);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Loads the next tasks from a json file.
    /// </summary>
    private void LoadNextTasks()
    {
        // activate next interaction technique, if we are currently in the training phase
        if (currentPhase == TaskPhase.Training)
        {
            noneTechnique.SetActive(false);
            if (currentTechnique != null)
            {
                currentTechnique.SetActive(false);
            }
            currentTechnique = interactionTechniques.transform.Find(chosenTechniques[0].name).gameObject;
            currentTechnique.SetActive(true);
        }

        // load the training tasks if we are in the training phase - otherwise load the next tasks
        List <Task> allTasks = JsonHelper.DeserializeFromFile <List <Task> >(Path.Combine(Application.streamingAssetsPath,
                                                                                          currentPhase == TaskPhase.Training ? "trainingTasks.json" : GetTaskFileName()));

        // reduce the tasks to the tasks which are supported by the interaction technique and do correspond with study type
        tasks = new Dictionary <TaskTypeDistance, List <Task> >();
        InteractionTechniqueConf it = chosenTechniques[0];

        foreach (Task task in allTasks)
        {
            TaskTypeDistance ttk = new TaskTypeDistance(task.taskTypes, task.distance);
            if (TechniqueSupportsTask(currentPhase, it, task) && TaskInStudy(task))
            {
                if (!tasks.ContainsKey(ttk))
                {
                    tasks.Add(ttk, new List <Task>());
                }
                tasks[ttk].Add(task);
            }
        }

        // randomize the order of the task blocks (but if we are in training phase put manipulation tasks first)
        taskTypeOrder = new List <TaskTypeDistance>(tasks.Keys);
        taskTypeOrder = currentPhase == TaskPhase.Training
            ? taskTypeOrder.OrderByDescending(a => a.sortingValue).ToList()
            : taskTypeOrder.OrderBy(a => a.sortingValue).ToList();

        // randomize the order in the task blocks
        foreach (TaskTypeDistance taskType in taskTypeOrder)
        {
            tasks[taskType] = tasks[taskType].OrderBy(a => Random.value).ToList();
        }

        // set task count for status text
        taskCount = GetCurrentTaskCount();

        // load dummy tasks and skip tasks if necessary
        if (currentPhase != TaskPhase.Training)
        {
            LoadDummyTasks(taskCount);
            SkipTasks();
        }
    }