예제 #1
0
    public void ResetQuestlines()
    {
        foreach (var questline in _questlines)
        {
            questline.IsDone = false;


            foreach (var quest in questline.Quests)
            {
                quest.IsDone = false;


                foreach (var step in quest.Steps)
                {
                    step.IsDone = false;
                }
            }
        }
        _currentQuest          = null;
        _currentQuestline      = null;
        _currentStep           = null;
        _currentQuestIndex     = 0;
        _currentQuestlineIndex = 0;
        _currentStepIndex      = 0;
        //Start Questline with the new data
        StartQuestline();
    }
    private void LoadAllQuestsData()
    {
        //Load all questlines
        FindAllSOByType(out QuestlineSO[] questLineSOs);
        RefreshListView(out ListView allQuestlinesListView, "questlines-list", questLineSOs);
        ClearElements(SelectionType.Questline);
        allQuestlinesListView.onSelectionChange += (questlineEnumerable) =>
        {
            _currentSelectedQuestLine = GetDataFromListViewItem <QuestlineSO>(questlineEnumerable);
            ClearElements(SelectionType.Questline);
            _idQuestlineSelected = allQuestlinesListView.selectedIndex;

            if (_currentSelectedQuestLine.Quests != null)
            {
                RefreshListView(out ListView allQuestsListView, "quests-list", _currentSelectedQuestLine.Quests.ToArray());

                allQuestsListView.onSelectionChange += (questEnumerable) =>
                {
                    _idQuestSelected = allQuestsListView.selectedIndex;

                    _currentSeletedQuest = GetDataFromListViewItem <QuestSO>(questEnumerable);
                    ClearElements(SelectionType.Quest);
                    if (_currentSeletedQuest != null && _currentSeletedQuest.Steps != null)
                    {
                        RefreshListView(out ListView allStepsListView, "steps-list", _currentSeletedQuest.Steps.ToArray());

                        SetUpQuestPreview(_currentSeletedQuest);

                        allStepsListView.onSelectionChange += (stepEnumerable) =>
                        {
                            _idStepSelected      = allStepsListView.selectedIndex;
                            _currentSelectedStep = GetDataFromListViewItem <StepSO>(stepEnumerable);
                            DisplayAllProperties(_currentSelectedStep, "step-info-scroll");
                            ClearElements(SelectionType.Step);
                            //Find all DialogueDataSOs in the same folder of the StepSO
                            FindAllDialogueInStep(_currentSelectedStep, out DialogueDataSO[] dialogueDataSOs);
                            if (dialogueDataSOs != null)
                            {
                                RefreshListView(out ListView dialoguesListView, "dialogues-list", dialogueDataSOs);

                                dialoguesListView.onSelectionChange += (dialogueEnumerable) =>
                                {
                                    DialogueDataSO dialogueData = GetDataFromListViewItem <DialogueDataSO>(dialogueEnumerable);
                                    DisplayAllProperties(dialogueData, "dialogue-info-scroll");
                                };
                            }
                            VisualElement DialogueList = rootVisualElement.Q <VisualElement>("dialogues-list");
                            SetAddDialogueButtonsForStep(out VisualElement ButtonsPanel);
                            //DialogueList.Q<VisualElement>("buttons-panel").Clear();
                            DialogueList.Add(ButtonsPanel);
                        };
                    }
                };
            }
        };
    }
    private void LoadAllQuestsData()
    {
        Debug.Log("LoadAllQuestsData");
        //Load all questlines
        FindAllSOByType(out QuestlineSO[] questLineSOs);
        RefreshListView(out ListView allQuestlinesListView, "questlines-list", questLineSOs);

        allQuestlinesListView.onSelectionChange += (questlineEnumerable) =>
        {
            selectedQuestLine = GetDataFromListViewItem <QuestlineSO>(questlineEnumerable);
            ClearElements(selectionType.Questline);
            idQuestlineSelected = allQuestlinesListView.selectedIndex;

            if (selectedQuestLine.Quests != null)
            {
                RefreshListView(out ListView allQuestsListView, "quests-list", selectedQuestLine.Quests.ToArray());



                allQuestsListView.onSelectionChange += (questEnumerable) =>
                {
                    idQuestSelected = allQuestsListView.selectedIndex;

                    currentSeletedQuest = GetDataFromListViewItem <QuestSO>(questEnumerable);
                    ClearElements(selectionType.Quest);
                    if (currentSeletedQuest != null && currentSeletedQuest.Steps != null)
                    {
                        RefreshListView(out ListView allStepsListView, "steps-list", currentSeletedQuest.Steps.ToArray());

                        SetUpQuestPreview(currentSeletedQuest);

                        allStepsListView.onSelectionChange += (stepEnumerable) =>
                        {
                            StepSO step = GetDataFromListViewItem <StepSO>(stepEnumerable);
                            DisplayAllProperties(step, "step-info-scroll");
                            ClearElements(selectionType.Step);
                            //Find all DialogueDataSOs in the same folder of the StepSO
                            FindAllDialogueInStep(step, out DialogueDataSO[] dialogueDataSOs);
                            if (dialogueDataSOs != null)
                            {
                                RefreshListView(out ListView dialoguesListView, "dialogues-list", dialogueDataSOs);

                                dialoguesListView.onSelectionChange += (dialogueEnumerable) =>
                                {
                                    DialogueDataSO dialogueData = GetDataFromListViewItem <DialogueDataSO>(dialogueEnumerable);

                                    DisplayAllProperties(dialogueData, "dialogue-info-scroll");
                                };
                            }
                        };
                    }
                };
            }
        };
    }
예제 #4
0
 void StartQuestline()
 {
     if (_questlines != null)
     {
         if (_questlines.Exists(o => !o.IsDone))
         {
             _currentQuestlineIndex = _questlines.FindIndex(o => !o.IsDone);
             if (_currentQuestlineIndex >= 0)
             {
                 _currentQuestline = _questlines.Find(o => !o.IsDone);
             }
         }
     }
 }
    void AddQuestline()
    {
        //get questline id
        FindAllSOByType(out QuestlineSO[] questLineSOs);
        int id = questLineSOs.Length;

        id++;
        QuestlineSO asset = ScriptableObject.CreateInstance <QuestlineSO>();

        asset.SetQuestlineId(id);
        AssetDatabase.CreateFolder("Assets/ScriptableObjects/Quests", "Questline" + id);
        AssetDatabase.CreateAsset(asset, "Assets/ScriptableObjects/Quests/Questline" + id + "/QL" + id + ".asset");
        AssetDatabase.SaveAssets();
        //refresh
        LoadAllQuestsData();
    }