Exemplo n.º 1
0
 /// <summary>
 /// 根据选择读取下一个对话
 /// </summary>
 /// <param name="selectionIndex">选项序号</param>
 /// <param name="readData">对话内容</param>
 /// <param name="commandAuto">自动执行指令</param>
 /// <returns>有可读的对话</returns>
 public static bool Next(int selectionIndex, ref ReadData readData, bool commandAuto = true)
 {
     if (Ins.m_currentData == null)
     {
         Debug.LogWarning("剧本未读取");
         return(false);
     }
     if (selectionIndex >= 0 && selectionIndex < Ins.CurrentDialogue.selections.Count)
     {
         ScenarioDialogue dialogue = Ins.CurrentDialogue;
         //触发选择行动
         ScenarioDialogue.Selection selection = dialogue.selections[selectionIndex];
         ScenarioAction             act       = selection.selectionAction;
         if (act != null)
         {
             if (act.instantiate)
             {
                 act = Instantiate(act);
             }
             act.DoAction();
         }
         return(Read(selection.nextScenario, ref readData, commandAuto));
     }
     else
     {
         Debug.LogError("序号不在选项范围内");
         return(Next(ref readData, commandAuto));
     }
 }
Exemplo n.º 2
0
        protected virtual void SetSelectionText(ScenarioData scenario, ScenarioDialogue dialogue)
        {
            List <ScenarioDialogue.Selection> selections = dialogue.selections;
            int selectionListLength = 0;

            if (selections != null)
            {
                selectionListLength = selections.Count;
            }
            selectionText = new string[selectionListLength];
            for (int i = 0; i < selectionListLength; i++)
            {
                selectionText[i] = scenario.GetLocalText(selections[i].text);
            }
        }
Exemplo n.º 3
0
        protected virtual void SetCharacterData(ScenarioData scenario, ScenarioDialogue dialogue)
        {
            List <ScenarioDialogue.Character> charas = dialogue.characters;
            int charaListLength = 0;

            if (charas != null)
            {
                charaListLength = charas.Count;
            }
            charaName      = new string[charaListLength];
            charaPortarit  = new Sprite[charaListLength];
            charaIsSpeaker = new bool[charaListLength];
            for (int i = 0; i < charaListLength; i++)
            {
                charaName[i]      = charas[i].character.GetCharaName(charas[i].customName);
                charaPortarit[i]  = charas[i].GetPortarit();
                charaIsSpeaker[i] = charas[i].isSpeaker;
            }
        }
Exemplo n.º 4
0
        private void RefreshCommandTime()
        {
            ScenarioDialogue dialogue = CurrentDialogue;

            if (dialogue == null || dialogue.commands == null)
            {
                m_commandTime = 0;
            }
            else
            {
                m_commandTime = 0;
                for (int i = 0; i < dialogue.commands.Count; i++)
                {
                    ScenarioDialogue.Command c = dialogue.commands[i];
                    float time = c.command.GetDuration();
                    if (m_commandTime < time)
                    {
                        m_commandTime = time;
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void DoCurrentCommands()
        {
            ScenarioDialogue dialogue = CurrentDialogue;

            if (dialogue == null || dialogue.commands == null)
            {
                return;
            }
            for (int i = 0; i < dialogue.commands.Count; i++)
            {
                ScenarioDialogue.Command c       = dialogue.commands[i];
                ScenarioCommand          command = c.command;
                if (command != null)
                {
                    if (command.instantiate)
                    {
                        command = Instantiate(command);
                    }
                    currentCommands.Add(command);
                    commandMessages.Add(c.message);
                    StartCoroutine(command.DoCommand(c.message));
                }
            }
        }
Exemplo n.º 6
0
 protected virtual void SetDialogueText(ScenarioData scenario, ScenarioDialogue dialogue)
 {
     dialogueText = scenario.GetLocalText(dialogue.text);
 }
Exemplo n.º 7
0
 public virtual void SetData(ScenarioData scenario, ScenarioDialogue dialogue)
 {
     SetCharacterData(scenario, dialogue);
     SetDialogueText(scenario, dialogue);
     SetSelectionText(scenario, dialogue);
 }