diff --git a/Assets/Bundles/XEROX b/Assets/Bundles/XEROX new file mode 100644 index 0000000..59936fc Binary files /dev/null and b/Assets/Bundles/XEROX differ diff --git a/Assets/Bundles/XINGAR b/Assets/Bundles/XINGAR new file mode 100644 index 0000000..3409013 Binary files /dev/null and b/Assets/Bundles/XINGAR differ diff --git a/Assets/Scenes/Scene.unity b/Assets/Scenes/Scene.unity index e571316..7e9ae7c 100644 --- a/Assets/Scenes/Scene.unity +++ b/Assets/Scenes/Scene.unity @@ -37,9 +37,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} ---- !u!127 &3 -LevelGameManager: - m_ObjectHideFlags: 0 --- !u!157 &4 LightmapSettings: m_ObjectHideFlags: 0 @@ -68,6 +65,7 @@ LightmapSettings: m_TextureCompression: 0 m_FinalGather: 0 m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 m_LightmapSnapshot: {fileID: 0} m_RuntimeCPUUsage: 25 --- !u!196 &5 diff --git a/Assets/Scripts/Editor/MyEditorScript.cs b/Assets/Scripts/Editor/MyEditorScript.cs new file mode 100644 index 0000000..18738f7 --- /dev/null +++ b/Assets/Scripts/Editor/MyEditorScript.cs @@ -0,0 +1,10 @@ +using UnityEditor; +using UnityEngine; + +class MyEditorScript +{ + static void RunAsd () + { + Debug.Log("asd"); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Editor/MyEditorScript.cs.meta b/Assets/Scripts/Editor/MyEditorScript.cs.meta new file mode 100644 index 0000000..b5e6ac2 --- /dev/null +++ b/Assets/Scripts/Editor/MyEditorScript.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 789d1dce6607a394b82bcaa4af8d1c46 +timeCreated: 1448041534 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GenericPlayerManager.cs b/Assets/Scripts/GenericPlayerManager.cs index 2655e5b..b44c1e1 100644 --- a/Assets/Scripts/GenericPlayerManager.cs +++ b/Assets/Scripts/GenericPlayerManager.cs @@ -10,11 +10,13 @@ using UnityEngine.UI; public abstract class GenericPlayerManager : MonoBehaviour { - private struct AnimationReference { + private class AnimationReference + { public string name; public string subtitle; public AnimationState state; public short type; + public bool playing; public AnimationReference(string name, string subtitle, AnimationState state, short type) { @@ -22,53 +24,70 @@ public abstract class GenericPlayerManager : MonoBehaviour { this.subtitle = subtitle; this.state = state; this.type = type; + this.playing = false; + } + } + + protected class DefaultSignSpeed + { + public static float DEFAULT = 1.1F; + public static float DEFAULT_MAX = 2F; + + public float speed; + public float max; + // Relação entre a velocidade do tipo representado e a velocidade DEFAULT. + public float unit; + + public DefaultSignSpeed() + { + this.speed = DEFAULT; + this.max = DEFAULT_MAX; + this.unit = 1F; + } + + public DefaultSignSpeed(float defaultSpeed, float defaultMaxSpeed) + { + this.speed = defaultSpeed; + this.max = defaultMaxSpeed; + this.unit = (this.max - this.speed) / (DEFAULT_MAX - DEFAULT); } + /* + * Retorna velocidade em relação ao estado do slider. + * @param slider - estado do slider (valor entre DefaultSignSpeed.DEFAULT e DefaultSignSpeed.DEFAULT_MAX) + */ + public float getProporcionalSpeed(float slider) + { + return this.speed + (slider - DEFAULT) * this.unit; + } } private const string DEFAULT_ANIMATION = "_default"; private const string NONE_ANIMATION = "_defaultWORD"; - private const float FADE_LENGTH = 0.6F; - - private const float WORD_DEFAULT_SPEED = 1.1F; - private const float WORD_MAX_SPEED = 2F; - - // Velocidade da primeira letra de uma palavra - private const float LETTER_FIRST_SPEED = 1.8F; - // Velocidade máxima de uma letra que o slider pode configurar - private const float LETTER_FIRST_MAX_SPEED = 2.8F; - // Taxa de velocidade da primeira letra de uma palavra equivalente a velocidade de uma palavra - private const float LETTER_FIRST_UNIT_SPEED = (LETTER_FIRST_MAX_SPEED - LETTER_FIRST_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); - // Velocidade das outras letras - private const float LETTER_DEFAULT_SPEED = 2.8F; - // Velocidade máxima de uma letra que o slider pode configurar - private const float LETTER_MAX_SPEED = 4.3F; - // Taxa de velocidade das outras letras equivalente a velocidade de uma palavra - private const float LETTER_UNIT_SPEED = (LETTER_MAX_SPEED - LETTER_DEFAULT_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); - - // Velocidade de reprodução de números - private const float NUMBER_DEFAULT_SPEED = 1.5F; - // Velocidade máxima de um número que o slider pode configurar - private const float NUMBER_MAX_SPEED = 2.9F; - // Taxa de velocidade equivalente a uma unidade de velocidade de uma palavra - private const float NUMBER_UNIT_SPEED = (NUMBER_MAX_SPEED - NUMBER_DEFAULT_SPEED) / (WORD_MAX_SPEED - WORD_DEFAULT_SPEED); + protected float fadeLength = 0.6F; + + protected DefaultSignSpeed defaultWordSpeed = new DefaultSignSpeed(); + protected DefaultSignSpeed defaultFirstLetterSpeed = new DefaultSignSpeed(2.1F, 2.8F); + protected DefaultSignSpeed defaultLetterSpeed = new DefaultSignSpeed(3F, 4.3F); + protected DefaultSignSpeed defaultNumberSpeed = new DefaultSignSpeed(1.5F, 2.9F); private const short TYPE_NONE = -1; private const short TYPE_WORD = 0; private const short TYPE_LETTER = 1; private const short TYPE_NUMBER = 2; - private static float hSlidersecond = WORD_DEFAULT_SPEED; - private float letterSpeed = LETTER_DEFAULT_SPEED; - private float numberSpeed = NUMBER_DEFAULT_SPEED; + private float hSlidersecond = DefaultSignSpeed.DEFAULT; + private float wordSpeed = DefaultSignSpeed.DEFAULT; + private float letterSpeed = DefaultSignSpeed.DEFAULT; + private float numberSpeed = DefaultSignSpeed.DEFAULT; protected string glosa = ""; private static String[] stringPos = { DEFAULT_ANIMATION };//vetor que sera usado para quebrar a glosa - public GameObject AVATAR; + private GameObject AVATAR; private Animation COMPONENT_ANIMATION; - private BoxCollider COMPONENT_COLLIDER; + private BoxCollider AVATAR_COLLIDER; public Text SUBTITLES; // Guarda os nomes das palavras ja carregadas. @@ -80,21 +99,30 @@ public abstract class GenericPlayerManager : MonoBehaviour { // Utilizada para alterar velocidade e apresentar a legenda. private volatile Queue animQueue = new Queue(); - // "play" flag. Indica se está carregando a glosa. + private volatile bool loadingSingleAnimation = false; private volatile bool loading = false; - - protected bool playing = false; - protected bool paused = false; + private volatile bool playing = false; + private volatile bool paused = false; public virtual void Start() { - //Gets Animation Component reference from AVATAR - COMPONENT_ANIMATION = AVATAR.GetComponent(); - COMPONENT_COLLIDER = AVATAR.GetComponent(); + wordSpeed = defaultWordSpeed.speed; + letterSpeed = defaultLetterSpeed.speed; + numberSpeed = defaultNumberSpeed.speed; + + AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar + COMPONENT_ANIMATION = AVATAR.GetComponent();//referencia para o componente animador do avatar + AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent(); } - public void SetAvatarCollider(bool active){ - COMPONENT_COLLIDER.enabled = active; + public bool isLoadingSingleAnimation() { return loadingSingleAnimation; } + public bool isLoading() { return loading; } + public bool isPlaying() { return playing; } + public bool isPaused() { return paused; } + + public void SetAvatarCollider(bool isActive) + { + AVATAR_COLLIDER.enabled = isActive; } protected virtual void setSubtitle(string text) @@ -107,8 +135,9 @@ public abstract class GenericPlayerManager : MonoBehaviour { { hSlidersecond = x; - letterSpeed = getProporcionalSpeed(LETTER_DEFAULT_SPEED, LETTER_UNIT_SPEED); - numberSpeed = getProporcionalSpeed(NUMBER_DEFAULT_SPEED, NUMBER_UNIT_SPEED); + wordSpeed = defaultWordSpeed.getProporcionalSpeed(x); + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(x); + numberSpeed = defaultNumberSpeed.getProporcionalSpeed(x); if ( ! paused) foreach (AnimationReference reference in animQueue) @@ -116,20 +145,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { reference.state.speed = getSpeedByType(reference.type); } - private float getProporcionalSpeed(float speed, float unit) - { - return speed + (hSlidersecond - WORD_DEFAULT_SPEED) * unit; - } - private float getSpeedByType(short type) { switch (type) { - case TYPE_WORD: return hSlidersecond; + case TYPE_WORD: return wordSpeed; case TYPE_LETTER: return letterSpeed; case TYPE_NUMBER: return numberSpeed; } - + return 2F; } @@ -159,21 +183,21 @@ public abstract class GenericPlayerManager : MonoBehaviour { } catch (NullReferenceException nre) { Debug.Log("SetQueueList null reff::"+nre.ToString()); } COMPONENT_ANIMATION.Stop(); - COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, FADE_LENGTH, PlayMode.StopAll); + COMPONENT_ANIMATION.CrossFade(DEFAULT_ANIMATION, fadeLength, PlayMode.StopAll); } /* * Manda reproduzir animação e adiciona a file de animações a serem reproduzidas. * * Caso não haja SUBTITLE, name será utilizado como SUBTITLE. - * Caso não haja fadeLength, será atribuido FADE_LENGTH. + * Caso não haja fadeLength, será atribuido fadeLength. * Caso não haja velocidade, hSlidersecond será atribuída. */ private AnimationState playAnimation(short type, string name, string subtitle, float speed) { try { - AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, FADE_LENGTH, QueueMode.CompleteOthers); + AnimationState state = COMPONENT_ANIMATION.CrossFadeQueued(name, fadeLength, QueueMode.CompleteOthers); state.speed = speed; animQueue.Enqueue(new AnimationReference(name, subtitle, state, type)); @@ -202,36 +226,63 @@ public abstract class GenericPlayerManager : MonoBehaviour { */ protected abstract WWW loadAssetBundle(string aniName); + /** * Listen to changes in the playing status. */ protected abstract void onPlayingStateChange(); - public void play() + + public void switchPauseState(bool paused) { - if (playing) + if (this.paused != paused) { - paused = ! paused; + this.paused = paused; foreach (AnimationReference reference in animQueue) if (reference.state != null) reference.state.speed = paused ? 0F : getSpeedByType(reference.type); + + onPlayingStateChange(); } + } + public void switchPauseState() + { + switchPauseState( ! paused); + } + + public bool play() + { + if (playing) + switchPauseState(); else - { - playing = true; + play(true, true, true); + + return true; + } - try{ - if (loading) + public bool play(bool stopLoading, bool stopPlaying, bool forceLoading) + { + try { + if (loading) + { + if (stopLoading) stop_animations(); else + return false; + } + else if (playing) + { + if (stopPlaying) stopAnimations(); - } catch (NullReferenceException nre) { nre.ToString(); } - StartCoroutine("loadAndPlay"); - } + else if ( ! forceLoading) + return false; + } + } catch (NullReferenceException nre) { nre.ToString(); } - onPlayingStateChange(); + StartCoroutine("loadAndPlay"); + return true; } @@ -279,7 +330,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { bool defaultPlayed = false; // A reprodução da primeira letra deve ser longa para não ser cortada no fade - letterSpeed = getProporcionalSpeed(LETTER_FIRST_SPEED, LETTER_FIRST_UNIT_SPEED); + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); for (int i = 0; i < word.Length; i++) { @@ -293,11 +344,11 @@ public abstract class GenericPlayerManager : MonoBehaviour { // Se for um número else if (second >= 48 && second <= 57) playAnimation(TYPE_NUMBER, second.ToString(), lastAnimationSubtitle, numberSpeed); - + // Se for uma vírgula else if (second == 44) playAnimation(TYPE_WORD, second.ToString(), lastAnimationSubtitle); - + // Não há animação else { @@ -308,7 +359,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); // A reprodução da próxima letra deve ser longa para não ser cortada no fade - letterSpeed = getProporcionalSpeed(LETTER_FIRST_SPEED, LETTER_FIRST_UNIT_SPEED); + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); } Debug.Log("Animação \"" + second + "\" inexistente."); @@ -316,23 +367,69 @@ public abstract class GenericPlayerManager : MonoBehaviour { } defaultPlayed = false; - letterSpeed = getProporcionalSpeed(LETTER_DEFAULT_SPEED, LETTER_UNIT_SPEED); + letterSpeed = defaultLetterSpeed.getProporcionalSpeed(hSlidersecond); } return lastAnimationSubtitle; } + protected IEnumerator loadAnimation(string name) + { + loadingSingleAnimation = true; + + // Função loadAssetBundle é definida pela classe filha + WWW www = loadAssetBundle(name); + + if (www != null) + { + yield return www; + + AssetBundle bundle = null; + + if (www.error == null) + bundle = www.assetBundle; + + if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name)) + { + AnimationClip aniClip = bundle.mainAsset as AnimationClip; + bundle.Unload(false); + + if (aniClip) + { + COMPONENT_ANIMATION.AddClip(aniClip, name); + + // Reproduz palavra + loadedAssetBundles.Add(name); + yield break; + } + else Debug.Log ("Sinal \"" + name + "\" não carregado corretamente."); + } + } + + // Soletra palavra + nonexistentAssetBundles.Add(name); + + loadingSingleAnimation = false; + } + + private IEnumerator loadAndPlay() { loading = true; + onPlayingStateChange(); string lastAnimationSubtitle = ""; bool spelled = false; // Default playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 2F); - StartCoroutine("handleStates"); + + if ( ! playing) + { + playing = true; + StartCoroutine("handleStates"); + } stringPos = glosa.Split(' '); @@ -389,7 +486,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { } bool isPunctuation = false; - lastAnimationSubtitle = aniName; if (aniName[0] == '[') { @@ -410,15 +506,16 @@ public abstract class GenericPlayerManager : MonoBehaviour { isPunctuation = true; lastAnimationSubtitle = "!"; } + else + { + lastAnimationSubtitle = aniName; + } } if (isPunctuation) playAnimation(TYPE_WORD, aniName, lastAnimationSubtitle); else playAnimation(TYPE_WORD, aniName); - - /*playAnimation(TYPE_WORD, aniName); - lastAnimationSubtitle = aniName;*/ } // Soletra palavra else @@ -428,29 +525,33 @@ public abstract class GenericPlayerManager : MonoBehaviour { if ( ! nonexistent) nonexistentAssetBundles.Add(aniName); - if (aniName[0] == '[' && (aniName.Equals("[PONTO]") || aniName.Equals("[INTERROGACAO]") || aniName.Equals("[EXCLAMACAO]"))) + Debug.Log("~~ To spell: " + aniName); + + if (aniName.Equals("[PONTO]") || aniName.Equals("[INTERROGACAO]") || aniName.Equals("[EXCLAMACAO]")) { playAnimation(TYPE_NONE, DEFAULT_ANIMATION, "", 1.6F); + continue; } + + // Se já houve o soletramento de alguma palavra, reproduz animação default + if (spelled) + playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); else - { - // Se já houve o soletramento de alguma palavra, reproduz animação default - if (spelled) - playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle, 1.6F); - else - spelled = true; + spelled = true; - lastAnimationSubtitle = spellWord(aniName); - } + lastAnimationSubtitle = spellWord(aniName); } } // Default playAnimation(TYPE_NONE, DEFAULT_ANIMATION, lastAnimationSubtitle); - loading = false; + loading = false; + onPlayingStateChange(); } + //int _id = 0; + /* * Sincroniza as legendas com as animações. */ @@ -467,9 +568,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { setSubtitle(reference.subtitle); while (COMPONENT_ANIMATION.IsPlaying(reference.name)) + { + reference.playing = true; yield return null; + } - animQueue.Dequeue(); + if (reference.state == null) + animQueue.Dequeue(); + else + yield return null; } else yield return null; @@ -479,19 +586,6 @@ public abstract class GenericPlayerManager : MonoBehaviour { playing = false; paused = false; onPlayingStateChange(); - - } - - - /* - * Chamada quando o player sinaliza UPDATE ou STOP. - * Limpa as filas de assets existentes e não existentes - * permitindo que novos assets sejam executados - */ - public void clear() - { - nonexistentAssetBundles.Clear(); - loadedAssetBundles.Clear(); } } diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index 37b1fe3..51f1fa1 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -48,14 +48,12 @@ public class PlayerManager : GenericPlayerManager { // a terceira, para testes com a textbox public string catchGlosa() { - glosa = Marshal.PtrToStringAnsi ( coreExecute( ) ); - //osa = "PIZZA"; - return glosa; + return base.glosa = Marshal.PtrToStringAnsi ( coreExecute( ) ); } public void start_local_play() { - catchGlosa(); + this.catchGlosa(); base.play(); } @@ -78,9 +76,9 @@ public class PlayerManager : GenericPlayerManager { protected override void onPlayingStateChange() { - if (base.playing) + if (base.isPlaying()) { - playButton.GetComponent().sprite = base.paused + playButton.GetComponent().sprite = base.isPaused() ? playSprite : pauseSprite; stopButtonGraphic.color = enabledAlpha; diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 8d4c592..04f6bec 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -115,6 +115,7 @@ PlayerSettings: iPhoneTargetOSVersion: 22 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 uIStatusBarHidden: 1 uIExitOnSuspend: 0 uIStatusBarStyle: 0 @@ -163,8 +164,10 @@ PlayerSettings: m_BuildTargetIcons: - m_BuildTarget: m_Icons: - - m_Icon: {fileID: 2800000, guid: 98a8d3ec5bfc6ef4bacfcc810c9edf5a, type: 3} - m_Size: 128 + - serializedVersion: 2 + m_Icon: {fileID: 2800000, guid: 98a8d3ec5bfc6ef4bacfcc810c9edf5a, type: 3} + m_Width: 128 + m_Height: 128 m_BuildTargetBatching: - m_BuildTarget: WebGL m_StaticBatching: 1 @@ -261,6 +264,10 @@ PlayerSettings: ps4pnGameCustomData: 1 playerPrefsSupport: 0 ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4SocialScreenEnabled: 0 ps4attribUserManagement: 0 ps4attribMoveSupport: 0 ps4attrib3DSupport: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 8a062e6..a6bc721 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.2.1f1 +m_EditorVersion: 5.2.3f1 m_StandardAssetsVersion: 0 -- libgit2 0.21.2