Commit 664858267bf3a7f59b0dbf785639fb12d7fac33f
1 parent
f1f0ce68
Exists in
master
and in
1 other branch
Nova implementacao do GenericPlayerManager
Showing
9 changed files
with
227 additions
and
108 deletions
Show diff stats
No preview for this file type
No preview for this file type
Assets/Scenes/Scene.unity
@@ -37,9 +37,6 @@ RenderSettings: | @@ -37,9 +37,6 @@ RenderSettings: | ||
37 | m_ReflectionIntensity: 1 | 37 | m_ReflectionIntensity: 1 |
38 | m_CustomReflection: {fileID: 0} | 38 | m_CustomReflection: {fileID: 0} |
39 | m_Sun: {fileID: 0} | 39 | m_Sun: {fileID: 0} |
40 | ---- !u!127 &3 | ||
41 | -LevelGameManager: | ||
42 | - m_ObjectHideFlags: 0 | ||
43 | --- !u!157 &4 | 40 | --- !u!157 &4 |
44 | LightmapSettings: | 41 | LightmapSettings: |
45 | m_ObjectHideFlags: 0 | 42 | m_ObjectHideFlags: 0 |
@@ -68,6 +65,7 @@ LightmapSettings: | @@ -68,6 +65,7 @@ LightmapSettings: | ||
68 | m_TextureCompression: 0 | 65 | m_TextureCompression: 0 |
69 | m_FinalGather: 0 | 66 | m_FinalGather: 0 |
70 | m_FinalGatherRayCount: 1024 | 67 | m_FinalGatherRayCount: 1024 |
68 | + m_ReflectionCompression: 2 | ||
71 | m_LightmapSnapshot: {fileID: 0} | 69 | m_LightmapSnapshot: {fileID: 0} |
72 | m_RuntimeCPUUsage: 25 | 70 | m_RuntimeCPUUsage: 25 |
73 | --- !u!196 &5 | 71 | --- !u!196 &5 |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +fileFormatVersion: 2 | ||
2 | +guid: 789d1dce6607a394b82bcaa4af8d1c46 | ||
3 | +timeCreated: 1448041534 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + serializedVersion: 2 | ||
7 | + defaultReferences: [] | ||
8 | + executionOrder: 0 | ||
9 | + icon: {instanceID: 0} | ||
10 | + userData: | ||
11 | + assetBundleName: | ||
12 | + assetBundleVariant: |
Assets/Scripts/GenericPlayerManager.cs
@@ -10,11 +10,13 @@ using UnityEngine.UI; | @@ -10,11 +10,13 @@ using UnityEngine.UI; | ||
10 | 10 | ||
11 | public abstract class GenericPlayerManager : MonoBehaviour { | 11 | public abstract class GenericPlayerManager : MonoBehaviour { |
12 | 12 | ||
13 | - private struct AnimationReference { | 13 | + private class AnimationReference |
14 | + { | ||
14 | public string name; | 15 | public string name; |
15 | public string subtitle; | 16 | public string subtitle; |
16 | public AnimationState state; | 17 | public AnimationState state; |
17 | public short type; | 18 | public short type; |
19 | + public bool playing; | ||
18 | 20 | ||
19 | public AnimationReference(string name, string subtitle, AnimationState state, short type) | 21 | public AnimationReference(string name, string subtitle, AnimationState state, short type) |
20 | { | 22 | { |
@@ -22,53 +24,70 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -22,53 +24,70 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
22 | this.subtitle = subtitle; | 24 | this.subtitle = subtitle; |
23 | this.state = state; | 25 | this.state = state; |
24 | this.type = type; | 26 | this.type = type; |
27 | + this.playing = false; | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + protected class DefaultSignSpeed | ||
32 | + { | ||
33 | + public static float DEFAULT = 1.1F; | ||
34 | + public static float DEFAULT_MAX = 2F; | ||
35 | + | ||
36 | + public float speed; | ||
37 | + public float max; | ||
38 | + // Relação entre a velocidade do tipo representado e a velocidade DEFAULT. | ||
39 | + public float unit; | ||
40 | + | ||
41 | + public DefaultSignSpeed() | ||
42 | + { | ||
43 | + this.speed = DEFAULT; | ||
44 | + this.max = DEFAULT_MAX; | ||
45 | + this.unit = 1F; | ||
46 | + } | ||
47 | + | ||
48 | + public DefaultSignSpeed(float defaultSpeed, float defaultMaxSpeed) | ||
49 | + { | ||
50 | + this.speed = defaultSpeed; | ||
51 | + this.max = defaultMaxSpeed; | ||
52 | + this.unit = (this.max - this.speed) / (DEFAULT_MAX - DEFAULT); | ||
25 | } | 53 | } |
26 | 54 | ||
55 | + /* | ||
56 | + * Retorna velocidade em relação ao estado do slider. | ||
57 | + * @param slider - estado do slider (valor entre DefaultSignSpeed.DEFAULT e DefaultSignSpeed.DEFAULT_MAX) | ||
58 | + */ | ||
59 | + public float getProporcionalSpeed(float slider) | ||
60 | + { | ||
61 | + return this.speed + (slider - DEFAULT) * this.unit; | ||
62 | + } | ||
27 | } | 63 | } |
28 | 64 | ||
29 | private const string DEFAULT_ANIMATION = "_default"; | 65 | private const string DEFAULT_ANIMATION = "_default"; |
30 | private const string NONE_ANIMATION = "_defaultWORD"; | 66 | private const string NONE_ANIMATION = "_defaultWORD"; |
31 | 67 | ||
32 | - private const float FADE_LENGTH = 0.6F; | ||
33 | - | ||
34 | - private const float WORD_DEFAULT_SPEED = 1.1F; | ||
35 | - private const float WORD_MAX_SPEED = 2F; | ||
36 | - | ||
37 | - // Velocidade da primeira letra de uma palavra | ||
38 | - private const float LETTER_FIRST_SPEED = 1.8F; | ||
39 | - // Velocidade máxima de uma letra que o slider pode configurar | ||
40 | - private const float LETTER_FIRST_MAX_SPEED = 2.8F; | ||
41 | - // Taxa de velocidade da primeira letra de uma palavra equivalente a velocidade de uma palavra | ||
42 | - private const float LETTER_FIRST_UNIT_SPEED = (LETTER_FIRST_MAX_SPEED - LETTER_FIRST_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); | ||
43 | - // Velocidade das outras letras | ||
44 | - private const float LETTER_DEFAULT_SPEED = 2.8F; | ||
45 | - // Velocidade máxima de uma letra que o slider pode configurar | ||
46 | - private const float LETTER_MAX_SPEED = 4.3F; | ||
47 | - // Taxa de velocidade das outras letras equivalente a velocidade de uma palavra | ||
48 | - private const float LETTER_UNIT_SPEED = (LETTER_MAX_SPEED - LETTER_DEFAULT_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); | ||
49 | - | ||
50 | - // Velocidade de reprodução de números | ||
51 | - private const float NUMBER_DEFAULT_SPEED = 1.5F; | ||
52 | - // Velocidade máxima de um número que o slider pode configurar | ||
53 | - private const float NUMBER_MAX_SPEED = 2.9F; | ||
54 | - // Taxa de velocidade equivalente a uma unidade de velocidade de uma palavra | ||
55 | - private const float NUMBER_UNIT_SPEED = (NUMBER_MAX_SPEED - NUMBER_DEFAULT_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); | 68 | + protected float fadeLength = 0.6F; |
69 | + | ||
70 | + protected DefaultSignSpeed defaultWordSpeed = new DefaultSignSpeed(); | ||
71 | + protected DefaultSignSpeed defaultFirstLetterSpeed = new DefaultSignSpeed(2.1F, 2.8F); | ||
72 | + protected DefaultSignSpeed defaultLetterSpeed = new DefaultSignSpeed(3F, 4.3F); | ||
73 | + protected DefaultSignSpeed defaultNumberSpeed = new DefaultSignSpeed(1.5F, 2.9F); | ||
56 | 74 | ||
57 | private const short TYPE_NONE = -1; | 75 | private const short TYPE_NONE = -1; |
58 | private const short TYPE_WORD = 0; | 76 | private const short TYPE_WORD = 0; |
59 | private const short TYPE_LETTER = 1; | 77 | private const short TYPE_LETTER = 1; |
60 | private const short TYPE_NUMBER = 2; | 78 | private const short TYPE_NUMBER = 2; |
61 | 79 | ||
62 | - private static float hSlidersecond = WORD_DEFAULT_SPEED; | ||
63 | - private float letterSpeed = LETTER_DEFAULT_SPEED; | ||
64 | - private float numberSpeed = NUMBER_DEFAULT_SPEED; | 80 | + private float hSlidersecond = DefaultSignSpeed.DEFAULT; |
81 | + private float wordSpeed = DefaultSignSpeed.DEFAULT; | ||
82 | + private float letterSpeed = DefaultSignSpeed.DEFAULT; | ||
83 | + private float numberSpeed = DefaultSignSpeed.DEFAULT; | ||
65 | 84 | ||
66 | protected string glosa = ""; | 85 | protected string glosa = ""; |
67 | private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa | 86 | private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa |
68 | 87 | ||
69 | - public GameObject AVATAR; | 88 | + private GameObject AVATAR; |
70 | private Animation COMPONENT_ANIMATION; | 89 | private Animation COMPONENT_ANIMATION; |
71 | - private BoxCollider COMPONENT_COLLIDER; | 90 | + private BoxCollider AVATAR_COLLIDER; |
72 | public Text SUBTITLES; | 91 | public Text SUBTITLES; |
73 | 92 | ||
74 | // Guarda os nomes das palavras ja carregadas. | 93 | // Guarda os nomes das palavras ja carregadas. |
@@ -80,21 +99,30 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -80,21 +99,30 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
80 | // Utilizada para alterar velocidade e apresentar a legenda. | 99 | // Utilizada para alterar velocidade e apresentar a legenda. |
81 | private volatile Queue<AnimationReference> animQueue = new Queue<AnimationReference>(); | 100 | private volatile Queue<AnimationReference> animQueue = new Queue<AnimationReference>(); |
82 | 101 | ||
83 | - // "play" flag. Indica se está carregando a glosa. | 102 | + private volatile bool loadingSingleAnimation = false; |
84 | private volatile bool loading = false; | 103 | private volatile bool loading = false; |
85 | - | ||
86 | - protected bool playing = false; | ||
87 | - protected bool paused = false; | 104 | + private volatile bool playing = false; |
105 | + private volatile bool paused = false; | ||
88 | 106 | ||
89 | public virtual void Start() | 107 | public virtual void Start() |
90 | { | 108 | { |
91 | - //Gets Animation Component reference from AVATAR | ||
92 | - COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>(); | ||
93 | - COMPONENT_COLLIDER = AVATAR.GetComponent<BoxCollider>(); | 109 | + wordSpeed = defaultWordSpeed.speed; |
110 | + letterSpeed = defaultLetterSpeed.speed; | ||
111 | + numberSpeed = defaultNumberSpeed.speed; | ||
112 | + | ||
113 | + AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar | ||
114 | + COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar | ||
115 | + AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); | ||
94 | } | 116 | } |
95 | 117 | ||
96 | - public void SetAvatarCollider(bool active){ | ||
97 | - COMPONENT_COLLIDER.enabled = active; | 118 | + public bool isLoadingSingleAnimation() { return loadingSingleAnimation; } |
119 | + public bool isLoading() { return loading; } | ||
120 | + public bool isPlaying() { return playing; } | ||
121 | + public bool isPaused() { return paused; } | ||
122 | + | ||
123 | + public void SetAvatarCollider(bool isActive) | ||
124 | + { | ||
125 | + AVATAR_COLLIDER.enabled = isActive; | ||
98 | } | 126 | } |
99 | 127 | ||
100 | protected virtual void setSubtitle(string text) | 128 | protected virtual void setSubtitle(string text) |
@@ -107,8 +135,9 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -107,8 +135,9 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
107 | { | 135 | { |
108 | hSlidersecond = x; | 136 | hSlidersecond = x; |
109 | 137 | ||
110 | - letterSpeed = getProporcionalSpeed(LETTER_DEFAULT_SPEED, LETTER_UNIT_SPEED); | ||
111 | - numberSpeed = getProporcionalSpeed(NUMBER_DEFAULT_SPEED, NUMBER_UNIT_SPEED); | 138 | + wordSpeed = defaultWordSpeed.getProporcionalSpeed(x); |
139 | + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(x); | ||
140 | + numberSpeed = defaultNumberSpeed.getProporcionalSpeed(x); | ||
112 | 141 | ||
113 | if ( ! paused) | 142 | if ( ! paused) |
114 | foreach (AnimationReference reference in animQueue) | 143 | foreach (AnimationReference reference in animQueue) |
@@ -116,20 +145,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -116,20 +145,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
116 | reference.state.speed = getSpeedByType(reference.type); | 145 | reference.state.speed = getSpeedByType(reference.type); |
117 | } | 146 | } |
118 | 147 | ||
119 | - private float getProporcionalSpeed(float speed, float unit) | ||
120 | - { | ||
121 | - return speed + (hSlidersecond - WORD_DEFAULT_SPEED) * unit; | ||
122 | - } | ||
123 | - | ||
124 | private float getSpeedByType(short type) | 148 | private float getSpeedByType(short type) |
125 | { | 149 | { |
126 | switch (type) | 150 | switch (type) |
127 | { | 151 | { |
128 | - case TYPE_WORD: return hSlidersecond; | 152 | + case TYPE_WORD: return wordSpeed; |
129 | case TYPE_LETTER: return letterSpeed; | 153 | case TYPE_LETTER: return letterSpeed; |
130 | case TYPE_NUMBER: return numberSpeed; | 154 | case TYPE_NUMBER: return numberSpeed; |
131 | } | 155 | } |
132 | - | 156 | + |
133 | return 2F; | 157 | return 2F; |
134 | } | 158 | } |
135 | 159 | ||
@@ -159,21 +183,21 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -159,21 +183,21 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
159 | } catch (NullReferenceException nre) { Debug.Log("SetQueueList null reff::"+nre.ToString()); } | 183 | } catch (NullReferenceException nre) { Debug.Log("SetQueueList null reff::"+nre.ToString()); } |
160 | 184 | ||
161 | COMPONENT_ANIMATION.Stop(); | 185 | COMPONENT_ANIMATION.Stop(); |
162 | - COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, FADE_LENGTH, PlayMode.StopAll); | 186 | + COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll); |
163 | } | 187 | } |
164 | 188 | ||
165 | /* | 189 | /* |
166 | * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. | 190 | * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. |
167 | * | 191 | * |
168 | * Caso não haja SUBTITLE, name será utilizado como SUBTITLE. | 192 | * Caso não haja SUBTITLE, name será utilizado como SUBTITLE. |
169 | - * Caso não haja fadeLength, será atribuido FADE_LENGTH. | 193 | + * Caso não haja fadeLength, será atribuido fadeLength. |
170 | * Caso não haja velocidade, hSlidersecond será atribuída. | 194 | * Caso não haja velocidade, hSlidersecond será atribuída. |
171 | */ | 195 | */ |
172 | private AnimationState playAnimation(short type, string name, string subtitle, float speed) | 196 | private AnimationState playAnimation(short type, string name, string subtitle, float speed) |
173 | { | 197 | { |
174 | try | 198 | try |
175 | { | 199 | { |
176 | - AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, FADE_LENGTH, QueueMode.CompleteOthers); | 200 | + AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, fadeLength, QueueMode.CompleteOthers); |
177 | state.speed = speed; | 201 | state.speed = speed; |
178 | animQueue.Enqueue(new AnimationReference(name, subtitle, state, type)); | 202 | animQueue.Enqueue(new AnimationReference(name, subtitle, state, type)); |
179 | 203 | ||
@@ -202,36 +226,63 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -202,36 +226,63 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
202 | */ | 226 | */ |
203 | protected abstract WWW loadAssetBundle(string aniName); | 227 | protected abstract WWW loadAssetBundle(string aniName); |
204 | 228 | ||
229 | + | ||
205 | /** | 230 | /** |
206 | * Listen to changes in the playing status. | 231 | * Listen to changes in the playing status. |
207 | */ | 232 | */ |
208 | protected abstract void onPlayingStateChange(); | 233 | protected abstract void onPlayingStateChange(); |
209 | 234 | ||
210 | - public void play() | 235 | + |
236 | + public void switchPauseState(bool paused) | ||
211 | { | 237 | { |
212 | - if (playing) | 238 | + if (this.paused != paused) |
213 | { | 239 | { |
214 | - paused = ! paused; | 240 | + this.paused = paused; |
215 | 241 | ||
216 | foreach (AnimationReference reference in animQueue) | 242 | foreach (AnimationReference reference in animQueue) |
217 | if (reference.state != null) | 243 | if (reference.state != null) |
218 | reference.state.speed = paused ? 0F : getSpeedByType(reference.type); | 244 | reference.state.speed = paused ? 0F : getSpeedByType(reference.type); |
245 | + | ||
246 | + onPlayingStateChange(); | ||
219 | } | 247 | } |
248 | + } | ||
249 | + public void switchPauseState() | ||
250 | + { | ||
251 | + switchPauseState( ! paused); | ||
252 | + } | ||
253 | + | ||
254 | + public bool play() | ||
255 | + { | ||
256 | + if (playing) | ||
257 | + switchPauseState(); | ||
220 | else | 258 | else |
221 | - { | ||
222 | - playing = true; | 259 | + play(true, true, true); |
260 | + | ||
261 | + return true; | ||
262 | + } | ||
223 | 263 | ||
224 | - try{ | ||
225 | - if (loading) | 264 | + public bool play(bool stopLoading, bool stopPlaying, bool forceLoading) |
265 | + { | ||
266 | + try { | ||
267 | + if (loading) | ||
268 | + { | ||
269 | + if (stopLoading) | ||
226 | stop_animations(); | 270 | stop_animations(); |
227 | else | 271 | else |
272 | + return false; | ||
273 | + } | ||
274 | + else if (playing) | ||
275 | + { | ||
276 | + if (stopPlaying) | ||
228 | stopAnimations(); | 277 | stopAnimations(); |
229 | - } catch (NullReferenceException nre) { nre.ToString(); } | ||
230 | 278 | ||
231 | - StartCoroutine("loadAndPlay"); | ||
232 | - } | 279 | + else if ( ! forceLoading) |
280 | + return false; | ||
281 | + } | ||
282 | + } catch (NullReferenceException nre) { nre.ToString(); } | ||
233 | 283 | ||
234 | - onPlayingStateChange(); | 284 | + StartCoroutine("loadAndPlay"); |
285 | + return true; | ||
235 | } | 286 | } |
236 | 287 | ||
237 | 288 | ||
@@ -279,7 +330,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -279,7 +330,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
279 | bool defaultPlayed = false; | 330 | bool defaultPlayed = false; |
280 | 331 | ||
281 | // A reprodução da primeira letra deve ser longa para não ser cortada no fade | 332 | // A reprodução da primeira letra deve ser longa para não ser cortada no fade |
282 | - letterSpeed = getProporcionalSpeed(LETTER_FIRST_SPEED, LETTER_FIRST_UNIT_SPEED); | 333 | + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); |
283 | 334 | ||
284 | for (int i = 0; i < word.Length; i++) | 335 | for (int i = 0; i < word.Length; i++) |
285 | { | 336 | { |
@@ -293,11 +344,11 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -293,11 +344,11 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
293 | // Se for um número | 344 | // Se for um número |
294 | else if (second >= 48 && second <= 57) | 345 | else if (second >= 48 && second <= 57) |
295 | playAnimation(TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, numberSpeed); | 346 | playAnimation(TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, numberSpeed); |
296 | - | 347 | + |
297 | // Se for uma vírgula | 348 | // Se for uma vírgula |
298 | else if (second == 44) | 349 | else if (second == 44) |
299 | playAnimation(TYPE_WORD, second.ToString(), lastAnimationSubtitle); | 350 | playAnimation(TYPE_WORD, second.ToString(), lastAnimationSubtitle); |
300 | - | 351 | + |
301 | // Não há animação | 352 | // Não há animação |
302 | else | 353 | else |
303 | { | 354 | { |
@@ -308,7 +359,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -308,7 +359,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
308 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | 359 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); |
309 | 360 | ||
310 | // A reprodução da próxima letra deve ser longa para não ser cortada no fade | 361 | // A reprodução da próxima letra deve ser longa para não ser cortada no fade |
311 | - letterSpeed = getProporcionalSpeed(LETTER_FIRST_SPEED, LETTER_FIRST_UNIT_SPEED); | 362 | + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); |
312 | } | 363 | } |
313 | 364 | ||
314 | Debug.Log("Animação \"" + second + "\" inexistente."); | 365 | Debug.Log("Animação \"" + second + "\" inexistente."); |
@@ -316,23 +367,69 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -316,23 +367,69 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
316 | } | 367 | } |
317 | 368 | ||
318 | defaultPlayed = false; | 369 | defaultPlayed = false; |
319 | - letterSpeed = getProporcionalSpeed(LETTER_DEFAULT_SPEED, LETTER_UNIT_SPEED); | 370 | + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); |
320 | } | 371 | } |
321 | 372 | ||
322 | return lastAnimationSubtitle; | 373 | return lastAnimationSubtitle; |
323 | } | 374 | } |
324 | 375 | ||
325 | 376 | ||
377 | + protected IEnumerator loadAnimation(string name) | ||
378 | + { | ||
379 | + loadingSingleAnimation = true; | ||
380 | + | ||
381 | + // Função loadAssetBundle é definida pela classe filha | ||
382 | + WWW www = loadAssetBundle(name); | ||
383 | + | ||
384 | + if (www != null) | ||
385 | + { | ||
386 | + yield return www; | ||
387 | + | ||
388 | + AssetBundle bundle = null; | ||
389 | + | ||
390 | + if (www.error == null) | ||
391 | + bundle = www.assetBundle; | ||
392 | + | ||
393 | + if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) | ||
394 | + { | ||
395 | + AnimationClip aniClip = bundle.mainAsset as AnimationClip; | ||
396 | + bundle.Unload(false); | ||
397 | + | ||
398 | + if (aniClip) | ||
399 | + { | ||
400 | + COMPONENT_ANIMATION.AddClip(aniClip, name); | ||
401 | + | ||
402 | + // Reproduz palavra | ||
403 | + loadedAssetBundles.Add(name); | ||
404 | + yield break; | ||
405 | + } | ||
406 | + else Debug.Log ("Sinal \"" + name + "\" não carregado corretamente."); | ||
407 | + } | ||
408 | + } | ||
409 | + | ||
410 | + // Soletra palavra | ||
411 | + nonexistentAssetBundles.Add(name); | ||
412 | + | ||
413 | + loadingSingleAnimation = false; | ||
414 | + } | ||
415 | + | ||
416 | + | ||
326 | private IEnumerator loadAndPlay() | 417 | private IEnumerator loadAndPlay() |
327 | { | 418 | { |
328 | loading = true; | 419 | loading = true; |
420 | + onPlayingStateChange(); | ||
329 | 421 | ||
330 | string lastAnimationSubtitle = ""; | 422 | string lastAnimationSubtitle = ""; |
331 | bool spelled = false; | 423 | bool spelled = false; |
332 | 424 | ||
333 | // Default | 425 | // Default |
334 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 2F); | 426 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 2F); |
335 | - StartCoroutine("handleStates"); | 427 | + |
428 | + if ( ! playing) | ||
429 | + { | ||
430 | + playing = true; | ||
431 | + StartCoroutine("handleStates"); | ||
432 | + } | ||
336 | 433 | ||
337 | stringPos = glosa.Split(' '); | 434 | stringPos = glosa.Split(' '); |
338 | 435 | ||
@@ -389,7 +486,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -389,7 +486,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
389 | } | 486 | } |
390 | 487 | ||
391 | bool isPunctuation = false; | 488 | bool isPunctuation = false; |
392 | - lastAnimationSubtitle = aniName; | ||
393 | 489 | ||
394 | if (aniName[0] == '[') | 490 | if (aniName[0] == '[') |
395 | { | 491 | { |
@@ -410,15 +506,16 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -410,15 +506,16 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
410 | isPunctuation = true; | 506 | isPunctuation = true; |
411 | lastAnimationSubtitle = "!"; | 507 | lastAnimationSubtitle = "!"; |
412 | } | 508 | } |
509 | + else | ||
510 | + { | ||
511 | + lastAnimationSubtitle = aniName; | ||
512 | + } | ||
413 | } | 513 | } |
414 | 514 | ||
415 | if (isPunctuation) | 515 | if (isPunctuation) |
416 | playAnimation(TYPE_WORD, aniName, lastAnimationSubtitle); | 516 | playAnimation(TYPE_WORD, aniName, lastAnimationSubtitle); |
417 | else | 517 | else |
418 | playAnimation(TYPE_WORD, aniName); | 518 | playAnimation(TYPE_WORD, aniName); |
419 | - | ||
420 | - /*playAnimation(TYPE_WORD, aniName); | ||
421 | - lastAnimationSubtitle = aniName;*/ | ||
422 | } | 519 | } |
423 | // Soletra palavra | 520 | // Soletra palavra |
424 | else | 521 | else |
@@ -428,29 +525,33 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -428,29 +525,33 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
428 | if ( ! nonexistent) | 525 | if ( ! nonexistent) |
429 | nonexistentAssetBundles.Add(aniName); | 526 | nonexistentAssetBundles.Add(aniName); |
430 | 527 | ||
431 | - if (aniName[0] == '[' && (aniName.Equals("[PONTO]") || aniName.Equals("[INTERROGACAO]") || aniName.Equals("[EXCLAMACAO]"))) | 528 | + Debug.Log("~~ To spell: " + aniName); |
529 | + | ||
530 | + if (aniName.Equals("[PONTO]") || aniName.Equals("[INTERROGACAO]") || aniName.Equals("[EXCLAMACAO]")) | ||
432 | { | 531 | { |
433 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); | 532 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); |
533 | + continue; | ||
434 | } | 534 | } |
535 | + | ||
536 | + // Se já houve o soletramento de alguma palavra, reproduz animação default | ||
537 | + if (spelled) | ||
538 | + playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); | ||
435 | else | 539 | else |
436 | - { | ||
437 | - // Se já houve o soletramento de alguma palavra, reproduz animação default | ||
438 | - if (spelled) | ||
439 | - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); | ||
440 | - else | ||
441 | - spelled = true; | 540 | + spelled = true; |
442 | 541 | ||
443 | - lastAnimationSubtitle = spellWord(aniName); | ||
444 | - } | 542 | + lastAnimationSubtitle = spellWord(aniName); |
445 | } | 543 | } |
446 | } | 544 | } |
447 | 545 | ||
448 | // Default | 546 | // Default |
449 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | 547 | playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); |
450 | - loading = false; | ||
451 | 548 | ||
549 | + loading = false; | ||
550 | + onPlayingStateChange(); | ||
452 | } | 551 | } |
453 | 552 | ||
553 | + //int _id = 0; | ||
554 | + | ||
454 | /* | 555 | /* |
455 | * Sincroniza as legendas com as animações. | 556 | * Sincroniza as legendas com as animações. |
456 | */ | 557 | */ |
@@ -467,9 +568,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -467,9 +568,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
467 | setSubtitle(reference.subtitle); | 568 | setSubtitle(reference.subtitle); |
468 | 569 | ||
469 | while (COMPONENT_ANIMATION.IsPlaying(reference.name)) | 570 | while (COMPONENT_ANIMATION.IsPlaying(reference.name)) |
571 | + { | ||
572 | + reference.playing = true; | ||
470 | yield return null; | 573 | yield return null; |
574 | + } | ||
471 | 575 | ||
472 | - animQueue.Dequeue(); | 576 | + if (reference.state == null) |
577 | + animQueue.Dequeue(); | ||
578 | + else | ||
579 | + yield return null; | ||
473 | } | 580 | } |
474 | else yield return null; | 581 | else yield return null; |
475 | 582 | ||
@@ -479,19 +586,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -479,19 +586,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
479 | playing = false; | 586 | playing = false; |
480 | paused = false; | 587 | paused = false; |
481 | onPlayingStateChange(); | 588 | onPlayingStateChange(); |
482 | - | ||
483 | - } | ||
484 | - | ||
485 | - | ||
486 | - /* | ||
487 | - * Chamada quando o player sinaliza UPDATE ou STOP. | ||
488 | - * Limpa as filas de assets existentes e não existentes | ||
489 | - * permitindo que novos assets sejam executados | ||
490 | - */ | ||
491 | - public void clear() | ||
492 | - { | ||
493 | - nonexistentAssetBundles.Clear(); | ||
494 | - loadedAssetBundles.Clear(); | ||
495 | } | 589 | } |
496 | 590 | ||
497 | } | 591 | } |
Assets/Scripts/PlayerManager.cs
@@ -48,14 +48,12 @@ public class PlayerManager : GenericPlayerManager { | @@ -48,14 +48,12 @@ public class PlayerManager : GenericPlayerManager { | ||
48 | // a terceira, para testes com a textbox | 48 | // a terceira, para testes com a textbox |
49 | public string catchGlosa() | 49 | public string catchGlosa() |
50 | { | 50 | { |
51 | - glosa = Marshal.PtrToStringAnsi ( coreExecute( ) ); | ||
52 | - //osa = "PIZZA"; | ||
53 | - return glosa; | 51 | + return base.glosa = Marshal.PtrToStringAnsi ( coreExecute( ) ); |
54 | } | 52 | } |
55 | 53 | ||
56 | public void start_local_play() | 54 | public void start_local_play() |
57 | { | 55 | { |
58 | - catchGlosa(); | 56 | + this.catchGlosa(); |
59 | base.play(); | 57 | base.play(); |
60 | } | 58 | } |
61 | 59 | ||
@@ -78,9 +76,9 @@ public class PlayerManager : GenericPlayerManager { | @@ -78,9 +76,9 @@ public class PlayerManager : GenericPlayerManager { | ||
78 | 76 | ||
79 | protected override void onPlayingStateChange() | 77 | protected override void onPlayingStateChange() |
80 | { | 78 | { |
81 | - if (base.playing) | 79 | + if (base.isPlaying()) |
82 | { | 80 | { |
83 | - playButton.GetComponent<Image>().sprite = base.paused | 81 | + playButton.GetComponent<Image>().sprite = base.isPaused() |
84 | ? playSprite : pauseSprite; | 82 | ? playSprite : pauseSprite; |
85 | 83 | ||
86 | stopButtonGraphic.color = enabledAlpha; | 84 | stopButtonGraphic.color = enabledAlpha; |
ProjectSettings/ProjectSettings.asset
@@ -115,6 +115,7 @@ PlayerSettings: | @@ -115,6 +115,7 @@ PlayerSettings: | ||
115 | iPhoneTargetOSVersion: 22 | 115 | iPhoneTargetOSVersion: 22 |
116 | uIPrerenderedIcon: 0 | 116 | uIPrerenderedIcon: 0 |
117 | uIRequiresPersistentWiFi: 0 | 117 | uIRequiresPersistentWiFi: 0 |
118 | + uIRequiresFullScreen: 1 | ||
118 | uIStatusBarHidden: 1 | 119 | uIStatusBarHidden: 1 |
119 | uIExitOnSuspend: 0 | 120 | uIExitOnSuspend: 0 |
120 | uIStatusBarStyle: 0 | 121 | uIStatusBarStyle: 0 |
@@ -163,8 +164,10 @@ PlayerSettings: | @@ -163,8 +164,10 @@ PlayerSettings: | ||
163 | m_BuildTargetIcons: | 164 | m_BuildTargetIcons: |
164 | - m_BuildTarget: | 165 | - m_BuildTarget: |
165 | m_Icons: | 166 | m_Icons: |
166 | - - m_Icon: {fileID: 2800000, guid: 98a8d3ec5bfc6ef4bacfcc810c9edf5a, type: 3} | ||
167 | - m_Size: 128 | 167 | + - serializedVersion: 2 |
168 | + m_Icon: {fileID: 2800000, guid: 98a8d3ec5bfc6ef4bacfcc810c9edf5a, type: 3} | ||
169 | + m_Width: 128 | ||
170 | + m_Height: 128 | ||
168 | m_BuildTargetBatching: | 171 | m_BuildTargetBatching: |
169 | - m_BuildTarget: WebGL | 172 | - m_BuildTarget: WebGL |
170 | m_StaticBatching: 1 | 173 | m_StaticBatching: 1 |
@@ -261,6 +264,10 @@ PlayerSettings: | @@ -261,6 +264,10 @@ PlayerSettings: | ||
261 | ps4pnGameCustomData: 1 | 264 | ps4pnGameCustomData: 1 |
262 | playerPrefsSupport: 0 | 265 | playerPrefsSupport: 0 |
263 | ps4ReprojectionSupport: 0 | 266 | ps4ReprojectionSupport: 0 |
267 | + ps4UseAudio3dBackend: 0 | ||
268 | + ps4Audio3dVirtualSpeakerCount: 14 | ||
269 | + ps4attribCpuUsage: 0 | ||
270 | + ps4SocialScreenEnabled: 0 | ||
264 | ps4attribUserManagement: 0 | 271 | ps4attribUserManagement: 0 |
265 | ps4attribMoveSupport: 0 | 272 | ps4attribMoveSupport: 0 |
266 | ps4attrib3DSupport: 0 | 273 | ps4attrib3DSupport: 0 |
ProjectSettings/ProjectVersion.txt