private float waitForCallback = -100; // -100 = not used #endregion Fields #region Methods public void shout(string shout, shoutDelegate c = null, bool shouldPause = false) { if (shouldPause) { pauser.pause(new string[]{"Shouter"}); } float x = Random.Range(-23.0f, 23.0f); float y = Random.Range(-18.0f, 18.0f); string top_bottom = "top"; string left_right = "left"; if (x > 0) { left_right = "right"; } if (y < 0) { top_bottom = "bottom"; } tk2dTextMesh textMesh = (tk2dTextMesh) Instantiate(prefab, new Vector3(x,y,-9), Quaternion.identity); if (top_bottom == "top") { if (left_right == "left") { textMesh.anchor = TextAnchor.UpperLeft; } else { // left_right == "right" textMesh.anchor = TextAnchor.UpperRight; } } else { // top_bottom == "bottom" if (left_right == "left") { textMesh.anchor = TextAnchor.LowerLeft; } else { // left_right == "right" textMesh.anchor = TextAnchor.LowerRight; } } AudioSource sound = (AudioSource)shouts[shout][1]; sound.Play(); textMesh.text = (string)shouts[shout][0]; textMesh.Commit(); waitForCallback = (float)shouts[shout][2]; callback = c; }
void Update() { if (waitForCallback > -100) { print(waitForCallback); waitForCallback -= Time.deltaTime; if (waitForCallback < 0) { pauser.resume(); if (callback != null) { callback(); callback = null; } waitForCallback = -100; } } }