Commit e60792b120f21e2c2c5b4dddbfa5c69de1335c47

Authored by Mateus Lustosa
1 parent 66485826
Exists in master and in 1 other branch dev

Refatoracao; Animacoes aleatorias.

Assets/Bundles/[IAE] 0 → 100644
No preview for this file type
Assets/Bundles/[OI] 0 → 100644
No preview for this file type
Assets/Bundles/[OLA] 0 → 100644
No preview for this file type
Assets/Scripts/AnimationReference.cs 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +using UnityEngine;
  2 +
  3 +public class AnimationReference
  4 +{
  5 + public string name;
  6 + public string subtitle;
  7 + public AnimationState state;
  8 + public short type;
  9 + public bool playing;
  10 +
  11 + public AnimationReference(string name, string subtitle, AnimationState state, short type)
  12 + {
  13 + this.name = name;
  14 + this.subtitle = subtitle;
  15 + this.state = state;
  16 + this.type = type;
  17 + this.playing = false;
  18 + }
  19 +}
0 \ No newline at end of file 20 \ No newline at end of file
Assets/Scripts/AnimationReference.cs.meta 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +fileFormatVersion: 2
  2 +guid: 0a79f85598da5e245b6beae9133a8a26
  3 +timeCreated: 1452687065
  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/DefaultSignSpeed.cs 0 → 100644
@@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
  1 +/**
  2 + * Configura a velocidade de reprodução de sinais com relação a uma
  3 + * velocidade padrão e a velocidade ajustada pelo usuário.
  4 + */
  5 +public class DefaultSignSpeed
  6 +{
  7 + public static float DEFAULT = 1.1F;
  8 + public static float DEFAULT_MAX = 2F;
  9 +
  10 + // Velocidade padrão
  11 + private float speed;
  12 + // Velocidade máxima
  13 + private float max;
  14 + // Relação entre a velocidade do tipo representado e a velocidade padrão (speed)
  15 + private float unit;
  16 +
  17 + public DefaultSignSpeed()
  18 + {
  19 + this.speed = DEFAULT;
  20 + this.max = DEFAULT_MAX;
  21 + this.unit = 1F;
  22 + }
  23 +
  24 + public DefaultSignSpeed(float defaultSpeed, float defaultMaxSpeed)
  25 + {
  26 + this.speed = defaultSpeed;
  27 + this.max = defaultMaxSpeed;
  28 + this.unit = (this.max - this.speed) / (DEFAULT_MAX - DEFAULT);
  29 + }
  30 +
  31 + public float Speed {
  32 + get { return this.speed; }
  33 + set {
  34 + this.speed = value;
  35 + this.unit = calculateUnit();
  36 + }
  37 + }
  38 + public float Max {
  39 + get { return this.max; }
  40 + set {
  41 + this.speed = value;
  42 + this.unit = calculateUnit();
  43 + }
  44 + }
  45 + public float Unit {
  46 + get { return this.unit; }
  47 + }
  48 +
  49 +
  50 + private float calculateUnit()
  51 + {
  52 + return (this.max - this.speed) / (DEFAULT_MAX - DEFAULT);
  53 + }
  54 +
  55 + /*
  56 + * Retorna velocidade em relação ao estado do slider.
  57 + * @param slider - estado do slider (valor entre "speed - max" e "max")
  58 + */
  59 + public float getProportional(float slider)
  60 + {
  61 + return this.speed + (slider - DEFAULT) * this.unit;
  62 + }
  63 +}
0 \ No newline at end of file 64 \ No newline at end of file
Assets/Scripts/DefaultSignSpeed.cs.meta 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +fileFormatVersion: 2
  2 +guid: 65beafb116ad9fe4fbf6eee8d0253b39
  3 +timeCreated: 1452687065
  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
@@ -6,82 +6,16 @@ using System; @@ -6,82 +6,16 @@ using System;
6 using System.IO; 6 using System.IO;
7 using System.Text; 7 using System.Text;
8 using System.Runtime.InteropServices; 8 using System.Runtime.InteropServices;
  9 +using System.Diagnostics;
9 using UnityEngine.UI; 10 using UnityEngine.UI;
10 11
11 public abstract class GenericPlayerManager : MonoBehaviour { 12 public abstract class GenericPlayerManager : MonoBehaviour {
12 13
13 - private class AnimationReference  
14 - {  
15 - public string name;  
16 - public string subtitle;  
17 - public AnimationState state;  
18 - public short type;  
19 - public bool playing;  
20 -  
21 - public AnimationReference(string name, string subtitle, AnimationState state, short type)  
22 - {  
23 - this.name = name;  
24 - this.subtitle = subtitle;  
25 - this.state = state;  
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);  
53 - }  
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 - }  
63 - }  
64 -  
65 private const string DEFAULT_ANIMATION = "_default"; 14 private const string DEFAULT_ANIMATION = "_default";
66 private const string NONE_ANIMATION = "_defaultWORD"; 15 private const string NONE_ANIMATION = "_defaultWORD";
67 16
68 protected float fadeLength = 0.6F; 17 protected float fadeLength = 0.6F;
69 18
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);  
74 -  
75 - private const short TYPE_NONE = -1;  
76 - private const short TYPE_WORD = 0;  
77 - private const short TYPE_LETTER = 1;  
78 - private const short TYPE_NUMBER = 2;  
79 -  
80 - private float hSlidersecond = DefaultSignSpeed.DEFAULT;  
81 - private float wordSpeed = DefaultSignSpeed.DEFAULT;  
82 - private float letterSpeed = DefaultSignSpeed.DEFAULT;  
83 - private float numberSpeed = DefaultSignSpeed.DEFAULT;  
84 -  
85 protected string glosa = ""; 19 protected string glosa = "";
86 private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa 20 private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa
87 21
@@ -89,7 +23,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -89,7 +23,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
89 private Animation COMPONENT_ANIMATION; 23 private Animation COMPONENT_ANIMATION;
90 private BoxCollider AVATAR_COLLIDER; 24 private BoxCollider AVATAR_COLLIDER;
91 public Text SUBTITLES; 25 public Text SUBTITLES;
92 - 26 +
93 // Guarda os nomes das palavras ja carregadas. 27 // Guarda os nomes das palavras ja carregadas.
94 private HashSet<string> loadedAssetBundles = new HashSet<string>(); 28 private HashSet<string> loadedAssetBundles = new HashSet<string>();
95 // Guarda os nomes das palavras que nao tem assetbundle. 29 // Guarda os nomes das palavras que nao tem assetbundle.
@@ -104,15 +38,26 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -104,15 +38,26 @@ public abstract class GenericPlayerManager : MonoBehaviour {
104 private volatile bool playing = false; 38 private volatile bool playing = false;
105 private volatile bool paused = false; 39 private volatile bool paused = false;
106 40
  41 + private Stopwatch watch = new Stopwatch();
  42 + private string lastRandom = "";
  43 + private int repeated = 0;
  44 +
  45 + private Subtitle subtitle;
  46 +
107 public virtual void Start() 47 public virtual void Start()
108 { 48 {
109 - wordSpeed = defaultWordSpeed.speed;  
110 - letterSpeed = defaultLetterSpeed.speed;  
111 - numberSpeed = defaultNumberSpeed.speed; 49 + subtitle = new Subtitle(SUBTITLES);
  50 + subtitle.DefaultWordSpeed = new DefaultSignSpeed();
  51 + subtitle.DefaultFirstLetterSpeed = new DefaultSignSpeed(2.1F, 2.8F);
  52 + subtitle.DefaultLetterSpeed = new DefaultSignSpeed(3F, 4.3F);
  53 + subtitle.DefaultNumberSpeed = new DefaultSignSpeed(1.5F, 2.9F);
112 54
113 AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar 55 AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar
114 COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar 56 COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar
115 AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); 57 AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>();
  58 +
  59 + watch.Start();
  60 + Invoke("playRandomAnimation", 5);
116 } 61 }
117 62
118 public bool isLoadingSingleAnimation() { return loadingSingleAnimation; } 63 public bool isLoadingSingleAnimation() { return loadingSingleAnimation; }
@@ -120,6 +65,46 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -120,6 +65,46 @@ public abstract class GenericPlayerManager : MonoBehaviour {
120 public bool isPlaying() { return playing; } 65 public bool isPlaying() { return playing; }
121 public bool isPaused() { return paused; } 66 public bool isPaused() { return paused; }
122 67
  68 +
  69 + private void stopWatch() {
  70 + watch.Stop();
  71 + watch.Reset();
  72 + }
  73 +
  74 + private void continueWatch() {
  75 + watch.Start();
  76 + }
  77 +
  78 + private void playRandomAnimation(string glosa)
  79 + {
  80 + stopWatch();
  81 +
  82 + this.glosa = glosa;
  83 + this.play();
  84 + }
  85 +
  86 + private void playRandomAnimation()
  87 + {
  88 + if (watch.Elapsed.Seconds >= 1)
  89 + {
  90 + int rand = new System.Random().Next(3);
  91 +
  92 + switch (rand)
  93 + {
  94 + case 0: playRandomAnimation("[OLA]");
  95 + break;
  96 +
  97 + case 1: playRandomAnimation("[OI]");
  98 + break;
  99 +
  100 + case 2: playRandomAnimation("[IAE]");
  101 + break;
  102 + }
  103 + }
  104 +
  105 + Invoke("playRandomAnimation", 1);
  106 + }
  107 +
123 public void SetAvatarCollider(bool isActive) 108 public void SetAvatarCollider(bool isActive)
124 { 109 {
125 AVATAR_COLLIDER.enabled = isActive; 110 AVATAR_COLLIDER.enabled = isActive;
@@ -131,17 +116,16 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -131,17 +116,16 @@ public abstract class GenericPlayerManager : MonoBehaviour {
131 } 116 }
132 117
133 // Define a velocidade das animacões com base no slider da GUI 118 // Define a velocidade das animacões com base no slider da GUI
134 - public void setSlider(float x) 119 + public void setSlider(float sliderPosition)
135 { 120 {
136 - hSlidersecond = x;  
137 -  
138 - wordSpeed = defaultWordSpeed.getProporcionalSpeed(x);  
139 - letterSpeed = defaultLetterSpeed.getProporcionalSpeed(x);  
140 - numberSpeed = defaultNumberSpeed.getProporcionalSpeed(x); 121 + subtitle.SliderPosition = sliderPosition;
  122 + subtitle.updateWordSpeed();
  123 + subtitle.updateLetterSpeed();
  124 + subtitle.updateNumberSpeed();
141 125
142 if ( ! paused) 126 if ( ! paused)
143 foreach (AnimationReference reference in animQueue) 127 foreach (AnimationReference reference in animQueue)
144 - if (reference.type != TYPE_NONE && reference.state != null) 128 + if (reference.type != Subtitle.TYPE_NONE && reference.state != null)
145 reference.state.speed = getSpeedByType(reference.type); 129 reference.state.speed = getSpeedByType(reference.type);
146 } 130 }
147 131
@@ -149,9 +133,9 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -149,9 +133,9 @@ public abstract class GenericPlayerManager : MonoBehaviour {
149 { 133 {
150 switch (type) 134 switch (type)
151 { 135 {
152 - case TYPE_WORD: return wordSpeed;  
153 - case TYPE_LETTER: return letterSpeed;  
154 - case TYPE_NUMBER: return numberSpeed; 136 + case Subtitle.TYPE_WORD: return subtitle.WordSpeed;
  137 + case Subtitle.TYPE_LETTER: return subtitle.LetterSpeed;
  138 + case Subtitle.TYPE_NUMBER: return subtitle.NumberSpeed;
155 } 139 }
156 140
157 return 2F; 141 return 2F;
@@ -174,13 +158,13 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -174,13 +158,13 @@ public abstract class GenericPlayerManager : MonoBehaviour {
174 { 158 {
175 try { 159 try {
176 StopCoroutine("handleStates"); 160 StopCoroutine("handleStates");
177 - } catch (NullReferenceException nre) { Debug.Log("StopCoroutine handlestates nullreff::"+nre.ToString()); } 161 + } catch (NullReferenceException nre) { UnityEngine.Debug.Log("StopCoroutine handlestates nullreff::"+nre.ToString()); }
178 162
179 setSubtitle(""); 163 setSubtitle("");
180 164
181 try { 165 try {
182 animQueue.Clear(); 166 animQueue.Clear();
183 - } catch (NullReferenceException nre) { Debug.Log("SetQueueList null reff::"+nre.ToString()); } 167 + } catch (NullReferenceException nre) { UnityEngine.Debug.Log("SetQueueList null reff::"+nre.ToString()); }
184 168
185 COMPONENT_ANIMATION.Stop(); 169 COMPONENT_ANIMATION.Stop();
186 COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll); 170 COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll);
@@ -188,10 +172,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -188,10 +172,6 @@ public abstract class GenericPlayerManager : MonoBehaviour {
188 172
189 /* 173 /*
190 * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. 174 * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas.
191 - *  
192 - * Caso não haja SUBTITLE, name será utilizado como SUBTITLE.  
193 - * Caso não haja fadeLength, será atribuido fadeLength.  
194 - * Caso não haja velocidade, hSlidersecond será atribuída.  
195 */ 175 */
196 private AnimationState playAnimation(short type, string name, string subtitle, float speed) 176 private AnimationState playAnimation(short type, string name, string subtitle, float speed)
197 { 177 {
@@ -205,7 +185,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -205,7 +185,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
205 } 185 }
206 catch (NullReferenceException nre) 186 catch (NullReferenceException nre)
207 { 187 {
208 - Debug.Log("'" + name + "' não foi encontrado!\n" + nre.ToString()); 188 + UnityEngine.Debug.Log("'" + name + "' não foi encontrado!\n" + nre.ToString());
209 } 189 }
210 190
211 return null; 191 return null;
@@ -285,40 +265,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -285,40 +265,6 @@ public abstract class GenericPlayerManager : MonoBehaviour {
285 return true; 265 return true;
286 } 266 }
287 267
288 -  
289 - /*  
290 - * Destaca caractere de uma string.  
291 - */  
292 - private string highlight(string word, int index)  
293 - {  
294 - string subtitle = "";  
295 - int last = 0;  
296 -  
297 - if (index == 0)  
298 - subtitle += "<b><color=white>" + word[0] + "</color></b>";  
299 - else  
300 - subtitle += word[0];  
301 -  
302 - for (int i = 1; i < word.Length; i++)  
303 - {  
304 - if ((word[i] >= 65 && word[i] <= 90) || (word[i] >= 48 && word[i] <= 57))  
305 - subtitle += "-";  
306 -  
307 - if (i == index || (last == index && word[i] == word[last]))  
308 - {  
309 - subtitle += "<b><color=white>" + word[i] + "</color></b>";  
310 - if (i == index) last = i;  
311 - }  
312 - else  
313 - {  
314 - subtitle += word[i];  
315 - last = i;  
316 - }  
317 - }  
318 -  
319 - return subtitle;  
320 - }  
321 -  
322 /** 268 /**
323 * Spells word. 269 * Spells word.
324 * 270 *
@@ -330,24 +276,24 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -330,24 +276,24 @@ public abstract class GenericPlayerManager : MonoBehaviour {
330 bool defaultPlayed = false; 276 bool defaultPlayed = false;
331 277
332 // A reprodução da primeira letra deve ser longa para não ser cortada no fade 278 // A reprodução da primeira letra deve ser longa para não ser cortada no fade
333 - letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); 279 + subtitle.updateLetterSpeed();
334 280
335 for (int i = 0; i < word.Length; i++) 281 for (int i = 0; i < word.Length; i++)
336 { 282 {
337 char second = word[i]; 283 char second = word[i];
338 - lastAnimationSubtitle = highlight(word, i); 284 + lastAnimationSubtitle = Subtitle.highlight(word, i);
339 285
340 // Se for uma letra 286 // Se for uma letra
341 if (second >= 65 && second <= 90) 287 if (second >= 65 && second <= 90)
342 - playAnimation(TYPE_LETTER, second.ToString(), lastAnimationSubtitle, letterSpeed); 288 + playAnimation(Subtitle.TYPE_LETTER, second.ToString(), lastAnimationSubtitle, subtitle.LetterSpeed);
343 289
344 // Se for um número 290 // Se for um número
345 else if (second >= 48 && second <= 57) 291 else if (second >= 48 && second <= 57)
346 - playAnimation(TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, numberSpeed); 292 + playAnimation(Subtitle.TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, subtitle.NumberSpeed);
347 293
348 // Se for uma vírgula 294 // Se for uma vírgula
349 else if (second == 44) 295 else if (second == 44)
350 - playAnimation(TYPE_WORD, second.ToString(), lastAnimationSubtitle); 296 + playAnimation(Subtitle.TYPE_WORD, second.ToString(), lastAnimationSubtitle);
351 297
352 // Não há animação 298 // Não há animação
353 else 299 else
@@ -356,18 +302,18 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -356,18 +302,18 @@ public abstract class GenericPlayerManager : MonoBehaviour {
356 if ( ! defaultPlayed) 302 if ( ! defaultPlayed)
357 { 303 {
358 defaultPlayed = true; 304 defaultPlayed = true;
359 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); 305 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle);
360 306
361 // A reprodução da próxima letra deve ser longa para não ser cortada no fade 307 // A reprodução da próxima letra deve ser longa para não ser cortada no fade
362 - letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); 308 + subtitle.updateLetterSpeed();
363 } 309 }
364 310
365 - Debug.Log("Animação \"" + second + "\" inexistente."); 311 + UnityEngine.Debug.Log("Animação \"" + second + "\" inexistente.");
366 continue; 312 continue;
367 } 313 }
368 314
369 defaultPlayed = false; 315 defaultPlayed = false;
370 - letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); 316 + subtitle.updateLetterSpeed();
371 } 317 }
372 318
373 return lastAnimationSubtitle; 319 return lastAnimationSubtitle;
@@ -403,7 +349,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -403,7 +349,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
403 loadedAssetBundles.Add(name); 349 loadedAssetBundles.Add(name);
404 yield break; 350 yield break;
405 } 351 }
406 - else Debug.Log ("Sinal \"" + name + "\" não carregado corretamente."); 352 + else UnityEngine.Debug.Log ("Sinal \"" + name + "\" não carregado corretamente.");
407 } 353 }
408 } 354 }
409 355
@@ -414,6 +360,16 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -414,6 +360,16 @@ public abstract class GenericPlayerManager : MonoBehaviour {
414 } 360 }
415 361
416 362
  363 + private bool isFlag(string animationName)
  364 + {
  365 + return animationName.Equals("[PONTO]")
  366 + || animationName.Equals("[INTERROGACAO]")
  367 + || animationName.Equals("[EXCLAMACAO]")
  368 + || animationName.Equals("[OLA]")
  369 + || animationName.Equals("[OI]")
  370 + || animationName.Equals("[IAE]");
  371 + }
  372 +
417 private IEnumerator loadAndPlay() 373 private IEnumerator loadAndPlay()
418 { 374 {
419 loading = true; 375 loading = true;
@@ -423,7 +379,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -423,7 +379,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
423 bool spelled = false; 379 bool spelled = false;
424 380
425 // Default 381 // Default
426 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 2F); 382 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 2F);
427 383
428 if ( ! playing) 384 if ( ! playing)
429 { 385 {
@@ -438,7 +394,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -438,7 +394,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
438 try { 394 try {
439 if (String.IsNullOrEmpty(aniName)) continue; 395 if (String.IsNullOrEmpty(aniName)) continue;
440 } catch (Exception e) { 396 } catch (Exception e) {
441 - Debug.Log(e + " :: NotNullNotEmpty"); 397 + UnityEngine.Debug.Log(e + " :: NotNullNotEmpty");
442 } 398 }
443 399
444 bool nonexistent = nonexistentAssetBundles.Contains(aniName); 400 bool nonexistent = nonexistentAssetBundles.Contains(aniName);
@@ -470,7 +426,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -470,7 +426,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
470 loadedAssetBundles.Add(aniName); 426 loadedAssetBundles.Add(aniName);
471 loaded = true; 427 loaded = true;
472 } 428 }
473 - else Debug.Log ("Sinal \"" + aniName + "\" não carregado corretamente."); 429 + else UnityEngine.Debug.Log ("Sinal \"" + aniName + "\" não carregado corretamente.");
474 } 430 }
475 } 431 }
476 } 432 }
@@ -481,41 +437,31 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -481,41 +437,31 @@ public abstract class GenericPlayerManager : MonoBehaviour {
481 if (spelled) 437 if (spelled)
482 { 438 {
483 // Default 439 // Default
484 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); 440 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle);
485 spelled = false; 441 spelled = false;
486 } 442 }
487 443
488 - bool isPunctuation = false; 444 + //bool isFlag = false;
489 445
490 - if (aniName[0] == '[')  
491 - {  
492 - if (aniName.Equals("[PONTO]")) 446 + //if (aniName[0] == '[')
  447 + //{
  448 + if (isFlag(aniName))
493 { 449 {
494 - isPunctuation = true;  
495 - lastAnimationSubtitle = ".";  
496 - }  
497 -  
498 - else if (aniName.Equals("[INTERROGACAO]"))  
499 - {  
500 - isPunctuation = true;  
501 - lastAnimationSubtitle = "?";  
502 - }  
503 -  
504 - else if (aniName.Equals("[EXCLAMACAO]"))  
505 - {  
506 - isPunctuation = true;  
507 - lastAnimationSubtitle = "!"; 450 + //isFlag = true;
  451 + lastAnimationSubtitle = "";
  452 + playAnimation(Subtitle.TYPE_WORD, aniName, "");
508 } 453 }
509 else 454 else
510 { 455 {
511 lastAnimationSubtitle = aniName; 456 lastAnimationSubtitle = aniName;
  457 + playAnimation(Subtitle.TYPE_WORD, aniName);
512 } 458 }
513 - } 459 + //}
514 460
515 - if (isPunctuation)  
516 - playAnimation(TYPE_WORD, aniName, lastAnimationSubtitle); 461 + /*if (isFlag)
  462 + playAnimation(Subtitle.TYPE_WORD, aniName, "");
517 else 463 else
518 - playAnimation(TYPE_WORD, aniName); 464 + playAnimation(Subtitle.TYPE_WORD, aniName);*/
519 } 465 }
520 // Soletra palavra 466 // Soletra palavra
521 else 467 else
@@ -525,17 +471,17 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -525,17 +471,17 @@ public abstract class GenericPlayerManager : MonoBehaviour {
525 if ( ! nonexistent) 471 if ( ! nonexistent)
526 nonexistentAssetBundles.Add(aniName); 472 nonexistentAssetBundles.Add(aniName);
527 473
528 - Debug.Log("~~ To spell: " + aniName); 474 + UnityEngine.Debug.Log("~~ To spell: " + aniName);
529 475
530 - if (aniName.Equals("[PONTO]") || aniName.Equals("[INTERROGACAO]") || aniName.Equals("[EXCLAMACAO]")) 476 + if (isFlag(aniName))
531 { 477 {
532 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); 478 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F);
533 continue; 479 continue;
534 } 480 }
535 481
536 // Se já houve o soletramento de alguma palavra, reproduz animação default 482 // Se já houve o soletramento de alguma palavra, reproduz animação default
537 if (spelled) 483 if (spelled)
538 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); 484 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F);
539 else 485 else
540 spelled = true; 486 spelled = true;
541 487
@@ -544,7 +490,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -544,7 +490,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
544 } 490 }
545 491
546 // Default 492 // Default
547 - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); 493 + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "");
548 494
549 loading = false; 495 loading = false;
550 onPlayingStateChange(); 496 onPlayingStateChange();
@@ -557,6 +503,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -557,6 +503,8 @@ public abstract class GenericPlayerManager : MonoBehaviour {
557 */ 503 */
558 IEnumerator handleStates() 504 IEnumerator handleStates()
559 { 505 {
  506 + stopWatch();
  507 +
560 // Enquanto estiver executando a rotina "loadAndPlay" 508 // Enquanto estiver executando a rotina "loadAndPlay"
561 // ou existir animações na fila de reprodução 509 // ou existir animações na fila de reprodução
562 while (loading || animQueue.Count > 0) 510 while (loading || animQueue.Count > 0)
@@ -586,6 +534,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { @@ -586,6 +534,8 @@ public abstract class GenericPlayerManager : MonoBehaviour {
586 playing = false; 534 playing = false;
587 paused = false; 535 paused = false;
588 onPlayingStateChange(); 536 onPlayingStateChange();
  537 +
  538 + continueWatch();
589 } 539 }
590 540
591 } 541 }
Assets/Scripts/Subtitle.cs 0 → 100644
@@ -0,0 +1,134 @@ @@ -0,0 +1,134 @@
  1 +using UnityEngine.UI;
  2 +
  3 +public class Subtitle {
  4 +
  5 + public const short TYPE_NONE = -1;
  6 + public const short TYPE_WORD = 0;
  7 + public const short TYPE_LETTER = 1;
  8 + public const short TYPE_NUMBER = 2;
  9 +
  10 + protected DefaultSignSpeed defaultWordSpeed = new DefaultSignSpeed();
  11 + protected DefaultSignSpeed defaultFirstLetterSpeed = new DefaultSignSpeed();
  12 + protected DefaultSignSpeed defaultLetterSpeed = new DefaultSignSpeed();
  13 + protected DefaultSignSpeed defaultNumberSpeed = new DefaultSignSpeed();
  14 +
  15 + private float sliderPosition = DefaultSignSpeed.DEFAULT;
  16 +
  17 + private float wordSpeed = DefaultSignSpeed.DEFAULT;
  18 + private float letterSpeed = DefaultSignSpeed.DEFAULT;
  19 + private float numberSpeed = DefaultSignSpeed.DEFAULT;
  20 +
  21 + public Text SUBTITLES;
  22 +
  23 +
  24 + public Subtitle(Text subtitles)
  25 + {
  26 + this.SUBTITLES = subtitles;
  27 + }
  28 +
  29 + public DefaultSignSpeed DefaultWordSpeed {
  30 + get { return this.defaultWordSpeed; }
  31 + set {
  32 + this.defaultWordSpeed = value;
  33 + this.wordSpeed = value.Speed;
  34 + }
  35 + }
  36 +
  37 + public DefaultSignSpeed DefaultFirstLetterSpeed {
  38 + get { return this.defaultFirstLetterSpeed; }
  39 + set { this.defaultFirstLetterSpeed = value; }
  40 + }
  41 +
  42 + public DefaultSignSpeed DefaultLetterSpeed {
  43 + get { return this.defaultLetterSpeed; }
  44 + set {
  45 + this.defaultLetterSpeed = value;
  46 + this.letterSpeed = value.Speed;
  47 + }
  48 + }
  49 +
  50 + public DefaultSignSpeed DefaultNumberSpeed {
  51 + get { return this.defaultNumberSpeed; }
  52 + set {
  53 + this.defaultNumberSpeed = value;
  54 + this.numberSpeed = value.Speed;
  55 + }
  56 + }
  57 +
  58 + public float WordSpeed {
  59 + get { return this.wordSpeed; }
  60 + set { this.wordSpeed = value; }
  61 + }
  62 +
  63 + public float LetterSpeed {
  64 + get { return this.letterSpeed; }
  65 + set { this.letterSpeed = value; }
  66 + }
  67 +
  68 + public float NumberSpeed {
  69 + get { return this.numberSpeed; }
  70 + set { this.numberSpeed = value; }
  71 + }
  72 +
  73 + public float SliderPosition {
  74 + get { return this.sliderPosition; }
  75 + set { this.sliderPosition = value; }
  76 + }
  77 +
  78 +
  79 + public void updateWordSpeed(float sliderPosition) {
  80 + this.WordSpeed = this.DefaultWordSpeed.getProportional(sliderPosition);
  81 + }
  82 + public void updateWordSpeed() {
  83 + this.WordSpeed = this.DefaultWordSpeed.getProportional(this.SliderPosition);
  84 + }
  85 +
  86 + public void updateLetterSpeed(float sliderPosition) {
  87 + this.LetterSpeed = this.DefaultLetterSpeed.getProportional(sliderPosition);
  88 + }
  89 + public void updateLetterSpeed() {
  90 + this.LetterSpeed = this.DefaultLetterSpeed.getProportional(this.SliderPosition);
  91 + }
  92 +
  93 + public void updateNumberSpeed(float sliderPosition) {
  94 + this.NumberSpeed = this.DefaultNumberSpeed.getProportional(sliderPosition);
  95 + }
  96 + public void updateNumberSpeed() {
  97 + this.NumberSpeed = this.DefaultNumberSpeed.getProportional(this.SliderPosition);
  98 + }
  99 +
  100 +
  101 + /*
  102 + * Destaca caractere de uma string.
  103 + */
  104 + public static string highlight(string word, int index)
  105 + {
  106 + string subtitle = "";
  107 + int last = 0;
  108 +
  109 + if (index == 0)
  110 + subtitle += "<b><color=white>" + word[0] + "</color></b>";
  111 + else
  112 + subtitle += word[0];
  113 +
  114 + for (int i = 1; i < word.Length; i++)
  115 + {
  116 + if ((word[i] >= 65 && word[i] <= 90) || (word[i] >= 48 && word[i] <= 57))
  117 + subtitle += "-";
  118 +
  119 + if (i == index || (last == index && word[i] == word[last]))
  120 + {
  121 + subtitle += "<b><color=white>" + word[i] + "</color></b>";
  122 + if (i == index) last = i;
  123 + }
  124 + else
  125 + {
  126 + subtitle += word[i];
  127 + last = i;
  128 + }
  129 + }
  130 +
  131 + return subtitle;
  132 + }
  133 +
  134 +}
0 \ No newline at end of file 135 \ No newline at end of file
Assets/Scripts/Subtitle.cs.meta 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +fileFormatVersion: 2
  2 +guid: f97b63181c1ec5f488126f3f9fd68141
  3 +timeCreated: 1452687065
  4 +licenseType: Pro
  5 +MonoImporter:
  6 + serializedVersion: 2
  7 + defaultReferences: []
  8 + executionOrder: 0
  9 + icon: {instanceID: 0}
  10 + userData:
  11 + assetBundleName:
  12 + assetBundleVariant: