diff --git a/Assets/0.Config/Scriptables/ScriptableSounds.cs b/Assets/0.Config/Scriptables/ScriptableSounds.cs index 77903e4..97a306b 100644 --- a/Assets/0.Config/Scriptables/ScriptableSounds.cs +++ b/Assets/0.Config/Scriptables/ScriptableSounds.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using UnityEngine; -[CreateAssetMenu ()] +[CreateAssetMenu()] public class ScriptableSounds : ScriptableObject { - [Header ("Músicas")] + [Header("Músicas")] public AudioClip mainTheme; - [Header ("Sonidos")] + [Header("Sonidos")] public AudioClip basicShot; public AudioClip enemyShot, enemyShot2, enemyShotFire; public AudioClip enemyDamaged, enemyDamagedLow, bossDamaged; @@ -19,4 +19,7 @@ public class ScriptableSounds : ScriptableObject public AudioClip shipUpgrade; public AudioClip gameOverSFX; public AudioClip theWin; + public AudioClip buttonClick; + public AudioClip blop; + public AudioClip retroPunch; } diff --git a/Assets/0.Config/Sounds.asset b/Assets/0.Config/Sounds.asset index d66c056..6931dcb 100644 --- a/Assets/0.Config/Sounds.asset +++ b/Assets/0.Config/Sounds.asset @@ -28,3 +28,6 @@ MonoBehaviour: shipUpgrade: {fileID: 8300000, guid: b5682408b5afe9440b2d883ed5cdebb2, type: 3} gameOverSFX: {fileID: 8300000, guid: d500b4ba427678a49880e6fdd06abfb0, type: 3} theWin: {fileID: 8300000, guid: fd7149e6638c48d4489970c10bdadbe4, type: 3} + buttonClick: {fileID: 8300000, guid: e93ed19488473e847b4b1fefaa201504, type: 3} + blop: {fileID: 8300000, guid: 3cfc07c1ac2e43a4289ca15e0ed3f431, type: 3} + retroPunch: {fileID: 8300000, guid: c3cd81f529602fa4484bc0fdf1cf954c, type: 3} diff --git a/Assets/1.Scripts/AudioManager.cs b/Assets/1.Scripts/AudioManager.cs index d92f24a..da3d7ed 100644 --- a/Assets/1.Scripts/AudioManager.cs +++ b/Assets/1.Scripts/AudioManager.cs @@ -8,91 +8,111 @@ public class AudioManager : MonoBehaviour public ScriptableSounds scriptableSounds; public AudioSource musicSource, playerSource, enemySource; - private void Awake () + private void Awake() { - if (Instance) Destroy (this.gameObject); + if (Instance) Destroy(this.gameObject); Instance = this; } - public void StartMusic () + public void PlayMainThemeMusic() { musicSource.clip = scriptableSounds.mainTheme; - musicSource.Play (); + musicSource.Play(); } - public void StopMusic () + public void StopMusic() { - musicSource.Stop (); + musicSource.Stop(); } - public void PlayAudioPlayer (AudioClip clip) + public void PlayAudioPlayer(AudioClip clip) { - playerSource.PlayOneShot (clip); + playerSource.PlayOneShot(clip); } - public void PlayAudioEnemy (AudioClip clip) + public void PlayAudioEnemy(AudioClip clip) { - enemySource.PlayOneShot (clip); + enemySource.PlayOneShot(clip); } - public void PlayPlayerShot () + public void PlayAudioTyping() { - PlayAudioPlayer (scriptableSounds.basicShot); + playerSource.PlayOneShot(scriptableSounds.basicShot); } - public void PlayPlayerLevelUp () + public void PlayButtonClick() { - PlayAudioPlayer (scriptableSounds.shipUpgrade); + PlayAudioPlayer(scriptableSounds.buttonClick); } - public void PlayPlayerLifeUp () + public void PlayRetroPunch() { - PlayAudioPlayer (scriptableSounds.lifeUp); + PlayAudioPlayer(scriptableSounds.retroPunch); } - public void PlayPlayerDestroyed () + public void PlayBlop() { - PlayAudioPlayer (scriptableSounds.playerDestroyed); + PlayAudioPlayer(scriptableSounds.blop); } - public void PlayEnemyShot () + public void PlayPlayerShot() { - PlayAudioEnemy (scriptableSounds.enemyShot); + PlayAudioPlayer(scriptableSounds.basicShot); } - public void PlayEnemyShotSlow () + public void PlayPlayerLevelUp() { - PlayAudioEnemy (scriptableSounds.enemyShot2); + PlayAudioPlayer(scriptableSounds.shipUpgrade); } - public void PlayEnemyShotFire () + public void PlayPlayerLifeUp() { - PlayAudioEnemy (scriptableSounds.enemyShotFire); + PlayAudioPlayer(scriptableSounds.lifeUp); } - public void PlayEnemyDamaged () + public void PlayPlayerDestroyed() { - PlayAudioEnemy (scriptableSounds.enemyDamaged); + PlayAudioPlayer(scriptableSounds.playerDestroyed); } - public void PlayEnemyDamagedLow () + public void PlayEnemyShot() { - PlayAudioEnemy (scriptableSounds.enemyDamagedLow); + PlayAudioEnemy(scriptableSounds.enemyShot); } - public void PlayEnemyExplosionLow () + public void PlayEnemyShotSlow() { - PlayAudioEnemy (scriptableSounds.explosionLow); + PlayAudioEnemy(scriptableSounds.enemyShot2); } - public void PlayEnemyShieldImpact () + public void PlayEnemyShotFire() { - PlayAudioEnemy (scriptableSounds.shieldImpact); + PlayAudioEnemy(scriptableSounds.enemyShotFire); } - public void PlayBossDamaged () + public void PlayEnemyDamaged() { - PlayAudioEnemy (scriptableSounds.bossDamaged); + PlayAudioEnemy(scriptableSounds.enemyDamaged); + } + + public void PlayEnemyDamagedLow() + { + PlayAudioEnemy(scriptableSounds.enemyDamagedLow); + } + + public void PlayEnemyExplosionLow() + { + PlayAudioEnemy(scriptableSounds.explosionLow); + } + + public void PlayEnemyShieldImpact() + { + PlayAudioEnemy(scriptableSounds.shieldImpact); + } + + public void PlayBossDamaged() + { + PlayAudioEnemy(scriptableSounds.bossDamaged); } } diff --git a/Assets/1.Scripts/AvatarManager.cs b/Assets/1.Scripts/AvatarManager.cs new file mode 100644 index 0000000..fa83a43 --- /dev/null +++ b/Assets/1.Scripts/AvatarManager.cs @@ -0,0 +1,86 @@ +using System.Collections; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using DG.Tweening; +using UnityEngine; +using UnityEngine.UI; + +public class AvatarManager : MonoBehaviour +{ + public Button avatarLeftButton, avatarRightButton; + public float animButtonDuration = 0.5f; + public float animButtonDistance = 1.8f; + public Transform avatarTransList; + int pageIndex = 0; + bool isAnimating = false; + + void OnEnable() + { + var rectT = transform.GetComponent(); + rectT.DOPunchAnchorPos(rectT.anchoredPosition * 1.2f, 0.5f, 2, 0.3f); + FillAvatars(pageIndex); + } + + public void BTN_AvatarLeft() + { + if (isAnimating) return; + AudioManager.Instance.PlayButtonClick(); + iTween.PunchScale(avatarLeftButton.gameObject, Vector3.one * animButtonDistance, animButtonDuration); + PreviosAvatarPage(); + } + + public void BTN_AvatarRight() + { + if (isAnimating) return; + AudioManager.Instance.PlayButtonClick(); + iTween.PunchScale(avatarRightButton.gameObject, Vector3.one * animButtonDistance, animButtonDuration); + NextAvatarPage(); + } + + void PreviosAvatarPage() + { + var totalPages = CanvasManager.Instance.spritesAvatar.Count / avatarTransList.childCount; + pageIndex--; + if (pageIndex < 0) pageIndex = totalPages; + FillAvatars(pageIndex); + } + + void NextAvatarPage() + { + var totalPages = CanvasManager.Instance.spritesAvatar.Count / avatarTransList.childCount; + pageIndex++; + if (totalPages < pageIndex) pageIndex = 0; + FillAvatars(pageIndex); + } + + async void FillAvatars(int pageIndex) + { + if (isAnimating) return; + isAnimating = true; + var avatarList = CanvasManager.Instance.spritesAvatar; + foreach (Transform t in avatarTransList) t.gameObject.SetActive(false); + for (var x = 0; x < avatarTransList.childCount; x++) + { + var spriteIndex = x + (pageIndex * avatarTransList.childCount); + if (avatarList.Count <= spriteIndex) break; + var avatarT = avatarTransList.GetChild(x); + avatarT.GetComponent().sprite = avatarList[spriteIndex]; + var avatarButton = avatarT.GetComponent