/// <summary> /// Auto stanza play of. /// calls on mouse down of each text to play its respective animation if present /// zoomin and zoomout of texts with delays acoordinf to the start and end time of texts /// </summary> /// <param name="startingTinkerText">Starting tinker text.</param> public IEnumerator AutoPlay(GTinkerText startingTinkerText = null) { //{ stanzaNarrate = true; Debug.Log("auto play"); int startingTinkerTextIndex = 0; if (startingTinkerText != null) { startingTinkerTextIndex = tinkerTexts.IndexOf(startingTinkerText); } for (int i = startingTinkerTextIndex; i < tinkerTexts.Count; i++) { //link the corresponding paried animation during auto play GTinkerText t = null; if (tinkerTexts[i] != null) { t = tinkerTexts[i]; } if (t.star) { for (int j = 0; j < t.pairedGraphics.Count; j++) { t.pairedGraphics [j].PlayCompleteAnim(); } } //GTinkerGraphic link = t.GetComponent<GTinkerText> ().pairedGraphic; //if paired graphic is present //if (link != null) { //GSManager scenescript = stanzaManager.sceneManager; //call its respective scene onmousedown //scenescript.OnMouseDown(t.gameObject); //scenescript.OnMouseUp (t.gameObject); //} Animator anim = t.GetComponent <Animator>(); if (anim != null) { anim.speed = 1 / t.playTime; } // If we aren't on last word, delay before playing next word if (i < tinkerTexts.Count - 1) { // delay according to timing data float pauseDelay = tinkerTexts[i + 1].GetStartTime() - tinkerTexts[i].GetEndTime(); if (anim != null) { anim.Play("textzoomout"); } yield return(new WaitForSeconds(t.playTime / 2)); if (anim != null) { anim.Play("textzoomin"); } yield return(new WaitForSeconds(t.playTime / 2)); if (pauseDelay != 0) { if (anim != null) { anim.speed = 1 / pauseDelay; } if (anim != null && anim.GetCurrentAnimatorStateInfo(0).IsName("idle")) { anim.Play("pausedelay"); } yield return(new WaitForSeconds(pauseDelay)); } } else // Delay before next stanza { if (anim != null) { anim.Play("textzoomout"); } yield return(new WaitForSeconds(t.playTime / 2)); if (anim != null) { anim.Play("textzoomin"); } yield return(new WaitForSeconds(t.playTime / 2)); if (anim != null && endDelay != 0) { anim.speed = 1 / endDelay; anim.Play("enddelay"); } yield return(new WaitForSeconds(endDelay)); } // Abort early? if (stanzaManager.CancelAutoPlay()) { yield break; } } //stanzaNarrate=false; // Stop the coroutine yield break; }