コード例 #1
0
ファイル: DialogueManager.cs プロジェクト: pengeel/Project-ZT
    /// <summary>
    /// 生成分支对话选项
    /// </summary>
    private void MakeNormalOption()
    {
        if (wordsToSay.Count < 1 || wordsToSay.Peek().Options.Count < 1)
        {
            return;
        }
        DialogueWords currentWords = wordsToSay.Peek();

        dialogueDatas.TryGetValue(currentDialog.ID, out DialogueData dialogDataFound);
        if (CurrentType == DialogueType.Normal)
        {
            ClearOptions(OptionType.Quest, OptionType.Objective);
        }
        else
        {
            ClearOptions();
        }
        bool isLastWords = currentDialog.IndexOfWords(wordsToSay.Peek()) == currentDialog.Words.Count - 1;

        foreach (WordsOption option in currentWords.Options)
        {
            if (option.OptionType == WordsOptionType.Choice && dialogDataFound != null)
            {
                DialogueWordsData wordsDataFound = dialogDataFound.wordsDatas.Find(x => x.wordsIndex == currentDialog.IndexOfWords(currentWords));
                //这个选择型分支是否完成了
                if (isLastWords || wordsDataFound != null && wordsDataFound.IsOptionCmplt(currentWords.IndexOfOption(option)))
                {
                    continue;//是最后一句话或者选项完成则跳过创建
                }
            }
            if (option.IsValid)
            {
                if (option.OptionType == WordsOptionType.OnlyGet && (option.ShowOnlyWhenNotHave && BackpackManager.Instance.HasItemWithID(option.ItemCanGet.ItemID) ||
                                                                     option.OnlyForQuest && option.BindedQuest && !QuestManager.Instance.HasOngoingQuestWithID(option.BindedQuest.ID)))
                {
                    continue;//若已持有当前选项给的道具,或者需任务驱动但任务未接取,则跳过创建
                }
                else if (option.OptionType == WordsOptionType.SubmitAndGet && option.OnlyForQuest && option.BindedQuest &&
                         !QuestManager.Instance.HasOngoingQuestWithID(option.BindedQuest.ID))
                {
                    continue;//若需当前选项需任务驱动但任务未接取,则跳过创建
                }
                OptionAgent oa = ObjectPool.Get(UI.optionPrefab, UI.optionsParent, false).GetComponent <OptionAgent>();
                oa.Init(option.Title, option);
                optionAgents.Add(oa);
            }
        }
        //把第一页以外的选项隐藏
        for (int i = UI.lineAmount - (int)(UI.wordsText.preferredHeight / UI.textLineHeight); i < optionAgents.Count; i++)
        {
            ZetanUtility.SetActive(optionAgents[i].gameObject, false);
        }
        if (optionAgents.Count < 1)
        {
            MakeContinueOption();//如果所有选择型分支都完成了,则可以进行下一句对话
        }
        CheckPages();
        //Debug.Log("make");
        //Debug.Log(optionAgents.Count);
    }
コード例 #2
0
ファイル: DialogueManager.cs プロジェクト: pengeel/Project-ZT
 private bool AllOptionComplete()
 {
     dialogueDatas.TryGetValue(currentDialog.ID, out DialogueData dialogDataFound);
     if (dialogDataFound == null)
     {
         return(false);
     }
     for (int i = 0; i < currentDialog.Words.Count; i++)
     {
         DialogueWordsData wordsDataFound = dialogDataFound.wordsDatas.Find(x => x.wordsIndex == i);
         if (wordsDataFound != null)
         {
             for (int j = 0; j < currentDialog.Words[i].Options.Count; j++)
             {
                 //这个分支是否完成了
                 if (wordsDataFound.IsOptionCmplt(j))
                 {
                     continue;                                 //完成则跳过
                 }
                 else
                 {
                     return(false);//只要有一个没完成,就返回False
                 }
             }
         }
     }
     return(true);
 }