diff --git a/Assets/Scripts/Player Manager/GenericPlayerManager.cs b/Assets/Scripts/Player Manager/GenericPlayerManager.cs index bbf41c0..aa73d14 100644 --- a/Assets/Scripts/Player Manager/GenericPlayerManager.cs +++ b/Assets/Scripts/Player Manager/GenericPlayerManager.cs @@ -61,6 +61,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { // Gerenciados de legendas private Subtitle subtitles = null; + private bool[] lastLetterAnimations = new bool[256]; + public virtual void Start() { // Configuração de velocidade das animações @@ -256,7 +258,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { lock (this.animQueue) { - if (this.animationPlaying.state != null) + if (this.animationPlaying != null && this.animationPlaying.state != null) this.animationPlaying.state.speed = paused ? 0F : getSpeedByType(this.animationPlaying.type); foreach (AnimationReference reference in this.animQueue) @@ -328,6 +330,14 @@ public abstract class GenericPlayerManager : MonoBehaviour { return true; } + private string nextLetterAnimation(char letter) + { + string animation = (this.lastLetterAnimations[letter] ? "" : "d_") + letter.ToString(); + this.lastLetterAnimations[letter] = ! this.lastLetterAnimations[letter]; + + return animation; + } + /* Enfileira soletração de palavra */ private string spellWord(Queue toPlayQueue, string word) { @@ -342,9 +352,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { for (int i = 0; i < word.Length; i++) { lastAnimationSubtitle = Subtitle.highlight(word, i); - - string anim = word[i].ToString(); - lastAnim = anim.Equals(lastAnim) ? "d_" + anim : anim; + lastAnim = nextLetterAnimation(word[i]); + //anim.Equals(lastAnim) ? "d_" + anim : anim; short type; @@ -555,19 +564,26 @@ public abstract class GenericPlayerManager : MonoBehaviour { bool isNotEmpty; lock (this.animQueue) { isNotEmpty = this.animQueue.Count > 0; } - // Enquanto estiver executando a rotina "loadAndPlay" + // Animação anterior a atual + AnimationReference endedAnimation = null; + + // Enquanto estiver executando a corotina "loadAndPlay" // ou existir animações na fila de reprodução while (loading || isNotEmpty) { + // Se não houver animações na fila, espera if (isNotEmpty) { + // Pega primeira animação AnimationReference reference; lock (this.animQueue) { reference = this.animQueue.Peek(); } - this.subtitles.setText(reference.subtitle); - + // Se estiver sendo reproduzida if (COMPONENT_ANIMATION.IsPlaying(reference.name)) { + this.subtitles.setText(reference.subtitle); + + // Animação seguinte AnimationReference next = null; lock (this.animQueue) { @@ -579,21 +595,36 @@ public abstract class GenericPlayerManager : MonoBehaviour { while (true) { + // Se a próxima animação estiver sendo reproduzida (no fade) if (next != null && COMPONENT_ANIMATION.IsPlaying(next.name)) { + // Se a animação anterior a atual não tiver acabado, + // espera acabar e só então conta o tempo + if (endedAnimation != null) + while (COMPONENT_ANIMATION.IsPlaying(endedAnimation.name)) + yield return null; + + // Tempo para pular para a legenda da próxima animação yield return new WaitForSeconds(0.4F); + + // Deprecated + // yield return WaitForContinuousMillis.Wait(this, 300); + + endedAnimation = reference; break; } + else if (COMPONENT_ANIMATION.IsPlaying(reference.name)) - { yield return null; - } + else break; } reference = null; } + // Se a animação não tiver sido liberada e seu AnimationState for nulo, + // a animação será liberada if (reference != null && reference.state == null) lock (this.animQueue) { this.animQueue.Dequeue(); } else @@ -601,11 +632,11 @@ public abstract class GenericPlayerManager : MonoBehaviour { } else yield return null; - this.subtitles.setText(""); - lock (this.animQueue) { isNotEmpty = this.animQueue.Count > 0; } } + this.subtitles.setText(""); + resetStates(); this.randomAnimations.unlockFor("handleStates"); } diff --git a/Assets/Scripts/UI/ScreenManager.cs b/Assets/Scripts/UI/ScreenManager.cs index c734d10..6c14fd1 100644 --- a/Assets/Scripts/UI/ScreenManager.cs +++ b/Assets/Scripts/UI/ScreenManager.cs @@ -164,8 +164,8 @@ public class ScreenManager : MonoBehaviour { public void setPauseMenuState(bool active) { - if (this.pauseMenu.activeSelf != active) - this.pauseMenu.SetActive(active); + this.pauseMenu.SetActive(active); + setAvatarColliderState( ! active); } public void setLoadingSnippetState(bool active) diff --git a/Assets/Scripts/WaitForContinuousMillis.cs b/Assets/Scripts/WaitForContinuousMillis.cs new file mode 100644 index 0000000..bd705ea --- /dev/null +++ b/Assets/Scripts/WaitForContinuousMillis.cs @@ -0,0 +1,34 @@ +using UnityEngine; +using System.Collections; +using System.Diagnostics; + +public class WaitForContinuousMillis { + + /* Corotina que espera millis milésimos, mas que conta o tempo apenas + * quando as animações sendo reproduzidas não estão pausadas. + */ + public static IEnumerator Wait(GenericPlayerManager context, long millis) + { + Stopwatch watch = new Stopwatch(); + watch.Start(); + + while (true) + { + if (watch.ElapsedMilliseconds < millis) + { + UnityEngine.Debug.Log(millis); + + if (context.isPaused()) { + if (watch.IsRunning) + watch.Stop(); + } + else if ( ! watch.IsRunning) + watch.Start(); + + yield return null; + } + else break; + } + } + +} diff --git a/Assets/Scripts/WaitForContinuousMillis.cs.meta b/Assets/Scripts/WaitForContinuousMillis.cs.meta new file mode 100644 index 0000000..3da87ea --- /dev/null +++ b/Assets/Scripts/WaitForContinuousMillis.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3d8662a14b9d0bd4a8625f41ae18ba5a +timeCreated: 1458595282 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/playerdroid-ios_2016-03-18_20-12.rar b/playerdroid-ios_2016-03-18_20-12.rar new file mode 100644 index 0000000..61c6724 Binary files /dev/null and b/playerdroid-ios_2016-03-18_20-12.rar differ -- libgit2 0.21.2