public DialogClip GetDialogClipByLineId(int id)
        {
            DialogueClipDb dialogueClipDb = new DialogueClipDb();
            IDataReader    reader         = dialogueClipDb.GetDataByLineId(id);

            int        itemId     = int.Parse($"{reader[0]}");
            int        lineId     = int.Parse($"{reader[1]}");
            string     path       = $"{reader[2]}";
            DialogClip dialogClip = new DialogClip(id: itemId, lineId: lineId, path: path);

            dialogueClipDb.close();
            return(dialogClip);
        }
    private IEnumerator DialogueLoop()
    {
        bool shouldTheLoopRun     = true;
        int  nextDialogueObjectId = -1;

        while (shouldTheLoopRun)
        {
            decision = -1;
            if (dialogueObject.type.Equals("Line"))
            {
                DialogClip dialogueClip = _clipRepository.GetDialogClipByLineId(dialogueObject.dialogueLines[0].lineId);
                SayLine(dialogueClip);
                PlayAnimation();
                PresentLine(dialogueObject.dialogueLines[0].line);

                yield return(StartCoroutine(SkipOrPlayLine((dialogueObject.dialogueLines[0].line.Length * 50) + 500))); // Time in milliseconds

                nextDialogueObjectId = dialogueObject.dialogueLines[0].nextDialogueObjectId;
            }
            else if (dialogueObject.type.Equals("Decision"))
            {
                PresentDecisions(dialogueObject.dialogueLines);

                StartCoroutine(ReceiveDecisionInputByKeyboard());
                yield return(new WaitUntil(() => decision > -1));

                PresentPlayerLine();
                DialogClip dialogClip = _clipRepository.GetDialogClipByLineId(dialogueObject.dialogueLines[decision].lineId);
                SayLine(dialogClip);
                yield return(StartCoroutine(SkipOrPlayLine((dialogueObject.dialogueLines[decision].line.Length * 50) + 500)));

                ResetPlayerLine();


                nextDialogueObjectId = dialogueObject
                                       .dialogueLines[decision]
                                       .nextDialogueObjectId;
            }
            else if (dialogueObject.type.Equals("End"))
            {
                shouldTheLoopRun = false;
            }
            dialogueObject = dialogueService.GetDialogueObject(nextDialogueObjectId);
        }

        DialogueEnd();
    }
Exemple #3
0
    protected override Playable CreatePlayable(PlayableGraph graph, GameObject go, TimelineClip clip)
    {
        ScriptPlayable <DialogBehaviour> mixer = ScriptPlayable <DialogBehaviour> .Create(graph);

        // TrackとClipに設定された値を取得する
        PlayableDirector content    = go.GetComponent <PlayableDirector>();
        MessageDialog    msgDialog  = content.GetGenericBinding(this) as MessageDialog;
        DialogClip       dialogClip = clip.asset as DialogClip;

        // behaviourに通知
        mixer.GetBehaviour().messageDialog = msgDialog;
        mixer.GetBehaviour().textString    = dialogClip.template.textString;
        mixer.GetBehaviour().hasToPause    = dialogClip.template.hasToPause;
        mixer.GetBehaviour().startTime     = clip.start;
        mixer.GetBehaviour().endTime       = clip.end;

        // トラック上での表記を変更予定の文字列にする
        clip.displayName = dialogClip.template.textString;

        return(mixer);
    }
    public void Reset()
    {
        test_audio_source.clip = null;

        current_menu = null;

        set_visible_once = false;

        last_response = "";

        good_response_index = 0;
        bad_response_index  = 0;

        action_response_clip = null;

        selected_action_widget = false;

        foreach (Menu m in menus)
        {
            if (m.GetComponent <SubtitleWidget>() || (m.transform.parent && m.transform.parent.GetComponent <SubtitleWidget>()) || m.name == "MenuPosition" || m.GetComponent <TeaDialogTree>())
            {
            }
            else
            {
                m.gameObject.SetActive(true);
                Destroy(m.gameObject);
            }
        }
        foreach (Transform go in GetComponentsInChildren <Transform>())
        {
            if (go.GetComponent <SubtitleWidget>() || (go.transform.parent && go.transform.parent.GetComponent <SubtitleWidget>()) || go.name == "MenuPosition" || go.GetComponent <TeaDialogTree>())
            {
            }
            else
            {
                Destroy(go.gameObject);
            }
        }
        Start();
    }
 //Set the dialog clip.
 public void SetDialogClip(AudioClip aclip, AudioSource source, string animationClip, string animatedCharacterName)
 {
     if (aclip == null)
     {
         Debug.LogError("A dialog clip entered was null!");
         return;
     }
     else if (source == null)
     {
         Debug.LogError("Source is null!");
         return;
     }
     if (subtitle_clip == null)
     {
         subtitle_clip = new DialogClip(aclip, source, animationClip, animatedCharacterName);
     }
     else
     {
         subtitle_clip.Reset();
         subtitle_clip.clip = aclip;
     }
 }
 //Set the dialog clip.
 public void SetDialogClip(AudioClip aclip,AudioSource source,string animationClip,string animatedCharacterName)
 {
     if(aclip == null)
     {
         Debug.LogError("A dialog clip entered was null!");
         return;
     }
     else if(source == null)
     {
         Debug.LogError("Source is null!");
         return;
     }
     if(subtitle_clip == null)
     {
         subtitle_clip = new DialogClip(aclip,source,animationClip, animatedCharacterName);
     }
     else
     {
         subtitle_clip.Reset();
         subtitle_clip.clip = aclip;
     }
 }
    public void Reset()
    {
        test_audio_source.clip = null;

        current_menu = null;

        set_visible_once = false;

        last_response = "";

        good_response_index = 0;
        bad_response_index = 0;

        action_response_clip = null;

        selected_action_widget = false;

        foreach(Menu m in menus)
        {
            if(m.GetComponent<SubtitleWidget>() || (m.transform.parent && m.transform.parent.GetComponent<SubtitleWidget>()) || m.name == "MenuPosition" || m.GetComponent<TeaDialogTree>()){}
            else
            {
                m.gameObject.SetActive(true);
                Destroy (m.gameObject);
            }
        }
        foreach(Transform go in GetComponentsInChildren<Transform>())
        {
            if(go.GetComponent<SubtitleWidget>() || (go.transform.parent && go.transform.parent.GetComponent<SubtitleWidget>()) || go.name == "MenuPosition" || go.GetComponent<TeaDialogTree>()){}
            else
                Destroy (go.gameObject);
        }
        Start ();
    }
    private void SayLine(DialogClip dialogClip)
    {
        AudioClip audioClip = dialogClip.GetAudioClip();

        _characterSounds.Dialog(audioClip);
    }