Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022 #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 6 additions & 3 deletions Assets/0.Config/Scriptables/ScriptableSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
3 changes: 3 additions & 0 deletions Assets/0.Config/Sounds.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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}
88 changes: 54 additions & 34 deletions Assets/1.Scripts/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
86 changes: 86 additions & 0 deletions Assets/1.Scripts/AvatarManager.cs
Original file line number Diff line number Diff line change
@@ -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<RectTransform>();
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<Image>().sprite = avatarList[spriteIndex];
var avatarButton = avatarT.GetComponent<Button>();
avatarButton.onClick.RemoveAllListeners();
avatarButton.onClick.AddListener(() => BTN_Avatar(spriteIndex + 1));
avatarT.gameObject.SetActive(true);
avatarT.DOPunchScale(Vector3.one, 0.5f, 5, 0.5f);
AudioManager.Instance.PlayBlop();
await UniTask.Delay(90);
}
isAnimating = false;
}

void BTN_Avatar(int avatarIndex)
{
AudioManager.Instance.PlayBlop();
CanvasManager.Instance.SetAvatarSprite(avatarIndex);
gameObject.SetActive(false);
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Assets/1.Scripts/Boss1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private void Awake()

void Initialize()
{
stats.health = GameManager.Instance.gameConfiguration.finalBossHealth;
stats.health = GameSession.Instance.gameConfiguration.finalBossHealth;
nextHealthToDropPoints = stats.health - 400;
nextHealthToDropShield = stats.health / 2;
nextTimeDropBoost = Time.time + 7f;
Expand Down Expand Up @@ -118,7 +118,7 @@ Vector3 GetRandomCannonPos()
void GetStrike(int damage)
{
stats.health -= damage;
CanvasManager.Instance.AddScore(damage);
GameManager.Instance.AddScore(damage);
if (stats.health <= 0) Die();
else
{
Expand All @@ -132,7 +132,7 @@ void GetStrike(int damage)

void Die()
{
CanvasManager.Instance.AddScore(11000);
GameManager.Instance.AddScore(11000);
GameManager.Instance.FinalBossKilled(transform.position);
gameObject.SetActive(false);
}
Expand Down
Loading