/// <summary> /// 转到下一句话 /// </summary> public void SayNextWords() { if (wordsToSay.Count < 1) { return; } MakeContinueOption(); if (wordsToSay.Count > 0 && wordsToSay.Peek().Options.Count > 0) { MakeTalkerCmpltQuestOption(); if (AllOptionComplete()) { MakeTalkerObjectiveOption(); } } MakeNormalOption(); if (wordsToSay.Count >= 1) { currentWords = wordsToSay.Peek(); } if (wordsToSay.Count == 1) { HandlingLastWords(); //因为Dequeue之后,话就没了,Words.Count就不是1了,而是0,所以要在Dequeue之前做这一步,意思是倒数第二句做这一步 } if (wordsToSay.Count >= 1) { string talkerName = currentDialog.UseUnifiedNPC ? (currentDialog.UseCurrentTalkerInfo ? CurrentTalker.Info.name : currentDialog.UnifiedNPC.name) : wordsToSay.Peek().TalkerName; if (wordsToSay.Peek().TalkerType == TalkerType.Player && PlayerManager.Instance.PlayerInfo) { talkerName = PlayerManager.Instance.PlayerInfo.name; } UI.nameText.text = talkerName; UI.wordsText.text = HandlingWords(wordsToSay.Peek().Words); wordsToSay.Dequeue(); } if (wordsToSay.Count == 0) { if (wordsOptionInstances.Count > 0) //分支栈不是空的,说明当前对话是其它某句话的一个分支 { HandlingLastOptionWords(); //分支处理比较特殊,放到Dequque之后,否则分支最后一句不会讲 } OnFinishDialogueEvent?.Invoke(); } }
private void HandlingOptions() { buttonDatas.Clear(); if (dialogueToSay.Count > 0 || wordsToSay.Count > 0 && (!currentWords.model.NeedToChusCorrectOption || currentWords.IsDone)) { buttonDatas.Add(new ButtonWithTextData("继续", delegate { SayNextWords(); })); } if (!currentOption && !currentQuest) { var cmpltQuest = currentTalker.QuestInstances.Where(x => x.InProgress && x.IsComplete); if (cmpltQuest != null && cmpltQuest.Count() > 0) { foreach (var quest in cmpltQuest) { buttonDatas.Add(new ButtonWithTextData($"{quest.Model.Title}(已完成)", delegate { currentQuest = quest; ShowButtons(false, false, false, false); StartDialogue(quest.Model.CompleteDialogue); })); } } } if (wordsToSay.Count < 1)//最后一句 { //完成剧情用对话时,结束对话 if (currentWords && currentWords.parent && currentWords.parent.model.StoryDialogue && currentWords.IsDone) { buttonDatas.Add(new ButtonWithTextData("结束", delegate { OnFinishDialogueEvent?.Invoke(); Close(); })); RefreshOptionUI(); return; } if (CurrentType == DialogueType.Gift) { buttonDatas.Add(new ButtonWithTextData("返回", delegate { GoBackDefault(); })); } else { if (currentQuest)//这是由任务引发的对话 { HandlingLast_Quest(); } else if (currentSubmitObj)//这是由提交目标引发的对话 { HandlingLast_SumbitObj(); } else if (currentTalkObj)//这是由对话目标引发的对话 { HandlingLast_TalkObj(); } else if (currentTalker)//普通对话 { HandlingLast_Normal(); } } OnFinishDialogueEvent?.Invoke(); } if (currentWords) { foreach (var option in currentWords.optionDatas) { if (!option.isDone || option.model.OptionType != WordsOptionType.Choice) { string title = option.model.Title; if (option.model.OptionType == WordsOptionType.SubmitAndGet) { title += $"(需[{option.model.ItemToSubmit.ItemName}]{option.model.ItemToSubmit.Amount}个)"; } buttonDatas.Add(new ButtonWithTextData(title, delegate { DoOption(option); })); } } } RefreshOptionUI(); }