Commit e28e59802bdf72e91410247332090c61ba574197
1 parent
8d8b5f09
Exists in
master
and in
1 other branch
Organização das classes concluída.
Showing
58 changed files
with
1415 additions
and
1335 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,137 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using UnityEngine.UI; | |
| 3 | +using UnityEngine.EventSystems; | |
| 4 | +using System.IO; | |
| 5 | +using System.Collections; | |
| 6 | +using System.Collections.Generic; | |
| 7 | + | |
| 8 | +// https://unity3d.com/pt/learn/tutorials/modules/beginner/live-training-archive/creating-scroll-lists-at-run-time | |
| 9 | + | |
| 10 | +[System.Serializable] | |
| 11 | +public class ItemData { | |
| 12 | + | |
| 13 | + public string animationName; | |
| 14 | + public Button.ButtonClickedEvent thingToDo; | |
| 15 | + | |
| 16 | +} | |
| 17 | + | |
| 18 | +public class ListManager : MonoBehaviour { | |
| 19 | + | |
| 20 | + public GameObject sampleItemObject; | |
| 21 | + public GameObject sampleLoadingItemObject; | |
| 22 | + | |
| 23 | + public string[] itemList; | |
| 24 | + private int index = 0; | |
| 25 | + private const int OFFSET = 20; | |
| 26 | + private int size = 0; | |
| 27 | + | |
| 28 | + public GameObject listBlock; | |
| 29 | + public GameObject bar; | |
| 30 | + | |
| 31 | + public Transform contentPanel; | |
| 32 | + public ScrollRect scrollView; | |
| 33 | + public InputField input; | |
| 34 | + | |
| 35 | + private bool isLoading = false; | |
| 36 | + private GameObject loadingItem; | |
| 37 | + | |
| 38 | + TrieST<string> trie; | |
| 39 | + | |
| 40 | + void Start() | |
| 41 | + { | |
| 42 | + this.scrollView.onValueChanged.AddListener(checkScrollPosition); | |
| 43 | + this.input.onValueChange.AddListener(inputChanged); | |
| 44 | + | |
| 45 | + // Load TrieST | |
| 46 | + { | |
| 47 | + this.trie = new TrieST<string>(); | |
| 48 | + | |
| 49 | + StreamReader s = new StreamReader(Application.dataPath + "/sinais.txt"); | |
| 50 | + | |
| 51 | + if (!s.EndOfStream) s.ReadLine(); | |
| 52 | + | |
| 53 | + while (!s.EndOfStream) | |
| 54 | + { | |
| 55 | + string temp = s.ReadLine(); | |
| 56 | + this.trie.put(temp, temp); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + this.itemList = getNamesByPrefix(""); | |
| 61 | + this.index = 0; | |
| 62 | + this.size = itemList.Length; | |
| 63 | + | |
| 64 | + this.loadingItem = Instantiate (sampleLoadingItemObject) as GameObject; | |
| 65 | + | |
| 66 | + StartCoroutine("populateList"); | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void checkScrollPosition(Vector2 scrollPosition) | |
| 70 | + { | |
| 71 | + if (scrollPosition.y <= 0F && ! this.isLoading) | |
| 72 | + StartCoroutine("populateList"); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void inputChanged(string text) | |
| 76 | + { | |
| 77 | + this.itemList = getNamesByPrefix(text.ToUpper()); | |
| 78 | + this.index = 0; | |
| 79 | + this.size = itemList.Length; | |
| 80 | + | |
| 81 | + this.contentPanel.DetachChildren(); | |
| 82 | + foreach(GameObject go in GameObject.FindGameObjectsWithTag("clone")) | |
| 83 | + Destroy(go); | |
| 84 | + | |
| 85 | + StartCoroutine("populateList"); | |
| 86 | + } | |
| 87 | + | |
| 88 | + private IEnumerator populateList() | |
| 89 | + { | |
| 90 | + changeLoadingState(true); | |
| 91 | + yield return new WaitForSeconds(0); | |
| 92 | + | |
| 93 | + int last = this.index + OFFSET; | |
| 94 | + if (last > size) last = this.size; | |
| 95 | + | |
| 96 | + for (int i = index; i < last; i++) | |
| 97 | + { | |
| 98 | + string item = itemList[i]; | |
| 99 | + | |
| 100 | + GameObject newButton = Instantiate (sampleItemObject) as GameObject; | |
| 101 | + SampleItem sampleItem = newButton.GetComponent<SampleItem>(); | |
| 102 | + sampleItem.title.text = item; | |
| 103 | + | |
| 104 | + sampleItem.GetComponent<Button>().onClick.AddListener( | |
| 105 | + delegate { | |
| 106 | + listBlock.SetActive(false); | |
| 107 | + bar.SetActive(true); | |
| 108 | + } | |
| 109 | + ); | |
| 110 | + | |
| 111 | + newButton.transform.SetParent(contentPanel); | |
| 112 | + //newButton.transform.SetAsFirstSibling(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + this.index = last; | |
| 116 | + | |
| 117 | + changeLoadingState(false); | |
| 118 | + } | |
| 119 | + | |
| 120 | + private string[] getNamesByPrefix(string prefix) | |
| 121 | + { | |
| 122 | + Queue<string> names = this.trie.keysWithPrefix(prefix); | |
| 123 | + return names.ToArray(); | |
| 124 | + } | |
| 125 | + | |
| 126 | + private void changeLoadingState(bool active) | |
| 127 | + { | |
| 128 | + Debug.Log(active ? "Loading..." : "Done"); | |
| 129 | + | |
| 130 | + if (isLoading != active) | |
| 131 | + { | |
| 132 | + this.loadingItem.transform.SetParent(active ? contentPanel : null); | |
| 133 | + this.isLoading = active; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 37eb385702c4b324ab15b3636b2ab32f | |
| 3 | +timeCreated: 1448643925 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using UnityEngine.UI; | |
| 3 | +using System.Collections; | |
| 4 | + | |
| 5 | +public class SampleItem : MonoBehaviour { | |
| 6 | + | |
| 7 | + public Button button; | |
| 8 | + public Text title; | |
| 9 | + | |
| 10 | + public void StartAnimation() | |
| 11 | + { | |
| 12 | + GameObject.FindGameObjectWithTag("inspetor").GetComponent<PlayerManager>().start_local_play(title.text); | |
| 13 | + } | |
| 14 | + | |
| 15 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 95cb85318477935499bf0284a82a5fe3 | |
| 3 | +timeCreated: 1448644758 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,96 @@ |
| 1 | +using System.Collections.Generic; | |
| 2 | +using System; | |
| 3 | +using System.Text; | |
| 4 | +using UnityEngine; | |
| 5 | + | |
| 6 | +public class TrieST<Value> | |
| 7 | +{ | |
| 8 | + private static int R = 42; | |
| 9 | + private static char[] chars = { | |
| 10 | + ' ', '-', '(', ')', ',', '%', | |
| 11 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', | |
| 12 | + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', | |
| 13 | + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | |
| 14 | + 'Y', 'Z', | |
| 15 | + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' | |
| 16 | + }; | |
| 17 | + private static int[] indexes = new int[256]; | |
| 18 | + | |
| 19 | + private Node root; | |
| 20 | + private int N; | |
| 21 | + | |
| 22 | + private class Node | |
| 23 | + { | |
| 24 | + public String val; | |
| 25 | + public Node[] next = new Node[R]; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public TrieST() | |
| 29 | + { | |
| 30 | + for (int i = 0; i < R; i++) | |
| 31 | + indexes[chars[i]] = i; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public String get(String key) | |
| 35 | + { | |
| 36 | + Node x = get(root, key, 0); | |
| 37 | + if (x == null) return null; | |
| 38 | + return x.val; | |
| 39 | + } | |
| 40 | + | |
| 41 | + private Node get(Node x, String key, int d) | |
| 42 | + { | |
| 43 | + if (x == null) return null; | |
| 44 | + if (d == key.Length) return x; | |
| 45 | + int c = indexes[key[d]]; | |
| 46 | + return get(x.next[c], key, d + 1); | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void put(String key, String val) | |
| 50 | + { | |
| 51 | + root = put(root, key, val, 0); | |
| 52 | + } | |
| 53 | + | |
| 54 | + private Node put(Node x, String key, String val, int d) | |
| 55 | + { | |
| 56 | + | |
| 57 | + if (x == null) x = new Node(); | |
| 58 | + if (d == key.Length) | |
| 59 | + { | |
| 60 | + if (x.val == null) N++; | |
| 61 | + x.val = val; | |
| 62 | + return x; | |
| 63 | + } | |
| 64 | + int c = indexes[key[d]]; | |
| 65 | + x.next[c] = put(x.next[c], key, val, d + 1); | |
| 66 | + return x; | |
| 67 | + | |
| 68 | + } | |
| 69 | + | |
| 70 | + public Queue<String> keys() | |
| 71 | + { return keysWithPrefix(""); } | |
| 72 | + | |
| 73 | + public Queue<String> keysWithPrefix(String prefix) | |
| 74 | + { | |
| 75 | + Queue<String> results = new Queue<String>(); | |
| 76 | + Node x = get(root, prefix, 0); //ref para o primeiro nó que contem a palavra prefix | |
| 77 | + collect(x, new StringBuilder(prefix), results); | |
| 78 | + return results; | |
| 79 | + } | |
| 80 | + | |
| 81 | + private void collect(Node x, StringBuilder prefix, Queue<String> results) | |
| 82 | + { | |
| 83 | + if (x == null) return; | |
| 84 | + if (x.val != null) results.Enqueue(prefix.ToString()); | |
| 85 | + | |
| 86 | + for (char c = (char)0; c < R; c++) | |
| 87 | + { | |
| 88 | + prefix.Append(chars[c]); | |
| 89 | + | |
| 90 | + collect(x.next[c], prefix, results); | |
| 91 | + prefix.Remove(prefix.Length - 1, 1); | |
| 92 | + } | |
| 93 | + | |
| 94 | + } | |
| 95 | + | |
| 96 | +} | |
| 0 | 97 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: c688e56f6c765894981cb20a40f10a9b | |
| 3 | +timeCreated: 1448926009 | |
| 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/AnimationReference.cs
| ... | ... | @@ -1,19 +0,0 @@ |
| 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 | -} | |
| 20 | 0 | \ No newline at end of file |
Assets/Scripts/AnimationReference.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 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
| ... | ... | @@ -1,63 +0,0 @@ |
| 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 | -} | |
| 64 | 0 | \ No newline at end of file |
Assets/Scripts/DefaultSignSpeed.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 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/FadeFX.cs
| ... | ... | @@ -1,62 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using System.Collections; | |
| 3 | -using UnityEngine.EventSystems; | |
| 4 | -using UnityEngine.UI; | |
| 5 | - | |
| 6 | -public class FadeFX : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { | |
| 7 | - | |
| 8 | - private BoxCollider COMPONENT_COLLIDER; | |
| 9 | - public GameObject update_box; | |
| 10 | - //Cria referência para o colider do avatar e torna a barra transparente | |
| 11 | - public void Start() | |
| 12 | - { | |
| 13 | - | |
| 14 | - COMPONENT_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); | |
| 15 | - Deactivate(); | |
| 16 | - | |
| 17 | - } | |
| 18 | - | |
| 19 | - //Listeners de eventos do mouse | |
| 20 | - public void OnPointerEnter(PointerEventData eventData){ Activate(); } | |
| 21 | - public void OnPointerExit(PointerEventData eventData){ Deactivate(); } | |
| 22 | - | |
| 23 | - /* | |
| 24 | - * Desabilita o colider do avatar para bloquear a rotação | |
| 25 | - * Em seguida retorna o visual padrão da barra de controles | |
| 26 | - * e reativa a interação com os botões | |
| 27 | - */ | |
| 28 | - private void Activate() | |
| 29 | - { | |
| 30 | - | |
| 31 | - COMPONENT_COLLIDER.enabled = false; | |
| 32 | - | |
| 33 | - foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED")) | |
| 34 | - GO.GetComponent<CanvasRenderer>().SetAlpha(1f); | |
| 35 | - | |
| 36 | - foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS")) | |
| 37 | - GO.GetComponent<Button>().interactable = true; | |
| 38 | - | |
| 39 | - } | |
| 40 | - | |
| 41 | - /* | |
| 42 | - * Habilita o colider do avatar para desbloquear a rotação | |
| 43 | - * Em seguida diminui o alpha dos componentes da barra de controles tornando-os transparentes | |
| 44 | - * Logo após desativa a interação com os botões para impedir que fiquem em status "highlighted" | |
| 45 | - */ | |
| 46 | - private void Deactivate(){ | |
| 47 | - | |
| 48 | - if(!SwitchResolution.showbox && !update_box.activeSelf){ | |
| 49 | - | |
| 50 | - COMPONENT_COLLIDER.enabled = true; | |
| 51 | - | |
| 52 | - foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED")) | |
| 53 | - GO.GetComponent<CanvasRenderer>().SetAlpha(.2f); | |
| 54 | - | |
| 55 | - foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS")) | |
| 56 | - GO.GetComponent<Button>().interactable = false; | |
| 57 | - | |
| 58 | - } | |
| 59 | - | |
| 60 | - } | |
| 61 | - | |
| 62 | -} |
Assets/Scripts/FadeFX.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 5cb0d8c33c1f9274083939fe0b6fdc86 | |
| 3 | -timeCreated: 1442001277 | |
| 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
| ... | ... | @@ -1,541 +0,0 @@ |
| 1 | -//Log Dir http://docs.unity3d.com/Manual/LogFiles.html | |
| 2 | -using UnityEngine; | |
| 3 | -using System.Collections; | |
| 4 | -using System.Collections.Generic; | |
| 5 | -using System; | |
| 6 | -using System.IO; | |
| 7 | -using System.Text; | |
| 8 | -using System.Runtime.InteropServices; | |
| 9 | -using System.Diagnostics; | |
| 10 | -using UnityEngine.UI; | |
| 11 | - | |
| 12 | -public abstract class GenericPlayerManager : MonoBehaviour { | |
| 13 | - | |
| 14 | - private const string DEFAULT_ANIMATION = "_default"; | |
| 15 | - private const string NONE_ANIMATION = "_defaultWORD"; | |
| 16 | - | |
| 17 | - protected float fadeLength = 0.6F; | |
| 18 | - | |
| 19 | - protected string glosa = ""; | |
| 20 | - private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa | |
| 21 | - | |
| 22 | - private GameObject AVATAR; | |
| 23 | - private Animation COMPONENT_ANIMATION; | |
| 24 | - private BoxCollider AVATAR_COLLIDER; | |
| 25 | - public Text SUBTITLES; | |
| 26 | - | |
| 27 | - // Guarda os nomes das palavras ja carregadas. | |
| 28 | - private HashSet<string> loadedAssetBundles = new HashSet<string>(); | |
| 29 | - // Guarda os nomes das palavras que nao tem assetbundle. | |
| 30 | - private HashSet<string> nonexistentAssetBundles = new HashSet<string>(); | |
| 31 | - | |
| 32 | - // Lista de animações sendo reproduzidas. | |
| 33 | - // Utilizada para alterar velocidade e apresentar a legenda. | |
| 34 | - private volatile Queue<AnimationReference> animQueue = new Queue<AnimationReference>(); | |
| 35 | - | |
| 36 | - private volatile bool loadingSingleAnimation = false; | |
| 37 | - private volatile bool loading = false; | |
| 38 | - private volatile bool playing = false; | |
| 39 | - private volatile bool paused = false; | |
| 40 | - | |
| 41 | - private Stopwatch watch = new Stopwatch(); | |
| 42 | - private string lastRandom = ""; | |
| 43 | - private int repeated = 0; | |
| 44 | - | |
| 45 | - private Subtitle subtitle; | |
| 46 | - | |
| 47 | - public virtual void Start() | |
| 48 | - { | |
| 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); | |
| 54 | - | |
| 55 | - AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar | |
| 56 | - COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar | |
| 57 | - AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); | |
| 58 | - | |
| 59 | - watch.Start(); | |
| 60 | - Invoke("playRandomAnimation", 5); | |
| 61 | - } | |
| 62 | - | |
| 63 | - public bool isLoadingSingleAnimation() { return loadingSingleAnimation; } | |
| 64 | - public bool isLoading() { return loading; } | |
| 65 | - public bool isPlaying() { return playing; } | |
| 66 | - public bool isPaused() { return paused; } | |
| 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 | - | |
| 108 | - public void SetAvatarCollider(bool isActive) | |
| 109 | - { | |
| 110 | - AVATAR_COLLIDER.enabled = isActive; | |
| 111 | - } | |
| 112 | - | |
| 113 | - protected virtual void setSubtitle(string text) | |
| 114 | - { | |
| 115 | - SUBTITLES.text = text; | |
| 116 | - } | |
| 117 | - | |
| 118 | - // Define a velocidade das animacões com base no slider da GUI | |
| 119 | - public void setSlider(float sliderPosition) | |
| 120 | - { | |
| 121 | - subtitle.SliderPosition = sliderPosition; | |
| 122 | - subtitle.updateWordSpeed(); | |
| 123 | - subtitle.updateLetterSpeed(); | |
| 124 | - subtitle.updateNumberSpeed(); | |
| 125 | - | |
| 126 | - if ( ! paused) | |
| 127 | - foreach (AnimationReference reference in animQueue) | |
| 128 | - if (reference.type != Subtitle.TYPE_NONE && reference.state != null) | |
| 129 | - reference.state.speed = getSpeedByType(reference.type); | |
| 130 | - } | |
| 131 | - | |
| 132 | - private float getSpeedByType(short type) | |
| 133 | - { | |
| 134 | - switch (type) | |
| 135 | - { | |
| 136 | - case Subtitle.TYPE_WORD: return subtitle.WordSpeed; | |
| 137 | - case Subtitle.TYPE_LETTER: return subtitle.LetterSpeed; | |
| 138 | - case Subtitle.TYPE_NUMBER: return subtitle.NumberSpeed; | |
| 139 | - } | |
| 140 | - | |
| 141 | - return 2F; | |
| 142 | - } | |
| 143 | - | |
| 144 | - | |
| 145 | - public void stop_animations() | |
| 146 | - { | |
| 147 | - StopCoroutine("loadAndPlay"); | |
| 148 | - loading = false; | |
| 149 | - | |
| 150 | - playing = false; | |
| 151 | - paused = false; | |
| 152 | - onPlayingStateChange(); | |
| 153 | - | |
| 154 | - stopAnimations(); | |
| 155 | - } | |
| 156 | - | |
| 157 | - public void stopAnimations() | |
| 158 | - { | |
| 159 | - try { | |
| 160 | - StopCoroutine("handleStates"); | |
| 161 | - } catch (NullReferenceException nre) { UnityEngine.Debug.Log("StopCoroutine handlestates nullreff::"+nre.ToString()); } | |
| 162 | - | |
| 163 | - setSubtitle(""); | |
| 164 | - | |
| 165 | - try { | |
| 166 | - animQueue.Clear(); | |
| 167 | - } catch (NullReferenceException nre) { UnityEngine.Debug.Log("SetQueueList null reff::"+nre.ToString()); } | |
| 168 | - | |
| 169 | - COMPONENT_ANIMATION.Stop(); | |
| 170 | - COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll); | |
| 171 | - } | |
| 172 | - | |
| 173 | - /* | |
| 174 | - * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. | |
| 175 | - */ | |
| 176 | - private AnimationState playAnimation(short type, string name, string subtitle, float speed) | |
| 177 | - { | |
| 178 | - try | |
| 179 | - { | |
| 180 | - AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, fadeLength, QueueMode.CompleteOthers); | |
| 181 | - state.speed = speed; | |
| 182 | - animQueue.Enqueue(new AnimationReference(name, subtitle, state, type)); | |
| 183 | - | |
| 184 | - return state; | |
| 185 | - } | |
| 186 | - catch (NullReferenceException nre) | |
| 187 | - { | |
| 188 | - UnityEngine.Debug.Log("'" + name + "' não foi encontrado!\n" + nre.ToString()); | |
| 189 | - } | |
| 190 | - | |
| 191 | - return null; | |
| 192 | - } | |
| 193 | - private AnimationState playAnimation(short type, string name, string subtitle) { | |
| 194 | - return playAnimation(type, name, subtitle, getSpeedByType(type)); | |
| 195 | - } | |
| 196 | - private AnimationState playAnimation(short type, string name) { | |
| 197 | - return playAnimation(type, name, name); | |
| 198 | - } | |
| 199 | - | |
| 200 | - | |
| 201 | - /** | |
| 202 | - * Returns the asset bundle named aniName. | |
| 203 | - * | |
| 204 | - * @return AssetBundle - se for encontrado. | |
| 205 | - * null - se ocorrer num erro. | |
| 206 | - */ | |
| 207 | - protected abstract WWW loadAssetBundle(string aniName); | |
| 208 | - | |
| 209 | - | |
| 210 | - /** | |
| 211 | - * Listen to changes in the playing status. | |
| 212 | - */ | |
| 213 | - protected abstract void onPlayingStateChange(); | |
| 214 | - | |
| 215 | - | |
| 216 | - public void switchPauseState(bool paused) | |
| 217 | - { | |
| 218 | - if (this.paused != paused) | |
| 219 | - { | |
| 220 | - this.paused = paused; | |
| 221 | - | |
| 222 | - foreach (AnimationReference reference in animQueue) | |
| 223 | - if (reference.state != null) | |
| 224 | - reference.state.speed = paused ? 0F : getSpeedByType(reference.type); | |
| 225 | - | |
| 226 | - onPlayingStateChange(); | |
| 227 | - } | |
| 228 | - } | |
| 229 | - public void switchPauseState() | |
| 230 | - { | |
| 231 | - switchPauseState( ! paused); | |
| 232 | - } | |
| 233 | - | |
| 234 | - public bool play() | |
| 235 | - { | |
| 236 | - if (playing) | |
| 237 | - switchPauseState(); | |
| 238 | - else | |
| 239 | - play(true, true, true); | |
| 240 | - | |
| 241 | - return true; | |
| 242 | - } | |
| 243 | - | |
| 244 | - public bool play(bool stopLoading, bool stopPlaying, bool forceLoading) | |
| 245 | - { | |
| 246 | - try { | |
| 247 | - if (loading) | |
| 248 | - { | |
| 249 | - if (stopLoading) | |
| 250 | - stop_animations(); | |
| 251 | - else | |
| 252 | - return false; | |
| 253 | - } | |
| 254 | - else if (playing) | |
| 255 | - { | |
| 256 | - if (stopPlaying) | |
| 257 | - stopAnimations(); | |
| 258 | - | |
| 259 | - else if ( ! forceLoading) | |
| 260 | - return false; | |
| 261 | - } | |
| 262 | - } catch (NullReferenceException nre) { nre.ToString(); } | |
| 263 | - | |
| 264 | - StartCoroutine("loadAndPlay"); | |
| 265 | - return true; | |
| 266 | - } | |
| 267 | - | |
| 268 | - /** | |
| 269 | - * Spells word. | |
| 270 | - * | |
| 271 | - * @return last animation's subtitle. | |
| 272 | - */ | |
| 273 | - private string spellWord(string word) | |
| 274 | - { | |
| 275 | - string lastAnimationSubtitle = ""; | |
| 276 | - bool defaultPlayed = false; | |
| 277 | - | |
| 278 | - // A reprodução da primeira letra deve ser longa para não ser cortada no fade | |
| 279 | - subtitle.updateLetterSpeed(); | |
| 280 | - | |
| 281 | - for (int i = 0; i < word.Length; i++) | |
| 282 | - { | |
| 283 | - char second = word[i]; | |
| 284 | - lastAnimationSubtitle = Subtitle.highlight(word, i); | |
| 285 | - | |
| 286 | - // Se for uma letra | |
| 287 | - if (second >= 65 && second <= 90) | |
| 288 | - playAnimation(Subtitle.TYPE_LETTER, second.ToString(), lastAnimationSubtitle, subtitle.LetterSpeed); | |
| 289 | - | |
| 290 | - // Se for um número | |
| 291 | - else if (second >= 48 && second <= 57) | |
| 292 | - playAnimation(Subtitle.TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, subtitle.NumberSpeed); | |
| 293 | - | |
| 294 | - // Se for uma vírgula | |
| 295 | - else if (second == 44) | |
| 296 | - playAnimation(Subtitle.TYPE_WORD, second.ToString(), lastAnimationSubtitle); | |
| 297 | - | |
| 298 | - // Não há animação | |
| 299 | - else | |
| 300 | - { | |
| 301 | - // Reproduz animação default apenas uma vez | |
| 302 | - if ( ! defaultPlayed) | |
| 303 | - { | |
| 304 | - defaultPlayed = true; | |
| 305 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | |
| 306 | - | |
| 307 | - // A reprodução da próxima letra deve ser longa para não ser cortada no fade | |
| 308 | - subtitle.updateLetterSpeed(); | |
| 309 | - } | |
| 310 | - | |
| 311 | - UnityEngine.Debug.Log("Animação \"" + second + "\" inexistente."); | |
| 312 | - continue; | |
| 313 | - } | |
| 314 | - | |
| 315 | - defaultPlayed = false; | |
| 316 | - subtitle.updateLetterSpeed(); | |
| 317 | - } | |
| 318 | - | |
| 319 | - return lastAnimationSubtitle; | |
| 320 | - } | |
| 321 | - | |
| 322 | - | |
| 323 | - protected IEnumerator loadAnimation(string name) | |
| 324 | - { | |
| 325 | - loadingSingleAnimation = true; | |
| 326 | - | |
| 327 | - // Função loadAssetBundle é definida pela classe filha | |
| 328 | - WWW www = loadAssetBundle(name); | |
| 329 | - | |
| 330 | - if (www != null) | |
| 331 | - { | |
| 332 | - yield return www; | |
| 333 | - | |
| 334 | - AssetBundle bundle = null; | |
| 335 | - | |
| 336 | - if (www.error == null) | |
| 337 | - bundle = www.assetBundle; | |
| 338 | - | |
| 339 | - if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) | |
| 340 | - { | |
| 341 | - AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
| 342 | - bundle.Unload(false); | |
| 343 | - | |
| 344 | - if (aniClip) | |
| 345 | - { | |
| 346 | - COMPONENT_ANIMATION.AddClip(aniClip, name); | |
| 347 | - | |
| 348 | - // Reproduz palavra | |
| 349 | - loadedAssetBundles.Add(name); | |
| 350 | - yield break; | |
| 351 | - } | |
| 352 | - else UnityEngine.Debug.Log ("Sinal \"" + name + "\" não carregado corretamente."); | |
| 353 | - } | |
| 354 | - } | |
| 355 | - | |
| 356 | - // Soletra palavra | |
| 357 | - nonexistentAssetBundles.Add(name); | |
| 358 | - | |
| 359 | - loadingSingleAnimation = false; | |
| 360 | - } | |
| 361 | - | |
| 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 | - | |
| 373 | - private IEnumerator loadAndPlay() | |
| 374 | - { | |
| 375 | - loading = true; | |
| 376 | - onPlayingStateChange(); | |
| 377 | - | |
| 378 | - string lastAnimationSubtitle = ""; | |
| 379 | - bool spelled = false; | |
| 380 | - | |
| 381 | - // Default | |
| 382 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 2F); | |
| 383 | - | |
| 384 | - if ( ! playing) | |
| 385 | - { | |
| 386 | - playing = true; | |
| 387 | - StartCoroutine("handleStates"); | |
| 388 | - } | |
| 389 | - | |
| 390 | - stringPos = glosa.Split(' '); | |
| 391 | - | |
| 392 | - foreach (string aniName in stringPos) | |
| 393 | - { | |
| 394 | - try { | |
| 395 | - if (String.IsNullOrEmpty(aniName)) continue; | |
| 396 | - } catch (Exception e) { | |
| 397 | - UnityEngine.Debug.Log(e + " :: NotNullNotEmpty"); | |
| 398 | - } | |
| 399 | - | |
| 400 | - bool nonexistent = nonexistentAssetBundles.Contains(aniName); | |
| 401 | - bool loaded = loadedAssetBundles.Contains(aniName); | |
| 402 | - | |
| 403 | - if ( ! nonexistent && ! loaded) | |
| 404 | - { | |
| 405 | - // Função loadAssetBundle é definida pela classe filha | |
| 406 | - WWW www = loadAssetBundle(aniName); | |
| 407 | - | |
| 408 | - if (www != null) | |
| 409 | - { | |
| 410 | - yield return www; | |
| 411 | - | |
| 412 | - AssetBundle bundle = null; | |
| 413 | - | |
| 414 | - if (www.error == null) | |
| 415 | - bundle = www.assetBundle; | |
| 416 | - | |
| 417 | - if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) | |
| 418 | - { | |
| 419 | - AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
| 420 | - bundle.Unload(false); | |
| 421 | - | |
| 422 | - if (aniClip) | |
| 423 | - { | |
| 424 | - COMPONENT_ANIMATION.AddClip(aniClip, aniName); | |
| 425 | - | |
| 426 | - loadedAssetBundles.Add(aniName); | |
| 427 | - loaded = true; | |
| 428 | - } | |
| 429 | - else UnityEngine.Debug.Log ("Sinal \"" + aniName + "\" não carregado corretamente."); | |
| 430 | - } | |
| 431 | - } | |
| 432 | - } | |
| 433 | - | |
| 434 | - // Reproduz palavra | |
| 435 | - if (loaded) | |
| 436 | - { | |
| 437 | - if (spelled) | |
| 438 | - { | |
| 439 | - // Default | |
| 440 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | |
| 441 | - spelled = false; | |
| 442 | - } | |
| 443 | - | |
| 444 | - //bool isFlag = false; | |
| 445 | - | |
| 446 | - //if (aniName[0] == '[') | |
| 447 | - //{ | |
| 448 | - if (isFlag(aniName)) | |
| 449 | - { | |
| 450 | - //isFlag = true; | |
| 451 | - lastAnimationSubtitle = ""; | |
| 452 | - playAnimation(Subtitle.TYPE_WORD, aniName, ""); | |
| 453 | - } | |
| 454 | - else | |
| 455 | - { | |
| 456 | - lastAnimationSubtitle = aniName; | |
| 457 | - playAnimation(Subtitle.TYPE_WORD, aniName); | |
| 458 | - } | |
| 459 | - //} | |
| 460 | - | |
| 461 | - /*if (isFlag) | |
| 462 | - playAnimation(Subtitle.TYPE_WORD, aniName, ""); | |
| 463 | - else | |
| 464 | - playAnimation(Subtitle.TYPE_WORD, aniName);*/ | |
| 465 | - } | |
| 466 | - // Soletra palavra | |
| 467 | - else | |
| 468 | - { | |
| 469 | - // Se a animação não foi carregada e nem está marcada como não existente, | |
| 470 | - // adiciona ao set de animações não existentes | |
| 471 | - if ( ! nonexistent) | |
| 472 | - nonexistentAssetBundles.Add(aniName); | |
| 473 | - | |
| 474 | - UnityEngine.Debug.Log("~~ To spell: " + aniName); | |
| 475 | - | |
| 476 | - if (isFlag(aniName)) | |
| 477 | - { | |
| 478 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); | |
| 479 | - continue; | |
| 480 | - } | |
| 481 | - | |
| 482 | - // Se já houve o soletramento de alguma palavra, reproduz animação default | |
| 483 | - if (spelled) | |
| 484 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); | |
| 485 | - else | |
| 486 | - spelled = true; | |
| 487 | - | |
| 488 | - lastAnimationSubtitle = spellWord(aniName); | |
| 489 | - } | |
| 490 | - } | |
| 491 | - | |
| 492 | - // Default | |
| 493 | - playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, ""); | |
| 494 | - | |
| 495 | - loading = false; | |
| 496 | - onPlayingStateChange(); | |
| 497 | - } | |
| 498 | - | |
| 499 | - //int _id = 0; | |
| 500 | - | |
| 501 | - /* | |
| 502 | - * Sincroniza as legendas com as animações. | |
| 503 | - */ | |
| 504 | - IEnumerator handleStates() | |
| 505 | - { | |
| 506 | - stopWatch(); | |
| 507 | - | |
| 508 | - // Enquanto estiver executando a rotina "loadAndPlay" | |
| 509 | - // ou existir animações na fila de reprodução | |
| 510 | - while (loading || animQueue.Count > 0) | |
| 511 | - { | |
| 512 | - if (animQueue.Count > 0) | |
| 513 | - { | |
| 514 | - AnimationReference reference = animQueue.Peek(); | |
| 515 | - | |
| 516 | - setSubtitle(reference.subtitle); | |
| 517 | - | |
| 518 | - while (COMPONENT_ANIMATION.IsPlaying(reference.name)) | |
| 519 | - { | |
| 520 | - reference.playing = true; | |
| 521 | - yield return null; | |
| 522 | - } | |
| 523 | - | |
| 524 | - if (reference.state == null) | |
| 525 | - animQueue.Dequeue(); | |
| 526 | - else | |
| 527 | - yield return null; | |
| 528 | - } | |
| 529 | - else yield return null; | |
| 530 | - | |
| 531 | - setSubtitle(""); | |
| 532 | - } | |
| 533 | - | |
| 534 | - playing = false; | |
| 535 | - paused = false; | |
| 536 | - onPlayingStateChange(); | |
| 537 | - | |
| 538 | - continueWatch(); | |
| 539 | - } | |
| 540 | - | |
| 541 | -} |
Assets/Scripts/GenericPlayerManager.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 953c1d9124325ab4099d246d3cbfb780 | |
| 3 | -timeCreated: 1440187017 | |
| 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/ListManager.cs
| ... | ... | @@ -1,137 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using UnityEngine.UI; | |
| 3 | -using UnityEngine.EventSystems; | |
| 4 | -using System.IO; | |
| 5 | -using System.Collections; | |
| 6 | -using System.Collections.Generic; | |
| 7 | - | |
| 8 | -// https://unity3d.com/pt/learn/tutorials/modules/beginner/live-training-archive/creating-scroll-lists-at-run-time | |
| 9 | - | |
| 10 | -[System.Serializable] | |
| 11 | -public class ItemData { | |
| 12 | - | |
| 13 | - public string animationName; | |
| 14 | - public Button.ButtonClickedEvent thingToDo; | |
| 15 | - | |
| 16 | -} | |
| 17 | - | |
| 18 | -public class ListManager : MonoBehaviour { | |
| 19 | - | |
| 20 | - public GameObject sampleItemObject; | |
| 21 | - public GameObject sampleLoadingItemObject; | |
| 22 | - | |
| 23 | - public string[] itemList; | |
| 24 | - private int index = 0; | |
| 25 | - private const int OFFSET = 20; | |
| 26 | - private int size = 0; | |
| 27 | - | |
| 28 | - public GameObject listBlock; | |
| 29 | - public GameObject bar; | |
| 30 | - | |
| 31 | - public Transform contentPanel; | |
| 32 | - public ScrollRect scrollView; | |
| 33 | - public InputField input; | |
| 34 | - | |
| 35 | - private bool isLoading = false; | |
| 36 | - private GameObject loadingItem; | |
| 37 | - | |
| 38 | - TrieST<string> trie; | |
| 39 | - | |
| 40 | - void Start() | |
| 41 | - { | |
| 42 | - this.scrollView.onValueChanged.AddListener(checkScrollPosition); | |
| 43 | - this.input.onValueChange.AddListener(inputChanged); | |
| 44 | - | |
| 45 | - // Load TrieST | |
| 46 | - { | |
| 47 | - this.trie = new TrieST<string>(); | |
| 48 | - | |
| 49 | - StreamReader s = new StreamReader(Application.dataPath + "/sinais.txt"); | |
| 50 | - | |
| 51 | - if (!s.EndOfStream) s.ReadLine(); | |
| 52 | - | |
| 53 | - while (!s.EndOfStream) | |
| 54 | - { | |
| 55 | - string temp = s.ReadLine(); | |
| 56 | - this.trie.put(temp, temp); | |
| 57 | - } | |
| 58 | - } | |
| 59 | - | |
| 60 | - this.itemList = getNamesByPrefix(""); | |
| 61 | - this.index = 0; | |
| 62 | - this.size = itemList.Length; | |
| 63 | - | |
| 64 | - this.loadingItem = Instantiate (sampleLoadingItemObject) as GameObject; | |
| 65 | - | |
| 66 | - StartCoroutine("populateList"); | |
| 67 | - } | |
| 68 | - | |
| 69 | - public void checkScrollPosition(Vector2 scrollPosition) | |
| 70 | - { | |
| 71 | - if (scrollPosition.y <= 0F && ! this.isLoading) | |
| 72 | - StartCoroutine("populateList"); | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void inputChanged(string text) | |
| 76 | - { | |
| 77 | - this.itemList = getNamesByPrefix(text.ToUpper()); | |
| 78 | - this.index = 0; | |
| 79 | - this.size = itemList.Length; | |
| 80 | - | |
| 81 | - this.contentPanel.DetachChildren(); | |
| 82 | - foreach(GameObject go in GameObject.FindGameObjectsWithTag("clone")) | |
| 83 | - Destroy(go); | |
| 84 | - | |
| 85 | - StartCoroutine("populateList"); | |
| 86 | - } | |
| 87 | - | |
| 88 | - private IEnumerator populateList() | |
| 89 | - { | |
| 90 | - changeLoadingState(true); | |
| 91 | - yield return new WaitForSeconds(0); | |
| 92 | - | |
| 93 | - int last = this.index + OFFSET; | |
| 94 | - if (last > size) last = this.size; | |
| 95 | - | |
| 96 | - for (int i = index; i < last; i++) | |
| 97 | - { | |
| 98 | - string item = itemList[i]; | |
| 99 | - | |
| 100 | - GameObject newButton = Instantiate (sampleItemObject) as GameObject; | |
| 101 | - SampleItem sampleItem = newButton.GetComponent<SampleItem>(); | |
| 102 | - sampleItem.title.text = item; | |
| 103 | - | |
| 104 | - sampleItem.GetComponent<Button>().onClick.AddListener( | |
| 105 | - delegate { | |
| 106 | - listBlock.SetActive(false); | |
| 107 | - bar.SetActive(true); | |
| 108 | - } | |
| 109 | - ); | |
| 110 | - | |
| 111 | - newButton.transform.SetParent(contentPanel); | |
| 112 | - //newButton.transform.SetAsFirstSibling(); | |
| 113 | - } | |
| 114 | - | |
| 115 | - this.index = last; | |
| 116 | - | |
| 117 | - changeLoadingState(false); | |
| 118 | - } | |
| 119 | - | |
| 120 | - private string[] getNamesByPrefix(string prefix) | |
| 121 | - { | |
| 122 | - Queue<string> names = this.trie.keysWithPrefix(prefix); | |
| 123 | - return names.ToArray(); | |
| 124 | - } | |
| 125 | - | |
| 126 | - private void changeLoadingState(bool active) | |
| 127 | - { | |
| 128 | - Debug.Log(active ? "Loading..." : "Done"); | |
| 129 | - | |
| 130 | - if (isLoading != active) | |
| 131 | - { | |
| 132 | - this.loadingItem.transform.SetParent(active ? contentPanel : null); | |
| 133 | - this.isLoading = active; | |
| 134 | - } | |
| 135 | - } | |
| 136 | - | |
| 137 | -} |
Assets/Scripts/ListManager.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 37eb385702c4b324ab15b3636b2ab32f | |
| 3 | -timeCreated: 1448643925 | |
| 4 | -licenseType: Pro | |
| 5 | -MonoImporter: | |
| 6 | - serializedVersion: 2 | |
| 7 | - defaultReferences: [] | |
| 8 | - executionOrder: 0 | |
| 9 | - icon: {instanceID: 0} | |
| 10 | - userData: | |
| 11 | - assetBundleName: | |
| 12 | - assetBundleVariant: |
| ... | ... | @@ -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 | 20 | \ No newline at end of file | ... | ... |
Assets/Scripts/Player Manager/AnimationReference.cs.meta
0 → 100644
| ... | ... | @@ -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: | ... | ... |
| ... | ... | @@ -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 | 64 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -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: | ... | ... |
| ... | ... | @@ -0,0 +1,512 @@ |
| 1 | +//Log Dir http://docs.unity3d.com/Manual/LogFiles.html | |
| 2 | +using UnityEngine; | |
| 3 | +using System.Collections; | |
| 4 | +using System.Collections.Generic; | |
| 5 | +using System; | |
| 6 | +using System.IO; | |
| 7 | +using System.Text; | |
| 8 | +using System.Runtime.InteropServices; | |
| 9 | +using UnityEngine.UI; | |
| 10 | + | |
| 11 | +public abstract class GenericPlayerManager : MonoBehaviour { | |
| 12 | + | |
| 13 | + private const string DEFAULT_ANIMATION = "_default"; | |
| 14 | + private const string NONE_ANIMATION = "_defaultWORD"; | |
| 15 | + | |
| 16 | + protected float fadeLength = 0.6F; | |
| 17 | + | |
| 18 | + protected string glosa = ""; | |
| 19 | + private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa | |
| 20 | + | |
| 21 | + private GameObject AVATAR; | |
| 22 | + private Animation COMPONENT_ANIMATION; | |
| 23 | + private BoxCollider AVATAR_COLLIDER; | |
| 24 | + public Text SUBTITLES; | |
| 25 | + | |
| 26 | + // Guarda os nomes das palavras ja carregadas. | |
| 27 | + private HashSet<string> loadedAssetBundles = new HashSet<string>(); | |
| 28 | + // Guarda os nomes das palavras que nao tem assetbundle. | |
| 29 | + private HashSet<string> nonexistentAssetBundles = new HashSet<string>(); | |
| 30 | + | |
| 31 | + // Lista de animações sendo reproduzidas. | |
| 32 | + // Utilizada para alterar velocidade e apresentar a legenda. | |
| 33 | + private volatile Queue<AnimationReference> animQueue = new Queue<AnimationReference>(); | |
| 34 | + | |
| 35 | + private HashSet<string> flags = new HashSet<string>(); | |
| 36 | + | |
| 37 | + private volatile bool loadingSingleAnimation = false; | |
| 38 | + private volatile bool loading = false; | |
| 39 | + private volatile bool playing = false; | |
| 40 | + private volatile bool paused = false; | |
| 41 | + | |
| 42 | + private RandomAnimations randomAnimations = null; | |
| 43 | + private Subtitle subtitle = null; | |
| 44 | + | |
| 45 | + public virtual void Start() | |
| 46 | + { | |
| 47 | + subtitle = new Subtitle(SUBTITLES); | |
| 48 | + subtitle.DefaultWordSpeed = new DefaultSignSpeed(); | |
| 49 | + subtitle.DefaultFirstLetterSpeed = new DefaultSignSpeed(2.1F, 2.8F); | |
| 50 | + subtitle.DefaultLetterSpeed = new DefaultSignSpeed(3F, 4.3F); | |
| 51 | + subtitle.DefaultNumberSpeed = new DefaultSignSpeed(1.5F, 2.9F); | |
| 52 | + | |
| 53 | + AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar | |
| 54 | + COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar | |
| 55 | + AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); | |
| 56 | + | |
| 57 | + this.addFlags(new string[] { | |
| 58 | + "[PONTO]", | |
| 59 | + "[INTERROGACAO]", | |
| 60 | + "[EXCLAMACAO]" | |
| 61 | + }); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public bool isLoadingSingleAnimation() { return loadingSingleAnimation; } | |
| 65 | + public bool isLoading() { return loading; } | |
| 66 | + public bool isPlaying() { return playing; } | |
| 67 | + public bool isPaused() { return paused; } | |
| 68 | + | |
| 69 | + public void addFlags(string[] flags) { | |
| 70 | + foreach (string flag in flags) | |
| 71 | + this.flags.Add(flag); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void playRandomAnimations() { | |
| 75 | + this.randomAnimations.playRandom(); | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void setRandomAnimations(RandomAnimations randomAnimations, string[] flags) { | |
| 79 | + this.randomAnimations = randomAnimations; | |
| 80 | + this.addFlags(flags); | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void SetAvatarCollider(bool isActive) | |
| 84 | + { | |
| 85 | + AVATAR_COLLIDER.enabled = isActive; | |
| 86 | + } | |
| 87 | + | |
| 88 | + protected virtual void setSubtitle(string text) | |
| 89 | + { | |
| 90 | + SUBTITLES.text = text; | |
| 91 | + } | |
| 92 | + | |
| 93 | + // Define a velocidade das animacões com base no slider da GUI | |
| 94 | + public void setSlider(float sliderPosition) | |
| 95 | + { | |
| 96 | + subtitle.SliderPosition = sliderPosition; | |
| 97 | + subtitle.updateWordSpeed(); | |
| 98 | + subtitle.updateLetterSpeed(); | |
| 99 | + subtitle.updateNumberSpeed(); | |
| 100 | + | |
| 101 | + if ( ! paused) | |
| 102 | + foreach (AnimationReference reference in animQueue) | |
| 103 | + if (reference.type != Subtitle.TYPE_NONE && reference.state != null) | |
| 104 | + reference.state.speed = getSpeedByType(reference.type); | |
| 105 | + } | |
| 106 | + | |
| 107 | + private float getSpeedByType(short type) | |
| 108 | + { | |
| 109 | + switch (type) | |
| 110 | + { | |
| 111 | + case Subtitle.TYPE_WORD: return subtitle.WordSpeed; | |
| 112 | + case Subtitle.TYPE_LETTER: return subtitle.LetterSpeed; | |
| 113 | + case Subtitle.TYPE_NUMBER: return subtitle.NumberSpeed; | |
| 114 | + } | |
| 115 | + | |
| 116 | + return 2F; | |
| 117 | + } | |
| 118 | + | |
| 119 | + | |
| 120 | + public void stop_animations() | |
| 121 | + { | |
| 122 | + StopCoroutine("loadAndPlay"); | |
| 123 | + loading = false; | |
| 124 | + | |
| 125 | + playing = false; | |
| 126 | + paused = false; | |
| 127 | + onPlayingStateChange(); | |
| 128 | + | |
| 129 | + stopAnimations(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + public void stopAnimations() | |
| 133 | + { | |
| 134 | + try { | |
| 135 | + StopCoroutine("handleStates"); | |
| 136 | + } catch (NullReferenceException nre) { UnityEngine.Debug.Log("StopCoroutine handlestates nullreff::"+nre.ToString()); } | |
| 137 | + | |
| 138 | + setSubtitle(""); | |
| 139 | + | |
| 140 | + try { | |
| 141 | + animQueue.Clear(); | |
| 142 | + } catch (NullReferenceException nre) { UnityEngine.Debug.Log("SetQueueList null reff::"+nre.ToString()); } | |
| 143 | + | |
| 144 | + COMPONENT_ANIMATION.Stop(); | |
| 145 | + COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll); | |
| 146 | + } | |
| 147 | + | |
| 148 | + /* | |
| 149 | + * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. | |
| 150 | + */ | |
| 151 | + private AnimationState playAnimation(short type, string name, string subtitle, float speed) | |
| 152 | + { | |
| 153 | + try | |
| 154 | + { | |
| 155 | + AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, fadeLength, QueueMode.CompleteOthers); | |
| 156 | + state.speed = speed; | |
| 157 | + animQueue.Enqueue(new AnimationReference(name, subtitle, state, type)); | |
| 158 | + | |
| 159 | + return state; | |
| 160 | + } | |
| 161 | + catch (NullReferenceException nre) | |
| 162 | + { | |
| 163 | + UnityEngine.Debug.Log("'" + name + "' não foi encontrado!\n" + nre.ToString()); | |
| 164 | + } | |
| 165 | + | |
| 166 | + return null; | |
| 167 | + } | |
| 168 | + private AnimationState playAnimation(short type, string name, string subtitle) { | |
| 169 | + return playAnimation(type, name, subtitle, getSpeedByType(type)); | |
| 170 | + } | |
| 171 | + private AnimationState playAnimation(short type, string name) { | |
| 172 | + return playAnimation(type, name, name); | |
| 173 | + } | |
| 174 | + | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Returns the asset bundle named aniName. | |
| 178 | + * | |
| 179 | + * @return AssetBundle - se for encontrado. | |
| 180 | + * null - se ocorrer num erro. | |
| 181 | + */ | |
| 182 | + protected abstract WWW loadAssetBundle(string aniName); | |
| 183 | + | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * Listen to changes in the playing status. | |
| 187 | + */ | |
| 188 | + protected abstract void onPlayingStateChange(); | |
| 189 | + | |
| 190 | + | |
| 191 | + public void switchPauseState(bool paused) | |
| 192 | + { | |
| 193 | + if (this.paused != paused) | |
| 194 | + { | |
| 195 | + this.paused = paused; | |
| 196 | + | |
| 197 | + foreach (AnimationReference reference in animQueue) | |
| 198 | + if (reference.state != null) | |
| 199 | + reference.state.speed = paused ? 0F : getSpeedByType(reference.type); | |
| 200 | + | |
| 201 | + onPlayingStateChange(); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + public void switchPauseState() | |
| 205 | + { | |
| 206 | + switchPauseState( ! paused); | |
| 207 | + } | |
| 208 | + | |
| 209 | + public bool play() | |
| 210 | + { | |
| 211 | + if (playing) | |
| 212 | + switchPauseState(); | |
| 213 | + else | |
| 214 | + play(true, true, true); | |
| 215 | + | |
| 216 | + return true; | |
| 217 | + } | |
| 218 | + | |
| 219 | + public bool play(string glosa) | |
| 220 | + { | |
| 221 | + this.glosa = glosa; | |
| 222 | + return this.play(); | |
| 223 | + } | |
| 224 | + | |
| 225 | + public bool play(bool stopLoading, bool stopPlaying, bool forceLoading) | |
| 226 | + { | |
| 227 | + try { | |
| 228 | + if (loading) | |
| 229 | + { | |
| 230 | + if (stopLoading) | |
| 231 | + stop_animations(); | |
| 232 | + else | |
| 233 | + return false; | |
| 234 | + } | |
| 235 | + else if (playing) | |
| 236 | + { | |
| 237 | + if (stopPlaying) | |
| 238 | + stopAnimations(); | |
| 239 | + | |
| 240 | + else if ( ! forceLoading) | |
| 241 | + return false; | |
| 242 | + } | |
| 243 | + } catch (NullReferenceException nre) { nre.ToString(); } | |
| 244 | + | |
| 245 | + StartCoroutine("loadAndPlay"); | |
| 246 | + return true; | |
| 247 | + } | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * Spells word. | |
| 251 | + * | |
| 252 | + * @return last animation's subtitle. | |
| 253 | + */ | |
| 254 | + private string spellWord(string word) | |
| 255 | + { | |
| 256 | + string lastAnimationSubtitle = ""; | |
| 257 | + bool defaultPlayed = false; | |
| 258 | + | |
| 259 | + // A reprodução da primeira letra deve ser longa para não ser cortada no fade | |
| 260 | + subtitle.updateLetterSpeed(); | |
| 261 | + | |
| 262 | + for (int i = 0; i < word.Length; i++) | |
| 263 | + { | |
| 264 | + char second = word[i]; | |
| 265 | + lastAnimationSubtitle = Subtitle.highlight(word, i); | |
| 266 | + | |
| 267 | + // Se for uma letra | |
| 268 | + if (second >= 65 && second <= 90) | |
| 269 | + playAnimation(Subtitle.TYPE_LETTER, second.ToString(), lastAnimationSubtitle, subtitle.LetterSpeed); | |
| 270 | + | |
| 271 | + // Se for um número | |
| 272 | + else if (second >= 48 && second <= 57) | |
| 273 | + playAnimation(Subtitle.TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, subtitle.NumberSpeed); | |
| 274 | + | |
| 275 | + // Se for uma vírgula | |
| 276 | + else if (second == 44) | |
| 277 | + playAnimation(Subtitle.TYPE_WORD, second.ToString(), lastAnimationSubtitle); | |
| 278 | + | |
| 279 | + // Não há animação | |
| 280 | + else | |
| 281 | + { | |
| 282 | + // Reproduz animação default apenas uma vez | |
| 283 | + if ( ! defaultPlayed) | |
| 284 | + { | |
| 285 | + defaultPlayed = true; | |
| 286 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | |
| 287 | + | |
| 288 | + // A reprodução da próxima letra deve ser longa para não ser cortada no fade | |
| 289 | + subtitle.updateLetterSpeed(); | |
| 290 | + } | |
| 291 | + | |
| 292 | + UnityEngine.Debug.Log("Animação \"" + second + "\" inexistente."); | |
| 293 | + continue; | |
| 294 | + } | |
| 295 | + | |
| 296 | + defaultPlayed = false; | |
| 297 | + subtitle.updateLetterSpeed(); | |
| 298 | + } | |
| 299 | + | |
| 300 | + return lastAnimationSubtitle; | |
| 301 | + } | |
| 302 | + | |
| 303 | + | |
| 304 | + protected IEnumerator loadAnimation(string name) | |
| 305 | + { | |
| 306 | + loadingSingleAnimation = true; | |
| 307 | + | |
| 308 | + // Função loadAssetBundle é definida pela classe filha | |
| 309 | + WWW www = loadAssetBundle(name); | |
| 310 | + | |
| 311 | + if (www != null) | |
| 312 | + { | |
| 313 | + yield return www; | |
| 314 | + | |
| 315 | + AssetBundle bundle = null; | |
| 316 | + | |
| 317 | + if (www.error == null) | |
| 318 | + bundle = www.assetBundle; | |
| 319 | + | |
| 320 | + if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) | |
| 321 | + { | |
| 322 | + AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
| 323 | + bundle.Unload(false); | |
| 324 | + | |
| 325 | + if (aniClip) | |
| 326 | + { | |
| 327 | + COMPONENT_ANIMATION.AddClip(aniClip, name); | |
| 328 | + | |
| 329 | + // Reproduz palavra | |
| 330 | + loadedAssetBundles.Add(name); | |
| 331 | + yield break; | |
| 332 | + } | |
| 333 | + else UnityEngine.Debug.Log ("Sinal \"" + name + "\" não carregado corretamente."); | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + // Soletra palavra | |
| 338 | + nonexistentAssetBundles.Add(name); | |
| 339 | + | |
| 340 | + loadingSingleAnimation = false; | |
| 341 | + } | |
| 342 | + | |
| 343 | + | |
| 344 | + private IEnumerator loadAndPlay() | |
| 345 | + { | |
| 346 | + loading = true; | |
| 347 | + onPlayingStateChange(); | |
| 348 | + | |
| 349 | + string lastAnimationSubtitle = ""; | |
| 350 | + bool spelled = false; | |
| 351 | + | |
| 352 | + // Default | |
| 353 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 2F); | |
| 354 | + | |
| 355 | + if ( ! playing) | |
| 356 | + { | |
| 357 | + playing = true; | |
| 358 | + StartCoroutine("handleStates"); | |
| 359 | + } | |
| 360 | + | |
| 361 | + stringPos = glosa.Split(' '); | |
| 362 | + | |
| 363 | + foreach (string aniName in stringPos) | |
| 364 | + { | |
| 365 | + try { | |
| 366 | + if (String.IsNullOrEmpty(aniName)) continue; | |
| 367 | + } catch (Exception e) { | |
| 368 | + UnityEngine.Debug.Log(e + " :: NotNullNotEmpty"); | |
| 369 | + } | |
| 370 | + | |
| 371 | + bool nonexistent = nonexistentAssetBundles.Contains(aniName); | |
| 372 | + bool loaded = loadedAssetBundles.Contains(aniName); | |
| 373 | + | |
| 374 | + if ( ! nonexistent && ! loaded) | |
| 375 | + { | |
| 376 | + // Função loadAssetBundle é definida pela classe filha | |
| 377 | + WWW www = loadAssetBundle(aniName); | |
| 378 | + | |
| 379 | + if (www != null) | |
| 380 | + { | |
| 381 | + yield return www; | |
| 382 | + | |
| 383 | + AssetBundle bundle = null; | |
| 384 | + | |
| 385 | + if (www.error == null) | |
| 386 | + bundle = www.assetBundle; | |
| 387 | + | |
| 388 | + if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) | |
| 389 | + { | |
| 390 | + AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
| 391 | + bundle.Unload(false); | |
| 392 | + | |
| 393 | + if (aniClip) | |
| 394 | + { | |
| 395 | + COMPONENT_ANIMATION.AddClip(aniClip, aniName); | |
| 396 | + | |
| 397 | + loadedAssetBundles.Add(aniName); | |
| 398 | + loaded = true; | |
| 399 | + } | |
| 400 | + else UnityEngine.Debug.Log ("Sinal \"" + aniName + "\" não carregado corretamente."); | |
| 401 | + } | |
| 402 | + } | |
| 403 | + } | |
| 404 | + | |
| 405 | + // Reproduz palavra | |
| 406 | + if (loaded) | |
| 407 | + { | |
| 408 | + if (spelled) | |
| 409 | + { | |
| 410 | + // Default | |
| 411 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); | |
| 412 | + spelled = false; | |
| 413 | + } | |
| 414 | + | |
| 415 | + //bool isFlag = false; | |
| 416 | + | |
| 417 | + //if (aniName[0] == '[') | |
| 418 | + //{ | |
| 419 | + if (flags.Contains(aniName)) | |
| 420 | + { | |
| 421 | + //isFlag = true; | |
| 422 | + lastAnimationSubtitle = ""; | |
| 423 | + playAnimation(Subtitle.TYPE_WORD, aniName, ""); | |
| 424 | + } | |
| 425 | + else | |
| 426 | + { | |
| 427 | + lastAnimationSubtitle = aniName; | |
| 428 | + playAnimation(Subtitle.TYPE_WORD, aniName); | |
| 429 | + } | |
| 430 | + //} | |
| 431 | + | |
| 432 | + /*if (isFlag) | |
| 433 | + playAnimation(Subtitle.TYPE_WORD, aniName, ""); | |
| 434 | + else | |
| 435 | + playAnimation(Subtitle.TYPE_WORD, aniName);*/ | |
| 436 | + } | |
| 437 | + // Soletra palavra | |
| 438 | + else | |
| 439 | + { | |
| 440 | + // Se a animação não foi carregada e nem está marcada como não existente, | |
| 441 | + // adiciona ao set de animações não existentes | |
| 442 | + if ( ! nonexistent) | |
| 443 | + nonexistentAssetBundles.Add(aniName); | |
| 444 | + | |
| 445 | + UnityEngine.Debug.Log("~~ To spell: " + aniName); | |
| 446 | + | |
| 447 | + if (flags.Contains(aniName)) | |
| 448 | + { | |
| 449 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); | |
| 450 | + continue; | |
| 451 | + } | |
| 452 | + | |
| 453 | + // Se já houve o soletramento de alguma palavra, reproduz animação default | |
| 454 | + if (spelled) | |
| 455 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); | |
| 456 | + else | |
| 457 | + spelled = true; | |
| 458 | + | |
| 459 | + lastAnimationSubtitle = spellWord(aniName); | |
| 460 | + } | |
| 461 | + } | |
| 462 | + | |
| 463 | + // Default | |
| 464 | + playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, ""); | |
| 465 | + | |
| 466 | + loading = false; | |
| 467 | + onPlayingStateChange(); | |
| 468 | + } | |
| 469 | + | |
| 470 | + //int _id = 0; | |
| 471 | + | |
| 472 | + /* | |
| 473 | + * Sincroniza as legendas com as animações. | |
| 474 | + */ | |
| 475 | + IEnumerator handleStates() | |
| 476 | + { | |
| 477 | + if (this.randomAnimations != null) this.randomAnimations.stop(); | |
| 478 | + | |
| 479 | + // Enquanto estiver executando a rotina "loadAndPlay" | |
| 480 | + // ou existir animações na fila de reprodução | |
| 481 | + while (loading || animQueue.Count > 0) | |
| 482 | + { | |
| 483 | + if (animQueue.Count > 0) | |
| 484 | + { | |
| 485 | + AnimationReference reference = animQueue.Peek(); | |
| 486 | + | |
| 487 | + setSubtitle(reference.subtitle); | |
| 488 | + | |
| 489 | + while (COMPONENT_ANIMATION.IsPlaying(reference.name)) | |
| 490 | + { | |
| 491 | + reference.playing = true; | |
| 492 | + yield return null; | |
| 493 | + } | |
| 494 | + | |
| 495 | + if (reference.state == null) | |
| 496 | + animQueue.Dequeue(); | |
| 497 | + else | |
| 498 | + yield return null; | |
| 499 | + } | |
| 500 | + else yield return null; | |
| 501 | + | |
| 502 | + setSubtitle(""); | |
| 503 | + } | |
| 504 | + | |
| 505 | + playing = false; | |
| 506 | + paused = false; | |
| 507 | + onPlayingStateChange(); | |
| 508 | + | |
| 509 | + if (this.randomAnimations != null) this.randomAnimations.play(); | |
| 510 | + } | |
| 511 | + | |
| 512 | +} | ... | ... |
Assets/Scripts/Player Manager/GenericPlayerManager.cs.meta
0 → 100644
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 953c1d9124325ab4099d246d3cbfb780 | |
| 3 | +timeCreated: 1440187017 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using UnityEngine.UI; | |
| 3 | + | |
| 4 | +public class RandomAnimations { | |
| 5 | + | |
| 6 | + private GenericPlayerManager playerManager; | |
| 7 | + private string[] names = new string[] {}; | |
| 8 | + private int time = 3; | |
| 9 | + private float probability = 0.3F; | |
| 10 | + | |
| 11 | + private int lastIndex = -1; | |
| 12 | + private bool running = true; | |
| 13 | + | |
| 14 | + | |
| 15 | + public RandomAnimations(GenericPlayerManager playerManager, string[] animations, int time, float probability) | |
| 16 | + { | |
| 17 | + this.playerManager = playerManager; | |
| 18 | + this.names = animations; | |
| 19 | + this.time = time; | |
| 20 | + this.probability = probability; | |
| 21 | + | |
| 22 | + playerManager.Invoke("playRandomAnimations", this.time); | |
| 23 | + } | |
| 24 | + | |
| 25 | + | |
| 26 | + public void stop() { | |
| 27 | + this.running = false; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void play() { | |
| 31 | + this.running = true; | |
| 32 | + playerManager.Invoke("playRandomAnimations", this.time); | |
| 33 | + } | |
| 34 | + | |
| 35 | + private void playAnimation(string glosa) | |
| 36 | + { | |
| 37 | + this.playerManager.play(glosa); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void playRandom() | |
| 41 | + { | |
| 42 | + if (running) | |
| 43 | + { | |
| 44 | + int index = sortIndex(); | |
| 45 | + | |
| 46 | + if (index != -1) | |
| 47 | + { | |
| 48 | + if (index == lastIndex) | |
| 49 | + index = sortIndex(); | |
| 50 | + | |
| 51 | + playAnimation(this.names[index]); | |
| 52 | + } | |
| 53 | + | |
| 54 | + playerManager.Invoke("playRandomAnimations", this.time); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + | |
| 58 | + private int sortIndex() | |
| 59 | + { | |
| 60 | + int rand = new System.Random().Next((int) (this.names.Length / this.probability)); | |
| 61 | + return rand < this.names.Length ? rand : -1; | |
| 62 | + } | |
| 63 | + | |
| 64 | +} | |
| 0 | 65 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 9d4b654b474c35d4592a9c87c9fe817b | |
| 3 | +timeCreated: 1453154557 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -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 | 135 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -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: | ... | ... |
Assets/Scripts/PlayerManager.cs
| ... | ... | @@ -24,6 +24,12 @@ public class PlayerManager : GenericPlayerManager { |
| 24 | 24 | private Color enabledAlpha = new Color(1F, 1F, 1F, 1F); |
| 25 | 25 | private Color disabledAlpha = new Color(1F, 1F, 1F, 0.5F); |
| 26 | 26 | |
| 27 | + private string[] randomAnimationNames = new string[] { | |
| 28 | + "[OLA]", | |
| 29 | + //"[OI]", | |
| 30 | + "[IAE]" | |
| 31 | + }; | |
| 32 | + | |
| 27 | 33 | //InputField INFIELD; |
| 28 | 34 | |
| 29 | 35 | //Primeiro metodo que o player executa |
| ... | ... | @@ -40,6 +46,7 @@ public class PlayerManager : GenericPlayerManager { |
| 40 | 46 | stopButtonGraphic = stopButton.GetComponent<Graphic>(); |
| 41 | 47 | stopButtonGraphic.color = disabledAlpha; |
| 42 | 48 | |
| 49 | + base.setRandomAnimations(new RandomAnimations(this, randomAnimationNames, 2, 1), randomAnimationNames); | |
| 43 | 50 | base.Start(); |
| 44 | 51 | } |
| 45 | 52 | |
| ... | ... | @@ -62,8 +69,7 @@ public class PlayerManager : GenericPlayerManager { |
| 62 | 69 | if (base.isLoading() || base.isPlaying()) |
| 63 | 70 | base.stop_animations(); |
| 64 | 71 | |
| 65 | - base.glosa = glosa; | |
| 66 | - base.play(); | |
| 72 | + base.play(glosa); | |
| 67 | 73 | } |
| 68 | 74 | |
| 69 | 75 | protected override WWW loadAssetBundle(string aniName) | ... | ... |
Assets/Scripts/RotateSprite.cs
Assets/Scripts/RotateSprite.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: f30ae3e7382215343aa581d1acb2c6a6 | |
| 3 | -timeCreated: 1442259123 | |
| 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/SampleItem.cs
| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using UnityEngine.UI; | |
| 3 | -using System.Collections; | |
| 4 | - | |
| 5 | -public class SampleItem : MonoBehaviour { | |
| 6 | - | |
| 7 | - public Button button; | |
| 8 | - public Text title; | |
| 9 | - | |
| 10 | - public void StartAnimation() | |
| 11 | - { | |
| 12 | - GameObject.FindGameObjectWithTag("inspetor").GetComponent<PlayerManager>().start_local_play(title.text); | |
| 13 | - } | |
| 14 | - | |
| 15 | -} |
Assets/Scripts/SampleItem.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 95cb85318477935499bf0284a82a5fe3 | |
| 3 | -timeCreated: 1448644758 | |
| 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/Subtitle.cs
| ... | ... | @@ -1,134 +0,0 @@ |
| 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 | -} | |
| 135 | 0 | \ No newline at end of file |
Assets/Scripts/Subtitle.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 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: |
Assets/Scripts/Switch.cs
| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using System.Collections; | |
| 3 | - | |
| 4 | -public class Switch : MonoBehaviour { | |
| 5 | - | |
| 6 | - public GameObject go; | |
| 7 | - private bool isActive = false; | |
| 8 | - | |
| 9 | - public void SwitchStatus() | |
| 10 | - { | |
| 11 | - go.SetActive(isActive); | |
| 12 | - isActive = !isActive; | |
| 13 | - } | |
| 14 | - | |
| 15 | -} |
Assets/Scripts/Switch.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 9d82f947b8b7b8c4cb02d681f795cb2d | |
| 3 | -timeCreated: 1449167019 | |
| 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/SwitchButtonCollor.cs
| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using System.Collections; | |
| 3 | -using UnityEngine.UI; | |
| 4 | - | |
| 5 | -public class SwitchButtonCollor : MonoBehaviour { | |
| 6 | - | |
| 7 | - public Button thisButton; | |
| 8 | - private Graphic thisButtonGraphic; | |
| 9 | - | |
| 10 | - public bool isEnabled; | |
| 11 | - private Color enabledAlpha = new Color(0.356F, 0.78F, 0.815F, 1F); | |
| 12 | - private Color disabledAlpha = new Color(1F, 1F, 1F, 1F); | |
| 13 | - | |
| 14 | - void Start () { | |
| 15 | - thisButtonGraphic = thisButton.GetComponent<Graphic>(); | |
| 16 | - thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha; | |
| 17 | - } | |
| 18 | - | |
| 19 | - public void switchCollor(){ | |
| 20 | - isEnabled = !isEnabled; | |
| 21 | - thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha; | |
| 22 | - } | |
| 23 | - | |
| 24 | -} |
Assets/Scripts/SwitchButtonCollor.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: 7cc5766abb54eac43825973353dad745 | |
| 3 | -timeCreated: 1442264587 | |
| 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/SwitchResolution.cs
| ... | ... | @@ -1,44 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using System.Collections; | |
| 3 | -using System.Collections.Generic; | |
| 4 | -using System; | |
| 5 | -using UnityEngine.UI; | |
| 6 | - | |
| 7 | -public class SwitchResolution : MonoBehaviour { | |
| 8 | - | |
| 9 | - public static bool showbox = false; | |
| 10 | - | |
| 11 | - //Mostra e esconde a box de resolucao do player | |
| 12 | - public void switchResbox(){ | |
| 13 | - | |
| 14 | - showbox = !showbox; | |
| 15 | - gameObject.SetActive(showbox); | |
| 16 | - | |
| 17 | - } | |
| 18 | - | |
| 19 | - public void resChange(int i){ | |
| 20 | - | |
| 21 | - switch(i){ | |
| 22 | - | |
| 23 | - case 1: | |
| 24 | - Screen.SetResolution(640, 480, false); | |
| 25 | - Debug.Log ("640"); | |
| 26 | - break; | |
| 27 | - case 2: | |
| 28 | - Screen.SetResolution(800, 600, false); | |
| 29 | - Debug.Log ("800"); | |
| 30 | - break; | |
| 31 | - case 3: | |
| 32 | - Screen.SetResolution(1024, 768, false); | |
| 33 | - Debug.Log ("1024"); | |
| 34 | - break; | |
| 35 | - default: | |
| 36 | - Screen.SetResolution(640, 480, false); | |
| 37 | - Debug.Log ("unknown res"); | |
| 38 | - break; | |
| 39 | - | |
| 40 | - } | |
| 41 | - | |
| 42 | - } | |
| 43 | - | |
| 44 | -} |
Assets/Scripts/SwitchResolution.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: d0f8efe7b736c5c43932f164af521190 | |
| 3 | -timeCreated: 1435948409 | |
| 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/SwitchSubActiveStatus.cs
| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | -using UnityEngine; | |
| 2 | -using System; | |
| 3 | -using UnityEngine.UI; | |
| 4 | - | |
| 5 | -public class SwitchSubActiveStatus : MonoBehaviour { | |
| 6 | - | |
| 7 | - private bool show = true; | |
| 8 | - | |
| 9 | - //Mostra ou esconde o GameObject associado ao script | |
| 10 | - public void SwitchStatus() | |
| 11 | - { | |
| 12 | - show = !show; | |
| 13 | - gameObject.SetActive(show); | |
| 14 | - | |
| 15 | - } | |
| 16 | - | |
| 17 | -} |
Assets/Scripts/SwitchSubActiveStatus.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: f2c282fe94d95b544b4585b0af90077b | |
| 3 | -timeCreated: 1441833015 | |
| 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/TrieST.cs
| ... | ... | @@ -1,96 +0,0 @@ |
| 1 | -using System.Collections.Generic; | |
| 2 | -using System; | |
| 3 | -using System.Text; | |
| 4 | -using UnityEngine; | |
| 5 | - | |
| 6 | -public class TrieST<Value> | |
| 7 | -{ | |
| 8 | - private static int R = 42; | |
| 9 | - private static char[] chars = { | |
| 10 | - ' ', '-', '(', ')', ',', '%', | |
| 11 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', | |
| 12 | - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', | |
| 13 | - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | |
| 14 | - 'Y', 'Z', | |
| 15 | - '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' | |
| 16 | - }; | |
| 17 | - private static int[] indexes = new int[256]; | |
| 18 | - | |
| 19 | - private Node root; | |
| 20 | - private int N; | |
| 21 | - | |
| 22 | - private class Node | |
| 23 | - { | |
| 24 | - public String val; | |
| 25 | - public Node[] next = new Node[R]; | |
| 26 | - } | |
| 27 | - | |
| 28 | - public TrieST() | |
| 29 | - { | |
| 30 | - for (int i = 0; i < R; i++) | |
| 31 | - indexes[chars[i]] = i; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public String get(String key) | |
| 35 | - { | |
| 36 | - Node x = get(root, key, 0); | |
| 37 | - if (x == null) return null; | |
| 38 | - return x.val; | |
| 39 | - } | |
| 40 | - | |
| 41 | - private Node get(Node x, String key, int d) | |
| 42 | - { | |
| 43 | - if (x == null) return null; | |
| 44 | - if (d == key.Length) return x; | |
| 45 | - int c = indexes[key[d]]; | |
| 46 | - return get(x.next[c], key, d + 1); | |
| 47 | - } | |
| 48 | - | |
| 49 | - public void put(String key, String val) | |
| 50 | - { | |
| 51 | - root = put(root, key, val, 0); | |
| 52 | - } | |
| 53 | - | |
| 54 | - private Node put(Node x, String key, String val, int d) | |
| 55 | - { | |
| 56 | - | |
| 57 | - if (x == null) x = new Node(); | |
| 58 | - if (d == key.Length) | |
| 59 | - { | |
| 60 | - if (x.val == null) N++; | |
| 61 | - x.val = val; | |
| 62 | - return x; | |
| 63 | - } | |
| 64 | - int c = indexes[key[d]]; | |
| 65 | - x.next[c] = put(x.next[c], key, val, d + 1); | |
| 66 | - return x; | |
| 67 | - | |
| 68 | - } | |
| 69 | - | |
| 70 | - public Queue<String> keys() | |
| 71 | - { return keysWithPrefix(""); } | |
| 72 | - | |
| 73 | - public Queue<String> keysWithPrefix(String prefix) | |
| 74 | - { | |
| 75 | - Queue<String> results = new Queue<String>(); | |
| 76 | - Node x = get(root, prefix, 0); //ref para o primeiro nó que contem a palavra prefix | |
| 77 | - collect(x, new StringBuilder(prefix), results); | |
| 78 | - return results; | |
| 79 | - } | |
| 80 | - | |
| 81 | - private void collect(Node x, StringBuilder prefix, Queue<String> results) | |
| 82 | - { | |
| 83 | - if (x == null) return; | |
| 84 | - if (x.val != null) results.Enqueue(prefix.ToString()); | |
| 85 | - | |
| 86 | - for (char c = (char)0; c < R; c++) | |
| 87 | - { | |
| 88 | - prefix.Append(chars[c]); | |
| 89 | - | |
| 90 | - collect(x.next[c], prefix, results); | |
| 91 | - prefix.Remove(prefix.Length - 1, 1); | |
| 92 | - } | |
| 93 | - | |
| 94 | - } | |
| 95 | - | |
| 96 | -} | |
| 97 | 0 | \ No newline at end of file |
Assets/Scripts/TrieST.cs.meta
| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | -fileFormatVersion: 2 | |
| 2 | -guid: c688e56f6c765894981cb20a40f10a9b | |
| 3 | -timeCreated: 1448926009 | |
| 4 | -licenseType: Pro | |
| 5 | -MonoImporter: | |
| 6 | - serializedVersion: 2 | |
| 7 | - defaultReferences: [] | |
| 8 | - executionOrder: 0 | |
| 9 | - icon: {instanceID: 0} | |
| 10 | - userData: | |
| 11 | - assetBundleName: | |
| 12 | - assetBundleVariant: |
| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System.Collections; | |
| 3 | +using UnityEngine.EventSystems; | |
| 4 | +using UnityEngine.UI; | |
| 5 | + | |
| 6 | +public class FadeFX : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { | |
| 7 | + | |
| 8 | + private BoxCollider COMPONENT_COLLIDER; | |
| 9 | + public GameObject update_box; | |
| 10 | + //Cria referência para o colider do avatar e torna a barra transparente | |
| 11 | + public void Start() | |
| 12 | + { | |
| 13 | + | |
| 14 | + COMPONENT_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); | |
| 15 | + Deactivate(); | |
| 16 | + | |
| 17 | + } | |
| 18 | + | |
| 19 | + //Listeners de eventos do mouse | |
| 20 | + public void OnPointerEnter(PointerEventData eventData){ Activate(); } | |
| 21 | + public void OnPointerExit(PointerEventData eventData){ Deactivate(); } | |
| 22 | + | |
| 23 | + /* | |
| 24 | + * Desabilita o colider do avatar para bloquear a rotação | |
| 25 | + * Em seguida retorna o visual padrão da barra de controles | |
| 26 | + * e reativa a interação com os botões | |
| 27 | + */ | |
| 28 | + private void Activate() | |
| 29 | + { | |
| 30 | + | |
| 31 | + COMPONENT_COLLIDER.enabled = false; | |
| 32 | + | |
| 33 | + foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED")) | |
| 34 | + GO.GetComponent<CanvasRenderer>().SetAlpha(1f); | |
| 35 | + | |
| 36 | + foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS")) | |
| 37 | + GO.GetComponent<Button>().interactable = true; | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + /* | |
| 42 | + * Habilita o colider do avatar para desbloquear a rotação | |
| 43 | + * Em seguida diminui o alpha dos componentes da barra de controles tornando-os transparentes | |
| 44 | + * Logo após desativa a interação com os botões para impedir que fiquem em status "highlighted" | |
| 45 | + */ | |
| 46 | + private void Deactivate(){ | |
| 47 | + | |
| 48 | + if(!SwitchResolution.showbox && !update_box.activeSelf){ | |
| 49 | + | |
| 50 | + COMPONENT_COLLIDER.enabled = true; | |
| 51 | + | |
| 52 | + foreach(GameObject GO in GameObject.FindGameObjectsWithTag("FADENEEDED")) | |
| 53 | + GO.GetComponent<CanvasRenderer>().SetAlpha(.2f); | |
| 54 | + | |
| 55 | + foreach(GameObject GO in GameObject.FindGameObjectsWithTag("BUTTONS")) | |
| 56 | + GO.GetComponent<Button>().interactable = false; | |
| 57 | + | |
| 58 | + } | |
| 59 | + | |
| 60 | + } | |
| 61 | + | |
| 62 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 5cb0d8c33c1f9274083939fe0b6fdc86 | |
| 3 | +timeCreated: 1442001277 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System.Collections; | |
| 3 | + | |
| 4 | +public class RotateSprite : MonoBehaviour { | |
| 5 | + private float count = 0; | |
| 6 | + void Update () { | |
| 7 | + count = 1f + (count % 360); | |
| 8 | + transform.rotation = Quaternion.AngleAxis(count, new Vector3(0, 0, -1)); | |
| 9 | + } | |
| 10 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: f30ae3e7382215343aa581d1acb2c6a6 | |
| 3 | +timeCreated: 1442259123 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System.Collections; | |
| 3 | + | |
| 4 | +public class Switch : MonoBehaviour { | |
| 5 | + | |
| 6 | + public GameObject go; | |
| 7 | + private bool isActive = false; | |
| 8 | + | |
| 9 | + public void SwitchStatus() | |
| 10 | + { | |
| 11 | + go.SetActive(isActive); | |
| 12 | + isActive = !isActive; | |
| 13 | + } | |
| 14 | + | |
| 15 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 9d82f947b8b7b8c4cb02d681f795cb2d | |
| 3 | +timeCreated: 1449167019 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System.Collections; | |
| 3 | +using UnityEngine.UI; | |
| 4 | + | |
| 5 | +public class SwitchButtonCollor : MonoBehaviour { | |
| 6 | + | |
| 7 | + public Button thisButton; | |
| 8 | + private Graphic thisButtonGraphic; | |
| 9 | + | |
| 10 | + public bool isEnabled; | |
| 11 | + private Color enabledAlpha = new Color(0.356F, 0.78F, 0.815F, 1F); | |
| 12 | + private Color disabledAlpha = new Color(1F, 1F, 1F, 1F); | |
| 13 | + | |
| 14 | + void Start () { | |
| 15 | + thisButtonGraphic = thisButton.GetComponent<Graphic>(); | |
| 16 | + thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void switchCollor(){ | |
| 20 | + isEnabled = !isEnabled; | |
| 21 | + thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha; | |
| 22 | + } | |
| 23 | + | |
| 24 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: 7cc5766abb54eac43825973353dad745 | |
| 3 | +timeCreated: 1442264587 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System.Collections; | |
| 3 | +using System.Collections.Generic; | |
| 4 | +using System; | |
| 5 | +using UnityEngine.UI; | |
| 6 | + | |
| 7 | +public class SwitchResolution : MonoBehaviour { | |
| 8 | + | |
| 9 | + public static bool showbox = false; | |
| 10 | + | |
| 11 | + //Mostra e esconde a box de resolucao do player | |
| 12 | + public void switchResbox(){ | |
| 13 | + | |
| 14 | + showbox = !showbox; | |
| 15 | + gameObject.SetActive(showbox); | |
| 16 | + | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void resChange(int i){ | |
| 20 | + | |
| 21 | + switch(i){ | |
| 22 | + | |
| 23 | + case 1: | |
| 24 | + Screen.SetResolution(640, 480, false); | |
| 25 | + Debug.Log ("640"); | |
| 26 | + break; | |
| 27 | + case 2: | |
| 28 | + Screen.SetResolution(800, 600, false); | |
| 29 | + Debug.Log ("800"); | |
| 30 | + break; | |
| 31 | + case 3: | |
| 32 | + Screen.SetResolution(1024, 768, false); | |
| 33 | + Debug.Log ("1024"); | |
| 34 | + break; | |
| 35 | + default: | |
| 36 | + Screen.SetResolution(640, 480, false); | |
| 37 | + Debug.Log ("unknown res"); | |
| 38 | + break; | |
| 39 | + | |
| 40 | + } | |
| 41 | + | |
| 42 | + } | |
| 43 | + | |
| 44 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: d0f8efe7b736c5c43932f164af521190 | |
| 3 | +timeCreated: 1435948409 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +using UnityEngine; | |
| 2 | +using System; | |
| 3 | +using UnityEngine.UI; | |
| 4 | + | |
| 5 | +public class SwitchSubActiveStatus : MonoBehaviour { | |
| 6 | + | |
| 7 | + private bool show = true; | |
| 8 | + | |
| 9 | + //Mostra ou esconde o GameObject associado ao script | |
| 10 | + public void SwitchStatus() | |
| 11 | + { | |
| 12 | + show = !show; | |
| 13 | + gameObject.SetActive(show); | |
| 14 | + | |
| 15 | + } | |
| 16 | + | |
| 17 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +fileFormatVersion: 2 | |
| 2 | +guid: f2c282fe94d95b544b4585b0af90077b | |
| 3 | +timeCreated: 1441833015 | |
| 4 | +licenseType: Pro | |
| 5 | +MonoImporter: | |
| 6 | + serializedVersion: 2 | |
| 7 | + defaultReferences: [] | |
| 8 | + executionOrder: 0 | |
| 9 | + icon: {instanceID: 0} | |
| 10 | + userData: | |
| 11 | + assetBundleName: | |
| 12 | + assetBundleVariant: | ... | ... |