public override void OnEnter() { if (showOnce && executionCount > 0) { Continue(); return; } executionCount++; SayDialog dialog = SetSayDialog.activeDialog; showBasicGUI = false; if (dialog == null) { showBasicGUI = true; return; } dialog.SetCharacter(character); dialog.ShowDialog(true); if (voiceOverClip != null) { MusicController.GetInstance().PlaySound(voiceOverClip, 1f); } dialog.Say(storyText, delegate { dialog.ShowDialog(false); Continue(); }); }
public static SayDialog GetSayDialog() { if (activeSayDialog == null) { // Use first Say Dialog found in the scene (if any) SayDialog sd = GameObject.FindObjectOfType<SayDialog>(); if (sd != null) { activeSayDialog = sd; } if (activeSayDialog == null) { // Auto spawn a say dialog object from the prefab GameObject prefab = Resources.Load<GameObject>("SayDialog"); if (prefab != null) { GameObject go = Instantiate(prefab) as GameObject; go.SetActive(false); go.name = "SayDialog"; activeSayDialog = go.GetComponent<SayDialog>(); } } } return activeSayDialog; }
/// <summary> /// Returns a SayDialog by searching for one in the scene or creating one if none exists. /// </summary> public static SayDialog GetSayDialog() { if (ActiveSayDialog == null) { SayDialog sd = null; // Use first active Say Dialog in the scene (if any) if (activeSayDialogs.Count > 0) { sd = activeSayDialogs[0]; } if (sd != null) { ActiveSayDialog = sd; } if (ActiveSayDialog == null) { // Auto spawn a say dialog object from the prefab GameObject prefab = Resources.Load<GameObject>("Prefabs/SayDialog"); if (prefab != null) { GameObject go = Instantiate(prefab) as GameObject; go.SetActive(false); go.name = "SayDialog"; ActiveSayDialog = go.GetComponent<SayDialog>(); } } } return ActiveSayDialog; }
/// <summary> /// Returns a SayDialog by searching for one in the scene or creating one if none exists. /// </summary> public static SayDialog GetSayDialog() { if (ActiveSayDialog == null) { // Use first Say Dialog found in the scene (if any) SayDialog sd = GameObject.FindObjectOfType <SayDialog>(); if (sd != null) { ActiveSayDialog = sd; } if (ActiveSayDialog == null) { // Auto spawn a say dialog object from the prefab GameObject prefab = Resources.Load <GameObject>("Prefabs/SayDialog"); if (prefab != null) { GameObject go = Instantiate(prefab) as GameObject; go.SetActive(false); go.name = "SayDialog"; ActiveSayDialog = go.GetComponent <SayDialog>(); } } } return(ActiveSayDialog); }
protected virtual void OnWriterState(Writer writer, WriterState writerState) { if (writerState == WriterState.End) { AddLine(SayDialog.GetSayDialog().NameText.text, SayDialog.GetSayDialog().StoryText.text); } }
/// <summary> /// Hides any currently displayed Say Dialog. /// </summary> public virtual void HideSayDialog() { var sayDialog = SayDialog.GetSayDialog(); if (sayDialog != null) { sayDialog.FadeWhenDone = true; } }
public virtual void HideSayDialog() { SayDialog sayDialog = SayDialog.GetSayDialog(); if (sayDialog != null) { sayDialog.FadeOut(); } }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (character != null && character.SetSayDialog != null) { SayDialog.ActiveSayDialog = character.SetSayDialog; } if (setSayDialog != null) { SayDialog.ActiveSayDialog = setSayDialog; } var sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { Continue(); return; } var flowchart = GetFlowchart(); sayDialog.SetActive(true); sayDialog.SetCharacter(character); sayDialog.SetCharacterImage(portrait); sayDialog.SetButtonUIActive(waitForClick); string displayText = storyText; var activeCustomTags = CustomTag.activeCustomTags; for (int i = 0; i < activeCustomTags.Count; i++) { var ct = activeCustomTags[i]; displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith); if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "") { displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith); } } string subbedText = flowchart.SubstituteVariables(displayText); sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate { Continue(); }); }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (character != null && character.SetSayDialog != null) { SayDialog.ActiveSayDialog = character.SetSayDialog; } if (setSayDialog != null) { SayDialog.ActiveSayDialog = setSayDialog; } var sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { Continue(); return; } var flowchart = GetFlowchart(); sayDialog.SetActive(true); sayDialog.SetCharacter(character); sayDialog.SetCharacterImage(portrait); string displayText = storyText; var activeCustomTags = CustomTag.activeCustomTags; for (int i = 0; i < activeCustomTags.Count; i++) { var ct = activeCustomTags[i]; displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith); if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "") { displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith); } } string subbedText = flowchart.SubstituteVariables(displayText); SayAndContinue(sayDialog, subbedText); }
protected virtual void OnWriterState(Writer writer, WriterState writerState) { if (writerState == WriterState.End) { var sd = SayDialog.GetSayDialog(); var from = sd.NameText; var line = sd.StoryText; AddLine(from, line); } }
public override void OnStopExecuting() { var sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { return; } sayDialog.Stop(); }
public override void OnEnter() { if (sayDialog != null) { activeDialog = sayDialog; } // Populate the static cached dialog GetActiveSayDialog(); Continue(); }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (character != null && character.setSayDialog != null) { SayDialog.activeSayDialog = character.setSayDialog; } if (setSayDialog != null) { SayDialog.activeSayDialog = setSayDialog; } SayDialog sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { Continue(); return; } Flowchart flowchart = GetFlowchart(); sayDialog.gameObject.SetActive(true); sayDialog.SetCharacter(character, flowchart); sayDialog.SetCharacterImage(portrait); string displayText = storyText; foreach (CustomTag ct in CustomTag.activeCustomTags) { displayText = displayText.Replace(ct.tagStartSymbol, ct.replaceTagStartWith); if (ct.tagEndSymbol != "" && ct.replaceTagEndWith != "") { displayText = displayText.Replace(ct.tagEndSymbol, ct.replaceTagEndWith); } } string subbedText = flowchart.SubstituteVariables(displayText); sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, voiceOverClip, delegate { Continue(); }); }
public virtual bool AddOption(string text, Sequence targetSequence) { gameObject.SetActive(true); bool addedOption = false; foreach (Button button in cachedButtons) { if (!button.gameObject.activeSelf) { button.gameObject.SetActive(true); Text textComponent = button.GetComponentInChildren <Text>(); if (textComponent != null) { textComponent.text = text; } Sequence sequence = targetSequence; button.onClick.AddListener(delegate { StopAllCoroutines(); // Stop timeout Clear(); gameObject.SetActive(false); // Hide the active Say dialog in case it's still being displayed SayDialog activeSayDialog = SetSayDialog.GetActiveSayDialog(); if (activeSayDialog != null) { activeSayDialog.ShowDialog(false); } if (sequence != null) { #if UNITY_EDITOR // Select the new target sequence in the Fungus Script window FungusScript fungusScript = sequence.GetFungusScript(); fungusScript.selectedSequence = sequence; #endif sequence.ExecuteCommand(0); } }); addedOption = true; break; } } return(addedOption); }
public override void OnEnter() { if (!sayDialogName.Contains("(Clone)")) { sayDialogName = sayDialogName + "(Clone)"; } var thisCanvas = StorySystem.StoryDataUtilities.StoryMainCanvas.transform; sayDialog = thisCanvas.Find(sayDialogName).GetComponent <SayDialog>(); if (sayDialog != null) { SayDialog.ActiveSayDialog = sayDialog; } Continue(); }
protected virtual void OnWriterState(Writer writer, WriterState writerState) { if (writerState == WriterState.End) { var sd = SayDialog.GetSayDialog(); if (sd != null) { NarrativeLogEntry entry = new NarrativeLogEntry() { name = sd.NameText, text = sd.StoryText }; AddLine(entry); } } }
public override void OnCommandAdded(Sequence parentSequence) { // Find last Say command in the sequence, then copy the Say dialog it's using. // This saves a step when adding a new Say command for (int i = parentSequence.commandList.Count - 1; i >= 0; --i) { Say sayCommand = parentSequence.commandList[i] as Say; if (sayCommand != null) { if (sayCommand.sayDialog != null) { sayDialog = sayCommand.sayDialog; break; } } } }
protected virtual SayDialog GetSayDialog(Character character) { SayDialog sayDialog = null; if (character != null) { if (character.SetSayDialog != null) { sayDialog = character.SetSayDialog; } } if (sayDialog == null) { sayDialog = SayDialog.GetSayDialog(); } return(sayDialog); }
protected virtual void Awake() { // Need to do this in Awake rather than Start due to init order issues if (useLegacyAudioLogic) { if (targetAudioSource == null) { targetAudioSource = GetComponent <AudioSource>(); if (targetAudioSource == null) { targetAudioSource = gameObject.AddComponent <AudioSource>(); targetAudioSource.outputAudioMixerGroup = FungusManager.Instance.MainAudioMixer.SFXGroup; } } targetAudioSource.volume = 0f; } attachedSayDialog = GetComponent <SayDialog>(); }
protected virtual SayDialog GetSayDialog(Character character) { SayDialog sayDialog = null; if (character != null) { if (character.SetSayDialog != null) { sayDialog = character.SetSayDialog; } } if (sayDialog == null) { sayDialog = SayDialog.GetSayDialog(); } sayDialog.SetActive(true); SayDialog.ActiveSayDialog = sayDialog; return sayDialog; }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; SayDialog sayDialog = SetSayDialog.GetActiveSayDialog(); if (sayDialog == null) { Continue(); return; } FungusScript fungusScript = GetFungusScript(); sayDialog.SetCharacter(character, fungusScript); sayDialog.SetCharacterImage(portrait); sayDialog.ShowDialog(true); if (voiceOverClip != null) { sayDialog.PlayVoiceOver(voiceOverClip); } string subbedText = fungusScript.SubstituteVariables(storyText); sayDialog.Say(subbedText, waitForInput, delegate { if (waitForInput) { sayDialog.ShowDialog(false); } Continue(); }); }
public static SayDialog GetActiveSayDialog() { if (activeDialog == null) { activeDialog = GameObject.FindObjectOfType<SayDialog>(); } if (activeDialog == null) { // Auto spawn a say dialog from the prefab GameObject go = Resources.Load<GameObject>("FungusSayDialog"); if (go != null) { GameObject spawnedGO = Instantiate(go) as GameObject; spawnedGO.name = "SayDialog"; spawnedGO.SetActive(false); activeDialog = spawnedGO.GetComponent<SayDialog>(); } } return activeDialog; }
public static SayDialog GetActiveSayDialog() { if (activeDialog == null) { activeDialog = GameObject.FindObjectOfType <SayDialog>(); } if (activeDialog == null) { // Auto spawn a say dialog from the prefab GameObject go = Resources.Load <GameObject>("FungusSayDialog"); if (go != null) { GameObject spawnedGO = Instantiate(go) as GameObject; spawnedGO.name = "SayDialog"; spawnedGO.SetActive(false); activeDialog = spawnedGO.GetComponent <SayDialog>(); } } return(activeDialog); }
protected virtual void HideSayDialog() { SayDialog sayDialog = SayDialog.GetSayDialog(); if (sayDialog != null) { bool fadingOut = false; bool movingOut = false; if (sayDialog.alwaysFadeDialog) { sayDialog.FadeOutDialog(); fadingOut = true; } if (sayDialog.alwaysMoveDialog) { sayDialog.MoveOutDialog(); movingOut = true; } if (!fadingOut && !movingOut) { sayDialog.ShowDialog(false); } } }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (setSayDialog != null) { SayDialog.activeSayDialog = setSayDialog; } SayDialog sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { Continue(); return; } Flowchart flowchart = GetFlowchart(); sayDialog.SetCharacter(character, flowchart); sayDialog.SetCharacterImage(portrait); bool fadingIn = false; bool movingIn = false; if (sayDialog.alwaysFadeDialog || fadeIn) { sayDialog.FadeInDialog(); fadingIn = true; } if (sayDialog.alwaysMoveDialog) { sayDialog.MoveInDialog(); movingIn = true; } if (!fadingIn && !movingIn) { sayDialog.ShowDialog(true); } if (voiceOverClip != null) { sayDialog.PlayVoiceOver(voiceOverClip); } string displayText = storyText; foreach (CustomTag ct in CustomTag.activeCustomTags) { displayText = displayText.Replace(ct.tagStartSymbol, ct.replaceTagStartWith); if (ct.tagEndSymbol != "" && ct.replaceTagEndWith != "") { displayText = displayText.Replace(ct.tagEndSymbol, ct.replaceTagEndWith); } } if (extendPrevious) { displayText = "{s=0}" + Dialog.prevStoryText + "{/s}" + displayText; } string subbedText = flowchart.SubstituteVariables(displayText); sayDialog.Say(subbedText, waitForClick, delegate { if (waitForClick) { bool fadingOut = false; bool movingOut = false; if (sayDialog.alwaysFadeDialog || fadeOut) { sayDialog.FadeOutDialog(); fadingOut = true; } if (sayDialog.alwaysMoveDialog) { sayDialog.MoveOutDialog(); movingOut = true; } if (!fadingOut && !movingOut) { sayDialog.ShowDialog(false); } } Continue(); }); }
/// <summary> /// Sync the active say dialog with what Lua thinks the SayDialog should be /// </summary> public void SetSayDialog(SayDialog sayDialog) { SayDialog.ActiveSayDialog = sayDialog; }
/// <summary> /// Parse and execute a conversation string /// </summary> /// <param name="conv"></param> public IEnumerator DoConversation(string conv) { if (string.IsNullOrEmpty(conv)) { yield break; } var conversationItems = Parse(conv); if (conversationItems.Count == 0) { yield break; } // Track the current and previous parameter values Character currentCharacter = null; Sprite currentPortrait = null; RectTransform currentPosition = null; Character previousCharacter = null; // Play the conversation for (int i = 0; i < conversationItems.Count; ++i) { ConversationItem item = conversationItems[i]; if (item.Character != null) { currentCharacter = item.Character; } currentPortrait = item.Portrait; currentPosition = item.Position; SayDialog sayDialog = GetSayDialog(currentCharacter); if (sayDialog == null) { // Should never happen yield break; } sayDialog.gameObject.SetActive(true); if (currentCharacter != null && currentCharacter != previousCharacter) { sayDialog.SetCharacter(currentCharacter); } var stage = Stage.GetActiveStage(); if (stage != null && currentCharacter != null && (currentPortrait != currentCharacter.state.portrait || currentPosition != currentCharacter.state.position)) { var portraitOptions = new PortraitOptions(true); portraitOptions.display = item.Hide ? DisplayType.Hide : DisplayType.Show; portraitOptions.character = currentCharacter; portraitOptions.fromPosition = currentCharacter.state.position; portraitOptions.toPosition = currentPosition; portraitOptions.portrait = currentPortrait; // Do a move tween if the character is already on screen and not yet at the specified position if (currentCharacter.state.onScreen && currentPosition != currentCharacter.state.position) { portraitOptions.move = true; } if (item.Hide) { stage.Hide(portraitOptions); } else { stage.Show(portraitOptions); } } if (stage == null && currentPortrait != null) { sayDialog.SetCharacterImage(currentPortrait); } previousCharacter = currentCharacter; if (!string.IsNullOrEmpty(item.Text)) { exitSayWait = false; sayDialog.Say(item.Text, true, true, true, false, null, () => { exitSayWait = true; }); while (!exitSayWait) { yield return(null); } exitSayWait = false; } } }
public override void OnEnter() { if (needName && StorySystem.StoryDataUtilities.StoryUserName != null) { storyText = storyText.Insert(AfterHowManyNumber, StorySystem.StoryDataUtilities.StoryUserName); } if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (character != null && character.SetSayDialog != null) { SayDialog.ActiveSayDialog = character.SetSayDialog; } if (setSayDialog != null) { SayDialog.ActiveSayDialog = setSayDialog; } DialogPortrait diaPortrait = null; int[] diaPLayerSetting = null; PortraitAnimClip[] animInfo = null; if (character != null && character.displayPortrait != null) { diaPortrait = character.displayPortrait; } if (diaPortrait != null) { diaPLayerSetting = new int[diaPortrait.charLayers.Length]; var presetData = diaPortrait.GetPresetData(); int[] layerSetting = null; if (portraitPresetIndex >= 0 && presetData != null && presetData.portraitPresets != null && presetData.portraitPresets.Length > portraitPresetIndex ) { layerSetting = presetData.portraitPresets[portraitPresetIndex].spIndexes; } else { layerSetting = portraitLayerSetting; } int overwriteSettingMax = layerSetting.Length; for (int i = 0; i < diaPLayerSetting.Length; i++) { if (i < overwriteSettingMax) { diaPLayerSetting[i] = (layerSetting[i] >= 0) ? layerSetting[i] : character.defaultProtraitLayerSetting[i]; } else { diaPLayerSetting[i] = layerSetting[i]; } } if (animPressetIndex >= 0 && presetData != null && presetData.animPresets != null && presetData.animPresets.Length > animPressetIndex ) { animInfo = presetData.animPresets[animPressetIndex].clips; } else { animInfo = animClips; } } DialogPortrait.ActivePortrait = diaPortrait; if (diaPortrait != null) { if (diaPLayerSetting != null && diaPLayerSetting.Length > 0) { for (int i = 0; i < diaPLayerSetting.Length; i++) { diaPortrait.SetSprite(i, diaPLayerSetting[i]); } } if (animInfo != null && animInfo.Length > 0) { diaPortrait.PlayAnim(animInfo); } } var sayDialog = SayDialog.GetSayDialog(); if (sayDialog == null) { Continue(); return; } var flowchart = GetFlowchart(); sayDialog.SetActive(true); sayDialog.SetCharacter(character); sayDialog.SetCharacterImage(portrait); string displayText = storyText; //if (playType == AnimPlayType.Start && !string.IsNullOrEmpty(sayDialogAnim)) //{ // // sayDialog.PlayAnim(sayDialogAnim); //} var activeCustomTags = CustomTag.activeCustomTags; for (int i = 0; i < activeCustomTags.Count; i++) { var ct = activeCustomTags[i]; displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith); if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "") { displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith); } } string subbedText = flowchart.SubstituteVariables(displayText); //stop voice via wwise if (!string.IsNullOrEmpty(PreVoiceClipName)) { AudioManager.StopSound(PreVoiceClipName, 0); }//play voice via wwise if (!string.IsNullOrEmpty(voiceClipName)) { AudioManager.TimeLinePlayVoice(voiceClipName); } sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate { Continue(); }, diaPortrait); }
protected virtual SayDialog GetSayDialog() { SayDialog sayDialog = SayDialog.GetSayDialog(); return(sayDialog); }
/// <summary> /// Returns the current say dialog. /// </summary> public virtual SayDialog GetSayDialog() { return(SayDialog.GetSayDialog()); }
/// <summary> /// Sync the active say dialog with what Lua thinks the SayDialog should be /// </summary> public virtual void SetSayDialog(SayDialog sayDialog) { SayDialog.ActiveSayDialog = sayDialog; }
/// <summary> /// Sync the active say dialog with what Lua thinks the SayDialog should be /// </summary> /// <param name="sayDialog"></param> public void SetSayDialog(SayDialog sayDialog) { SayDialog.activeSayDialog = sayDialog; }
public override void OnEnter() { activeDialog = sayDialog; Continue(); }
/// <summary> /// Returns a SayDialog by searching for one in the scene or creating one if none exists. /// </summary> public static SayDialog GetSayDialog(string tag) { SayDialog sd = activeSayDialogs.Where(r => r.gameObject.tag == tag).FirstOrDefault(); return(sd); }