コード例 #1
0
    public void syncCurrentTask()
    {
        if (currentSelection >= 0 && currentSelection < scenario.rawScenario.tasks.Count)
        {
            Scenario.RawTask syncTask = new Scenario.RawTask(scenario.rawScenario.tasks[currentSelection].id);
            // parse all childs
            int i = 0;
            foreach (Transform descUI in scenario.contentUI.transform)
            {
                Descriptor descriptor = descUI.GetComponent <Descriptor>();
                // save name
                if (descriptor.GetType() == typeof(TaskName))
                {
                    syncTask.id = descUI.GetComponentInChildren <TMP_InputField>().text;
                }
                // save objective
                if (descriptor.GetType() == typeof(TaskObjective))
                {
                    syncTask.objective          = descUI.GetComponentInChildren <TMP_InputField>(true).text;
                    syncTask.objectiveViewState = descUI.GetComponentInChildren <Toggle>().isOn;
                }
                // save complexity
                if (descriptor.GetType() == typeof(Complexity))
                {
                    syncTask.rawComplexities.Add(new Scenario.RawComplexity(i, descUI.GetComponentInChildren <TMP_Dropdown>().value));
                }
                // save artefacts
                if (descriptor.GetType() == typeof(Artefact))
                {
                    syncTask.rawArtefacts.Add(new Scenario.RawArtefact(i, descUI.GetComponentInChildren <TMP_InputField>().text));
                }
                // save observations
                if (descriptor.GetType() == typeof(Observation))
                {
                    Transform contentArea = descUI.Find("Content");
                    Scenario.RawObservation newObservation = new Scenario.RawObservation(i, descUI.GetComponentInChildren <Toggle>().isOn, contentArea.GetChild(0).GetComponentInChildren <TMP_InputField>(true).text);
                    foreach (Decision decision in contentArea.GetComponentsInChildren <Decision>(true))
                    {
                        newObservation.addRawDecision(decision.GetComponentInChildren <TMP_InputField>(true).text);
                    }
                    syncTask.rawObservations.Add(newObservation);
                }
                // save working session
                if (descriptor.GetType() == typeof(WorkingSession))
                {
                    Transform contentArea = descUI.Find("Content");
                    Scenario.RawWorkingSession newWorkingSession = new Scenario.RawWorkingSession(i, descUI.GetComponentInChildren <Toggle>().isOn, descUI.Find("Header").GetComponentInChildren <TMP_InputField>(true).text, contentArea.GetChild(0).GetComponentInChildren <TMP_InputField>(true).text, contentArea.GetChild(1).GetComponentInChildren <TMP_InputField>(true).text);
                    foreach (Participant participant in contentArea.GetComponentsInChildren <Participant>(true))
                    {
                        newWorkingSession.addParticipant(participant.transform.GetChild(1).GetComponentInChildren <TMP_InputField>(true).text, participant.transform.GetChild(3).GetComponentInChildren <TMP_InputField>(true).text);
                    }
                    syncTask.rawWorkingSessions.Add(newWorkingSession);
                }
                // save competency
                if (descriptor.GetType() == typeof(Competency))
                {
                    Transform headerArea = descUI.Find("Header");
                    syncTask.rawCompetencies.Add(new Scenario.RawCompetency(i, descUI.GetComponentInChildren <Toggle>().isOn, headerArea.GetChild(2).GetComponent <TMP_Dropdown>().value, headerArea.GetChild(4).GetComponent <TMP_Dropdown>().value, descUI.Find("Content").GetComponentInChildren <TMP_InputField>(true).text));
                }
                // save production
                if (descriptor.GetType() == typeof(Production))
                {
                    syncTask.rawProductions.Add(new Scenario.RawProduction(i, descUI.GetComponentInChildren <Toggle>().isOn, descUI.GetComponentInChildren <TMP_InputField>(true).text));
                }
                // save antecedent
                if (descriptor.GetType() == typeof(Antecedent))
                {
                    syncTask.rawAntecedents.Add(new Scenario.RawAntecedent(i, descUI.GetComponentInChildren <TMP_Dropdown>(true).value));
                }
                // save subtask
                if (descriptor.GetType() == typeof(SubTask))
                {
                    syncTask.rawSubTasks.Add(new Scenario.RawSubTask(i, descUI.GetComponentInChildren <TMP_Dropdown>(true).value));
                }
                i++;
            }

            // override Task
            scenario.rawScenario.tasks[currentSelection] = syncTask;
        }
    }
コード例 #2
0
    public void showTask(int value)
    {
        // save previous task
        syncCurrentTask();
        // remove all childs
        foreach (Transform child in scenario.contentUI.transform)
        {
            GameObjectManager.unbind(child.gameObject);
            GameObject.Destroy(child.gameObject);
        }

        NewComplexityButton.interactable = true;
        NewProductionButton.interactable = true;
        if (value >= 0 && value < scenario.rawScenario.tasks.Count)
        {
            // Load new selected task
            Scenario.RawTask task = scenario.rawScenario.tasks[value];
            // load name
            GameObject taskName = addDescriptor(scenario.taskNamePrefab);
            taskName.GetComponentInChildren <TMP_InputField>().text = task.id;
            // load objective
            GameObject taskObjective = addDescriptor(scenario.taskObjectivePrefab);
            taskObjective.GetComponentInChildren <TMP_InputField>(true).text = task.objective;
            taskObjective.GetComponentInChildren <Toggle>().isOn             = task.objectiveViewState;

            // load other descriptors
            // find max id of descriptors
            int max = -1;
            foreach (Scenario.RawComplexity rawComplexity in task.rawComplexities)
            {
                if (rawComplexity.pos > max)
                {
                    max = rawComplexity.pos;
                }
            }
            foreach (Scenario.RawArtefact rawArtefact in task.rawArtefacts)
            {
                if (rawArtefact.pos > max)
                {
                    max = rawArtefact.pos;
                }
            }
            foreach (Scenario.RawObservation rawObservation in task.rawObservations)
            {
                if (rawObservation.pos > max)
                {
                    max = rawObservation.pos;
                }
            }
            foreach (Scenario.RawWorkingSession rawWorkingSession in task.rawWorkingSessions)
            {
                if (rawWorkingSession.pos > max)
                {
                    max = rawWorkingSession.pos;
                }
            }
            foreach (Scenario.RawCompetency rawCompetency in task.rawCompetencies)
            {
                if (rawCompetency.pos > max)
                {
                    max = rawCompetency.pos;
                }
            }
            foreach (Scenario.RawProduction rawProduction in task.rawProductions)
            {
                if (rawProduction.pos > max)
                {
                    max = rawProduction.pos;
                }
            }
            foreach (Scenario.RawAntecedent rawAntecedent in task.rawAntecedents)
            {
                if (rawAntecedent.pos > max)
                {
                    max = rawAntecedent.pos;
                }
            }
            foreach (Scenario.RawSubTask rawSubTask in task.rawSubTasks)
            {
                if (rawSubTask.pos > max)
                {
                    max = rawSubTask.pos;
                }
            }
            // create descripors in order
            for (int i = 0; i <= max; i++)
            {
                // look for descriptor associated to this pos in all sets
                // check complexity
                foreach (Scenario.RawComplexity rawComplexity in task.rawComplexities)
                {
                    if (rawComplexity.pos == i)
                    {
                        GameObject taskComplexity = addDescriptor(scenario.taskComplexityPrefab);
                        taskComplexity.GetComponentInChildren <TMP_Dropdown>().value = rawComplexity.complexity;
                        NewComplexityButton.interactable = false;
                    }
                }
                // check artefact
                foreach (Scenario.RawArtefact rawArtefact in task.rawArtefacts)
                {
                    if (rawArtefact.pos == i)
                    {
                        GameObject taskArtefact = addDescriptor(scenario.taskArtefactPrefab);
                        taskArtefact.GetComponentInChildren <TMP_InputField>().text = rawArtefact.artefact;
                    }
                }
                // check Observation
                foreach (Scenario.RawObservation rawObservation in task.rawObservations)
                {
                    if (rawObservation.pos == i)
                    {
                        GameObject taskObservation = addDescriptor(scenario.taskObservationPrefab);
                        taskObservation.GetComponentInChildren <TMP_InputField>(true).text = rawObservation.content;
                        foreach (string decisionContent in rawObservation.decisions)
                        {
                            GameObject decision = taskObservation.GetComponent <Observation>().addDecision(scenario.taskDecisionPrefab);
                            decision.GetComponentInChildren <TMP_InputField>(true).text = decisionContent;
                        }
                        taskObservation.GetComponentInChildren <Toggle>().isOn = rawObservation.viewState;
                    }
                }
                // check Working session
                foreach (Scenario.RawWorkingSession rawWorkingSession in task.rawWorkingSessions)
                {
                    if (rawWorkingSession.pos == i)
                    {
                        GameObject taskWorkingSession = addDescriptor(scenario.taskWorkingSessionPrefab);
                        taskWorkingSession.transform.Find("Header").GetComponentInChildren <TMP_InputField>().text = rawWorkingSession.id;
                        Transform contentArea = taskWorkingSession.transform.Find("Content");
                        contentArea.GetChild(0).GetComponentInChildren <TMP_InputField>(true).text = rawWorkingSession.duration;
                        contentArea.GetChild(1).GetComponentInChildren <TMP_InputField>(true).text = rawWorkingSession.organisation;
                        foreach (Scenario.RawParticipant participantContent in rawWorkingSession.participants)
                        {
                            GameObject participant = taskWorkingSession.GetComponent <WorkingSession>().addParticipant(scenario.taskParticipantPrefab);
                            participant.transform.GetChild(1).GetComponentInChildren <TMP_InputField>(true).text = participantContent.profil;
                            participant.transform.GetChild(3).GetComponentInChildren <TMP_InputField>(true).text = participantContent.role;
                        }
                        taskWorkingSession.GetComponentInChildren <Toggle>().isOn = rawWorkingSession.viewState;
                    }
                }
                // check competency
                foreach (Scenario.RawCompetency rawCompetency in task.rawCompetencies)
                {
                    if (rawCompetency.pos == i)
                    {
                        GameObject taskCompetency = addDescriptor(scenario.taskCompetencyPrefab);
                        Transform  headerArea     = taskCompetency.transform.Find("Header");
                        headerArea.GetChild(2).GetComponent <TMP_Dropdown>().value = rawCompetency.type;
                        headerArea.GetChild(4).GetComponent <TMP_Dropdown>().value = rawCompetency.id;
                        taskCompetency.transform.Find("Content").GetComponentInChildren <TMP_InputField>(true).text = rawCompetency.details;
                        taskCompetency.GetComponentInChildren <Toggle>().isOn = rawCompetency.viewState;
                    }
                }
                // check production
                foreach (Scenario.RawProduction rawProduction in task.rawProductions)
                {
                    if (rawProduction.pos == i)
                    {
                        GameObject taskProduction = addDescriptor(scenario.taskProductionPrefab);
                        taskProduction.GetComponentInChildren <TMP_InputField>(true).text = rawProduction.production;
                        taskProduction.GetComponentInChildren <Toggle>().isOn             = rawProduction.viewState;
                        NewProductionButton.interactable = false;
                    }
                }
                // check antecedent
                foreach (Scenario.RawAntecedent rawAntecedent in task.rawAntecedents)
                {
                    if (rawAntecedent.pos == i)
                    {
                        GameObject   taskAntecedent = addDescriptor(scenario.taskAntecedentPrefab);
                        TMP_Dropdown drop           = taskAntecedent.GetComponentInChildren <TMP_Dropdown>(true);
                        drop.value = rawAntecedent.antecedent;
                        drop.RefreshShownValue();
                    }
                }
                // check subtask
                foreach (Scenario.RawSubTask rawSubTask in task.rawSubTasks)
                {
                    if (rawSubTask.pos == i)
                    {
                        GameObject   taskSubTask = addDescriptor(scenario.taskSubTaskPrefab);
                        TMP_Dropdown drop        = taskSubTask.GetComponentInChildren <TMP_Dropdown>(true);
                        drop.value = rawSubTask.subTask;
                        drop.RefreshShownValue();
                    }
                }
            }

            // remember current selection
            currentSelection = value;
        }
    }
コード例 #3
0
    public void onNewMovableTask(GameObject go)
    {
        // update position and collider
        if (go.transform.localPosition.x == 0 && go.transform.localPosition.y == 0 && go.transform.localPosition.z == 0)
        {
            go.transform.localPosition = new Vector3(go.transform.localPosition.x + (go.transform as RectTransform).rect.width / 2 + 200, go.transform.localPosition.y - (go.transform as RectTransform).rect.height / 2 - 200, 0);
        }
        go.GetComponent <BoxCollider2D>().size = new Vector2((go.transform as RectTransform).rect.width, (go.transform as RectTransform).rect.height);

        MoveTask mt = go.GetComponent <MoveTask>();

        // process antecedents/nexts
        Scenario.RawTask task = scenario.rawScenario.tasks[mt.scenarioId];
        foreach (Scenario.RawAntecedent rawAntecedent in task.rawAntecedents)
        {
            // create an antecedent linker
            GameObject linker = GameObject.Instantiate(mt.antecedentPrefab);
            LinkedWith link   = linker.GetComponent <LinkedWith>();
            // set link to the antecedent task
            link.link = scenario.rawScenario.tasks[rawAntecedent.antecedent].linkedMovableUI;
            GameObjectManager.bind(linker);
            // add linker to next task
            GameObjectManager.setGameObjectParent(linker, go, true);
            // move at the right of my antecedent
            go.transform.localPosition = new Vector3(link.link.transform.localPosition.x + 100, link.link.transform.localPosition.y, 0);

            // create a next linker
            linker = GameObject.Instantiate(mt.nextPrefab);
            link   = linker.GetComponent <LinkedWith>();
            // set link to the next task
            link.link = go;
            GameObjectManager.bind(linker);
            // add linker to the antecedent task
            GameObjectManager.setGameObjectParent(linker, scenario.rawScenario.tasks[rawAntecedent.antecedent].linkedMovableUI, true);
        }

        // process subtasks/parent
        foreach (Scenario.RawSubTask rawSubTask in task.rawSubTasks)
        {
            // create a sub task linker
            GameObject linker = GameObject.Instantiate(mt.subTaskPrefab);
            LinkedWith link   = linker.GetComponent <LinkedWith>();
            // set link to the sub task
            link.link = scenario.rawScenario.tasks[rawSubTask.subTask].linkedMovableUI;
            GameObjectManager.bind(linker);
            // add linker to the parent task
            GameObjectManager.setGameObjectParent(linker, go, true);
            // hide sub task
            GameObjectManager.setGameObjectState(link.link, false);
            // hide line renderer
            GameObjectManager.setGameObjectState(linker, false);
            // move sub task under me
            link.link.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y - 80, 0);

            // create a parent linker
            linker = GameObject.Instantiate(mt.parentPrefab);
            link   = linker.GetComponent <LinkedWith>();
            // set link to the parent task
            link.link = go;
            GameObjectManager.bind(linker);
            // add linker to the sub task
            GameObjectManager.setGameObjectParent(linker, scenario.rawScenario.tasks[rawSubTask.subTask].linkedMovableUI, true);
        }
        // By default hide this task => see onMovableTaskHidden for enabling
        GameObjectManager.setGameObjectState(go, false);
    }