IEnumerator sea_Output(TwineOutput output) { if (output is TwineLink && output.Name == "continue") { yield return(StartCoroutine(ClickForAlarm(output as TwineLink))); } }
void Story_OnOutput(TwineOutput output) { if (!this.AutoDisplay) { return; } // Check if a wait is needed float wait = 0f; try { wait = (float)Story["wait"].ToDouble(); } catch (KeyNotFoundException) { } // Check if a click in needed (only for links and non-empty text lines) bool click = false; if ((output is TwineLink || output is TwineText) && output.Text.Length > 0) { try { click = Story["click"].ToBool(); } catch (KeyNotFoundException) { } } if (click || wait > 0f) { Story.Pause(); StartCoroutine(Wait(wait, click, output)); } else { DisplayOutput(output); } }
void her_Update() { if (her_done) { return; } float delta = (Input.mousePosition - her_lastMousePos).magnitude; float move = Mathf.Clamp(delta / Screen.height, 0f, 1f); Color color = uiImage.color; if (move < her_minScreenMove) { if (!ImageFade.IsInProgress(uiImage) && color.a > 0f) { ImageFade.Start(uiImage, 1f, 0f, move < her_minScreenMove ? her_minFadeoutTime : her_maxFadeoutTime); } } else if (!her_lineTriggered) { ImageFade.Stop(uiImage); color.a = Mathf.Clamp(color.a + move * her_alphaFactor, 0f, 1f); uiImage.color = color; } // Show another line if (!her_lineTriggered && color.a >= her_alphaLineTriggerUp) { TwineText line = null; while (line == null) { TwineOutput output = story.Output[her_outputIndex]; if (output is TwineText) { line = (TwineText)output; } else if (output is TwineLink && output.Name == "continue") { her_done = true; StartCoroutine(her_alarm(output as TwineLink)); break; } her_outputIndex++; } if (line != null) { uiTextPlayer.DisplayOutput(line); her_lineTriggered = true; } } else if (her_lineTriggered && color.a <= her_alphaLineTriggerDown) { her_lineTriggered = false; } her_lastMousePos = Input.mousePosition; }
void Story_OnOutput(TwineOutput output) { if (output is TwineText) { var text = (TwineText)output; if (IgnoreEmptyLines && text.Text.Trim().Length < 1) { return; } lines.Add(text.Text); } }
public void DisplayOutput(TwineOutput output) { const int maxNameLength = 30; RectTransform child = null; if (output is TwineText) { var text = (TwineText)output; if (!ShowEmptyLines && text.Text.Trim().Length < 1) { return; } Text uiText = (Text)Instantiate(TextTemplate); uiText.gameObject.SetActive(true); uiText.text = text.Text; uiText.name = text.Text.Length > maxNameLength - 3 ? text.Text.Substring(0, 27) + "..." : text.Text.Trim().Length == 0 ? "(empty line)" : text.Text; child = uiText.rectTransform; } else if (output is TwineLink) { var link = (TwineLink)output; if (!ShowNamedLinks && link.Name != link.Text) { return; } Button uiLink = (Button)Instantiate(LinkTemplate); uiLink.gameObject.SetActive(true); uiLink.name = "[[" + (link.Name.Length > maxNameLength - 3 ? link.Name.Substring(0, 27) + "..." : link.Name) + "]]"; Text uiLinkText = uiLink.GetComponentInChildren <Text>(); uiLinkText.text = link.Text; //RenderSettings.skybox = nextMaterial; uiLink.onClick.AddListener(() => this.Story.Advance(link)); child = (RectTransform)uiLink.transform; } else { return; } if (child != null) { child.SetParent(Container); } }
IEnumerator relationship_Output(TwineOutput output) { if (output is TwineText && Random.Range(0, 2) == 0) { if (!relationship_sfxCough.isPlaying) { relationship_sfxCough.clip = relationship_sfxCoughSounds[Random.Range(0, relationship_sfxCoughSounds.Length)]; relationship_sfxCough.time = 0f; relationship_sfxCough.Play(); } } else if (output is TwineLink && output.Name == "continue") { yield return(StartCoroutine(ClickForAlarm(output as TwineLink))); } }
IEnumerator Wait(float wait, bool click, TwineOutput output) { if (wait > 0f) { yield return(new WaitForSeconds(wait)); } if (click) { while (!this.WasClicked()) { yield return(null); } } DisplayOutput(output); yield return(null); Story["wait"] = 0.0; Story.Resume(); }