IEnumerator WaitCompletion(string text, Transform speaker, Vector3 position, BalloonDirection dir) { while (typing) { yield return(new WaitForSeconds(1.5f)); } tl.gameObject.SetActive(dir == BalloonDirection.TL); tr.gameObject.SetActive(dir == BalloonDirection.TR); bl.gameObject.SetActive(dir == BalloonDirection.BL); br.gameObject.SetActive(dir == BalloonDirection.BR); int numLines = 1; foreach (char c in text) { if (c == '\n') { numLines++; } } RectTransform ContentRT = null; TextMeshProUGUI Words = null; RectTransform WordsRT = null; switch (dir) { case BalloonDirection.TL: ContentRT = ContentTLrt; Words = WordsTL; WordsRT = WordsTLrt; break; case BalloonDirection.TR: ContentRT = ContentTRrt; Words = WordsTR; WordsRT = WordsTRrt; break; case BalloonDirection.BL: ContentRT = ContentBLrt; Words = WordsBL; WordsRT = WordsBLrt; break; case BalloonDirection.BR: ContentRT = ContentBRrt; Words = WordsBR; WordsRT = WordsBRrt; break; } transform.position = position; previousPosition = speaker.position; if (typingCoroutine != null) { StopCoroutine(typingCoroutine); } typingCoroutine = StartCoroutine(TypeText(text, Words, WordsRT, ContentRT, speaker)); }
IEnumerator SayLater(int pos, string text, BalloonDirection dir) { yield return(new WaitForSeconds(pos + Random.Range(.5f, 1.5f))); Say(text, dir); sayLaterCoroutine = null; yield return(null); }
public void Say(string text, BalloonDirection dir) { if (balloon == null) // Check if we have a balloon, if not instantiate one { balloon = Instantiate(BalloonTemplate, BalloonTemplate.transform.parent).GetComponent <Balloon>(); } Vector3[] corners = new Vector3[4]; gameObject.GetComponent <RectTransform>().GetWorldCorners(corners); Vector3 center = Vector3.zero; float minx = corners[0].x; if (corners[0].x > corners[1].x) { minx = corners[1].x; } if (corners[1].x > corners[2].x) { minx = corners[2].x; } float maxx = corners[0].x; if (corners[0].x < corners[1].x) { maxx = corners[1].x; } if (corners[1].x < corners[2].x) { maxx = corners[2].x; } float miny = corners[0].y; if (corners[0].y > corners[1].y) { miny = corners[1].y; } if (corners[1].y > corners[2].y) { miny = corners[2].y; } float maxy = corners[0].y; if (corners[0].y < corners[1].y) { maxy = corners[1].y; } if (corners[1].y < corners[2].y) { maxy = corners[2].y; } center.x = (maxx + minx) / 2; center.y = (maxy + miny) / 2; balloon.Say(text, transform, center, dir); }
public void SetMood(Mood m, bool silent = false, BalloonDirection dir = BalloonDirection.TL) { if (player.def.type == PlayerDef.Type.Defeated || player.def.type != PlayerDef.Type.AI) { return; } mood = m; eyes = ((int)m) % 6; mouth = ((int)m) / 6; SetExpression(eyes, mouth); timeOut = 0; moodTimeout = Random.Range(5, 10); if (!silent) { Say(GetIntroMessage(), dir); } }
// Constructor to create a CBalloon object public HelpBalloon(string text, Icon icon, Control control, bool showCloseButton, BalloonDirection direction, BalloonEffect effect) { MyBalloon = CreateBalloon(control.Handle, 0, 0, text, showCloseButton, icon.Handle, (uint)direction, (uint)effect, 0, 0, 0); }
public HelpBalloon(string text, Icon icon, Control control, bool showCloseButton, BalloonDirection direction, BalloonEffect effect, Color start, Color mid, Color end) { MyBalloon = CreateBalloon(control.Handle, 0, 0, text, showCloseButton, icon.Handle, (uint)direction, (uint)effect, (uint)start.ToArgb(), (uint)mid.ToArgb(), (uint)end.ToArgb()); }
internal void Say(string text, Transform speaker, Vector3 position, BalloonDirection dir) { StartCoroutine(WaitCompletion(text, speaker, position, dir)); }