From 85f88069cabbc245d1df633b1ec9ce03348d0b55 Mon Sep 17 00:00:00 2001 From: Mateus Pires Date: Fri, 14 Oct 2016 12:24:14 -0300 Subject: [PATCH] Fix animations watcher; Fix avatar-z --- Assets/Scenes/Main.unity | 142 ++++++++-------------------------------------------------------------------------------------------------------------------------------------- Assets/Scripts/Player Manager/GenericPlayerManager.cs | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------- Assets/Scripts/TutorialManager.cs | 46 ++++++++++++++++++++++------------------------ Assets/Scripts/UI/Resizers/BarResizer.cs | 6 +++--- 4 files changed, 98 insertions(+), 212 deletions(-) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 3581dbe..1f49a7d 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -5156,7 +5156,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 400002, guid: 714c639770278b249bb7d0850bac50fc, type: 3} propertyPath: m_LocalPosition.z - value: 4 + value: 3 objectReference: {fileID: 0} - target: {fileID: 400002, guid: 714c639770278b249bb7d0850bac50fc, type: 3} propertyPath: m_LocalRotation.x @@ -6279,131 +6279,6 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1031720608} ---- !u!1 &1048863672 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 133698, guid: 5ccb0ba277304a14b9bb8d4e34161675, type: 2} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1048863673} - - 222: {fileID: 1048863676} - - 114: {fileID: 1048863674} - - 114: {fileID: 1048863675} - m_Layer: 5 - m_Name: b_info - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &1048863673 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 22435842, guid: 5ccb0ba277304a14b9bb8d4e34161675, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1048863672} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_Children: [] - m_Father: {fileID: 1357627304} - m_RootOrder: 4 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 203.972, y: -24.257143} - m_SizeDelta: {x: 22.215998, y: 38.514286} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1048863674 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11447224, guid: 5ccb0ba277304a14b9bb8d4e34161675, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1048863672} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.3019608} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 21300000, guid: 9d4cc4cb9b7a7e44ab610fb91451883b, type: 3} - m_Type: 0 - m_PreserveAspect: 1 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!114 &1048863675 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11487520, guid: 5ccb0ba277304a14b9bb8d4e34161675, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1048863672} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 45157148} - m_OnClick: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 228512395} - m_MethodName: select - m_Mode: 3 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 4 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null ---- !u!222 &1048863676 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 22201970, guid: 5ccb0ba277304a14b9bb8d4e34161675, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1048863672} --- !u!1 &1053934344 GameObject: m_ObjectHideFlags: 0 @@ -6697,7 +6572,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Version 3.0.36 + m_Text: Version 3.0.40 --- !u!222 &1071047506 CanvasRenderer: m_ObjectHideFlags: 0 @@ -8633,7 +8508,6 @@ RectTransform: - {fileID: 510126319} - {fileID: 395548682} - {fileID: 630366171} - - {fileID: 1048863673} m_Father: {fileID: 1798565573} m_RootOrder: 0 m_AnchorMin: {x: 0.12, y: 0} @@ -13717,7 +13591,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 5 + m_IntArgument: 4 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -13955,7 +13829,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &2099411279 RectTransform: m_ObjectHideFlags: 0 @@ -13970,10 +13844,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 702185295} m_RootOrder: 2 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 260.71997, y: -76.62858} - m_SizeDelta: {x: 106, y: 106} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2099411280 MonoBehaviour: diff --git a/Assets/Scripts/Player Manager/GenericPlayerManager.cs b/Assets/Scripts/Player Manager/GenericPlayerManager.cs index bee0675..951da09 100644 --- a/Assets/Scripts/Player Manager/GenericPlayerManager.cs +++ b/Assets/Scripts/Player Manager/GenericPlayerManager.cs @@ -88,6 +88,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { subtitles.DefaultFirstLetterSpeed = new DefaultSignSpeed(2.1F, 2.8F); subtitles.DefaultLetterSpeed = new DefaultSignSpeed(3F, 4.3F); subtitles.DefaultNumberSpeed = new DefaultSignSpeed(1.5F, 2.9F); + PlayerLogger.Log("Subtitles object: " + subtitles); AVATAR = GameObject.FindGameObjectWithTag("avatar"); COMPONENT_ANIMATION = AVATAR.GetComponent(); @@ -120,6 +121,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { // Cria novo _default chamado _default_middle para pausas dentro de uma glosa // Impede que a animação default seja confundida com não-reprodução na UI COMPONENT_ANIMATION.AddClip(COMPONENT_ANIMATION[DEFAULT_ANIMATION].clip, DEFAULT_ANIMATION_MIDDLE); + + StartCoroutine(AnimationsWatcher()); } public bool isPlayingIntervalAnimation() { return intervalAnimationState != null; } @@ -187,11 +190,10 @@ public abstract class GenericPlayerManager : MonoBehaviour { /* Para animações */ public void stopAnimations() { - StopCoroutine("AnimationsWatcher"); this.randomAnimations.unlockFor("AnimationsWatcher"); + this.animQueue.Clear(); this.subtitles.setText(""); - lock (this.animQueue) { this.animQueue.Clear(); } COMPONENT_ANIMATION.CrossFadeQueued(DEFAULT_ANIMATION, fadeLength, QueueMode.PlayNow); resetStates(); @@ -621,61 +623,73 @@ public abstract class GenericPlayerManager : MonoBehaviour { while (true) { - if (this.animQueue.Count > 0) - { - if (!this.playing) - { - PlayerLogger.Log("GPM", "AW", "Playing."); + if (this.animQueue.Count > 0) + { + if (!this.playing) + { + PlayerLogger.Log("GPM", "AW", "Playing."); - this.playing = true; - onPlayingStateChange(); + this.playing = true; + onPlayingStateChange(); - this.randomAnimations.lockFor("AnimationsWatcher"); - } + this.randomAnimations.lockFor("AnimationsWatcher"); + } - // Gets first animation - AnimationReference reference = this.animQueue.Peek(); - - if (COMPONENT_ANIMATION.IsPlaying(reference.name)) - { - this.animationPlaying = this.animQueue.Dequeue(); - this.subtitles.setText(reference.subtitle); - - // Watches transition between current and next animation - while (true) - { - yield return new WaitForEndOfFrame(); - - // Gets next animation - AnimationReference next = this.animQueue.Count > 0 ? this.animQueue.Peek() : null; - - if (next != null && COMPONENT_ANIMATION.IsPlaying(next.name)) - { - // Waits next animation starts - while (!COMPONENT_ANIMATION.IsPlaying(next.name)) - yield return new WaitForEndOfFrame(); - - // Waits half fade - yield return new WaitForSeconds(this.fadeLength / 2); - break; - } - else if (!COMPONENT_ANIMATION.IsPlaying(reference.name)) break; - } - } + // Gets first animation + AnimationReference reference = this.animQueue.Peek(); + PlayerLogger.Log("GPM", "AW", "Got " + reference.name + "."); - // Animation played but was not tracked - if (reference.state == null) - this.animQueue.Dequeue(); - } - else if (this.playing && !this.loading) - { - PlayerLogger.Log("GPM", "AW", "Not playing."); + if (COMPONENT_ANIMATION.IsPlaying(reference.name)) + { + PlayerLogger.Log("GPM", "AW", "And its playing!"); - resetStates(); + this.animationPlaying = this.animQueue.Dequeue(); + this.subtitles.setText(reference.subtitle); - this.subtitles.setText(""); - this.randomAnimations.unlockFor("AnimationsWatcher"); - } + // Watches transition between current and next animation + while (true) + { + PlayerLogger.Log("GPM", "AW", "Wating for it to end."); + + yield return new WaitForEndOfFrame(); + + // Gets next animation + AnimationReference next = this.animQueue.Count > 0 ? this.animQueue.Peek() : null; + + if (next != null && COMPONENT_ANIMATION.IsPlaying(next.name)) + { + PlayerLogger.Log("GPM", "AW", "It has a next."); + + // Waits next animation starts + while (!COMPONENT_ANIMATION.IsPlaying(next.name)) + yield return new WaitForEndOfFrame(); + + // Waits half fade + yield return new WaitForSeconds(this.fadeLength / 2); + break; + } + else if (!COMPONENT_ANIMATION.IsPlaying(reference.name)) break; + } + } + // Animation played but was not tracked + else + { + if (reference.state == null) + this.animQueue.Dequeue(); + + yield return new WaitForEndOfFrame(); + } + } + else if (this.playing && !this.loading) + { + PlayerLogger.Log("GPM", "AW", "Not playing."); + + resetStates(); + + this.subtitles.setText(""); + this.randomAnimations.unlockFor("AnimationsWatcher"); + } + else yield return new WaitForEndOfFrame(); } } diff --git a/Assets/Scripts/TutorialManager.cs b/Assets/Scripts/TutorialManager.cs index ba86649..788d93b 100644 --- a/Assets/Scripts/TutorialManager.cs +++ b/Assets/Scripts/TutorialManager.cs @@ -24,6 +24,8 @@ public class TutorialManager : MonoBehaviour { "Barra de velocidade\n\nNa barra você pode escolher a velocidade que deseja visualizar o sinal", }; + private Image[] buttons; + protected void Start () { if (Screen.dpi < 140) @@ -53,23 +55,22 @@ public class TutorialManager : MonoBehaviour { { this.description.fontSize = 14; } + + this.buttons = new Image[] { + this.translateImage, + this.micImage, + this.dictionaryImage, + this.subtitlesImage + }; } - private Image getButton() - { - switch (this.index) - { - case 0: return this.translateImage; - case 1: return this.micImage; - case 2: return this.dictionaryImage; - case 3: return this.subtitlesImage; - default: return null; - } + private Image getButton() { + return this.index <= 3 ? this.buttons[this.index] : null; } public void next() { - if (index == 4) + if (this.index == 4) { this.screenManager.hideScreen(); select(0); @@ -77,14 +78,15 @@ public class TutorialManager : MonoBehaviour { else { #if UNITY_IOS - if (this.index == 0) - this.index++; + // Jump mic + select(this.index == 0 ? 2 : this.index + 1); +#else + select(this.index + 1); #endif - select(this.index + 1); - } - } + } + } - public void select(int index) + public void select(int index) { if (this.index <= 3) getButton().color = disabledColor; @@ -94,15 +96,11 @@ public class TutorialManager : MonoBehaviour { this.index = index; if (this.index <= 3) - { getButton().color = enabledColor; - this.description.text = this.descriptions[index]; - } else - { - this.sliderShadow.SetActive(false); - this.description.text = this.descriptions[index]; - } + this.sliderShadow.SetActive(false); + + this.description.text = this.descriptions[index]; } } \ No newline at end of file diff --git a/Assets/Scripts/UI/Resizers/BarResizer.cs b/Assets/Scripts/UI/Resizers/BarResizer.cs index 2c8fa36..50de539 100644 --- a/Assets/Scripts/UI/Resizers/BarResizer.cs +++ b/Assets/Scripts/UI/Resizers/BarResizer.cs @@ -17,15 +17,15 @@ public class BarResizer : MonoBehaviour { // 240 else if (Screen.width < 500) - this.barBottomLayout.spacing = 116; + this.barBottomLayout.spacing = 106; // 320 else if (Screen.width < 620) - this.barBottomLayout.spacing = 142; + this.barBottomLayout.spacing = 132; // 480 else if (Screen.width < 840) - this.barBottomLayout.spacing = 190; + this.barBottomLayout.spacing = 180; else this.barBottomLayout.spacing = 210; -- libgit2 0.21.2