Esempio n. 1
0
 public DialogueWordsData(DialogueWords words, DialogueData parent)
 {
     model       = words;
     this.parent = parent;
     if (model.Options.Count > 0 && parent)
     {
         int index = parent.model.Words.IndexOf(words);
         for (int i = 0; i < model.Options.Count; i++)
         {
             int         indexBack = index;
             WordsOption option    = model.Options[i];
             if (words.NeedToChusCorrectOption)
             {
                 if (model.IndexOfCorrectOption == i)
                 {
                     indexBack++;
                 }
             }
             else
             {
                 indexBack = option.IndexToGoBack > 0 && option.OptionType != WordsOptionType.SubmitAndGet && option.OptionType != WordsOptionType.OnlyGet &&
                             parent.model.StoryDialogue && (option.OptionType == WordsOptionType.BranchDialogue || option.OptionType == WordsOptionType.BranchWords) && !option.GoBack
                     ? option.IndexToGoBack : indexBack;
             }
             WordsOptionData od = new WordsOptionData(option, this, indexBack);
             optionDatas.Add(od);
         }
     }
 }
Esempio n. 2
0
 public void GoBackDefault()
 {
     currentOption    = null;
     currentDialogue  = null;
     currentQuest     = null;
     currentSubmitObj = null;
     currentTalkObj   = null;
     currentWords     = null;
     choiceOptionSaid.Clear();
     ClearOptions();
     HideQuestDescription();
     StartTalking(currentTalker);
 }
Esempio n. 3
0
 private void HandlingWords()
 {
     if (wordsToSay.Count < 1)
     {
         if (currentOption)//选项引发的对话最后一句
         {
             if (choiceOptionSaid.Count > 0 && this.currentOption == choiceOptionSaid.Peek())
             {
                 choiceOptionSaid.Pop();
             }
             var currentOption = this.currentOption;
             this.currentOption = null;
             if (currentOption.model.OptionType != WordsOptionType.Choice || currentOption.model.OptionType == WordsOptionType.Choice && currentOption.model.DeleteWhenCmplt)
             {
                 currentOption.isDone = true;
             }
             if (currentOption.model.OptionType == WordsOptionType.Choice && currentOption.parent.model.IsCorrectOption(currentOption.model))//选择型选项的最后一句
             {
                 foreach (var option in currentOption.parent.optionDatas.Where(x => x.model.OptionType == WordsOptionType.Choice))
                 {
                     option.isDone = true;
                 }
                 while (choiceOptionSaid.Count > 0)
                 {
                     var preOption = choiceOptionSaid.Pop();
                     preOption.isDone = true;
                     if (choiceOptionSaid.Count < 1)
                     {
                         foreach (var option in preOption.parent.optionDatas.Where(x => x.model.OptionType == WordsOptionType.Choice))
                         {
                             option.isDone = true;
                         }
                     }
                 }
             }
             else if (currentOption.model.GoBack || currentOption.parent.parent.model.StoryDialogue)
             {
                 DoDialogue(currentOption.parent.parent.model, currentOption.indexToGoBack);
             }
         }
         if (currentWords.IsDone)//整句话完成了才触发事件
         {
             ExecuteEvents(currentWords.model);
         }
     }
     HandlingOptions();
 }
Esempio n. 4
0
    private void DoOption(WordsOptionData option)
    {
        wordsToSay.Clear();
        currentOption = option;

        if (option.model.OptionType == WordsOptionType.SubmitAndGet)
        {
            if (option.model.IsValid)
            {
                if (BackpackManager.Instance.CanLose(option.model.ItemToSubmit.item, option.model.ItemToSubmit.Amount, (ItemWithAmount)option.model.ItemCanGet))
                {
                    BackpackManager.Instance.LoseItem(option.model.ItemToSubmit.item, option.model.ItemToSubmit.Amount, (ItemWithAmount)option.model.ItemCanGet);
                }
                else
                {
                    currentOption = null;
                    return;
                }
            }
            else
            {
                MessageManager.Instance.New("无效的选项");
            }
        }
        if (option.model.OptionType == WordsOptionType.OnlyGet)
        {
            if (option.model.IsValid)
            {
                if (!BackpackManager.Instance.CanGet(option.model.ItemCanGet.item, option.model.ItemCanGet.Amount))
                {
                    currentOption = null;
                    return;
                }
                else
                {
                    BackpackManager.Instance.GetItem(option.model.ItemCanGet.item, option.model.ItemCanGet.Amount);
                }
            }
            else
            {
                MessageManager.Instance.New("无效的选项");
            }
        }
        if (option.model.OptionType == WordsOptionType.Choice)//是选择型选项
        {
            choiceOptionSaid.Push(option);
            if (option.parent.model.IsCorrectOption(option.model))
            {
                DoDialogue(option.parent.parent.model, option.indexToGoBack);
            }
            else
            {
                NewWords(option.parent.model.TalkerType != TalkerType.Player, option.parent.model.WrongChoiceWords);//对话人的类型由句子决定,说的话是句子带的选择错误时说的话
            }
        }
        if (option.model.HasWordsToSay || option.model.OptionType == WordsOptionType.BranchWords)
        {
            NewWords(option.model.TalkerType != TalkerType.Player, option.model.Words);//对话人的类型由选项决定,说的话是选项自带的
        }
        else if (option.model.OptionType == WordsOptionType.BranchDialogue)
        {
            DoDialogue(option.model.Dialogue, option.model.SpecifyIndex);
        }
        SayNextWords();

        void NewWords(bool condition, string words)
        {
            TalkerInformation talkerInfo = null;

            if (condition)
            {
                if (!option.parent.parent.model.UseUnifiedNPC)
                {
                    talkerInfo = option.parent.model.TalkerInfo;
                }
                else if (option.parent.parent.model.UseUnifiedNPC && option.parent.parent.model.UseCurrentTalkerInfo)
                {
                    talkerInfo = currentTalker.GetData <TalkerData>().Info;
                }
                else if (option.parent.parent.model.UseUnifiedNPC && !option.parent.parent.model.UseCurrentTalkerInfo)
                {
                    talkerInfo = option.parent.parent.model.UnifiedNPC;
                }
                wordsToSay.Push(new DialogueWordsData(new DialogueWords(talkerInfo, words), null));
            }
            else
            {
                wordsToSay.Push(new DialogueWordsData(new DialogueWords(null, words, TalkerType.Player), null));
            }
        }
    }