Animate and add sound to countdown
This commit is contained in:
parent
60ee4185e2
commit
8b0817b15d
6 changed files with 66 additions and 5 deletions
|
@ -23,7 +23,7 @@ public class PlatesCounter : BaseCounter
|
|||
{
|
||||
spawnPlateTimer = 0f;
|
||||
|
||||
if (platesSpawnedAmount < platesSpawnedMax)
|
||||
if (GameStateManager.Instace.IsGamePlaying() && platesSpawnedAmount < platesSpawnedMax)
|
||||
{
|
||||
platesSpawnedAmount++;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DeliveryManager : MonoBehaviour
|
|||
{
|
||||
spawnRecipeTimer = spawnRecipeTimerMax;
|
||||
|
||||
if (waitingRecipeSOList.Count < waitingRecipesMax)
|
||||
if (GameStateManager.Instace.IsGamePlaying() && waitingRecipeSOList.Count < waitingRecipesMax)
|
||||
{
|
||||
RecipeSO waitingRecipeSO = recipeListSO.recipeSOList[UnityEngine.Random.Range(0, recipeListSO.recipeSOList.Count)];
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ public class SoundManager : MonoBehaviour
|
|||
PlaySound(audioClipsRefsSO.footstep, position, volume);
|
||||
}
|
||||
|
||||
public void PlayCountdown()
|
||||
{
|
||||
PlaySound(audioClipsRefsSO.warning, Vector3.zero);
|
||||
}
|
||||
|
||||
public void ChangeVolume()
|
||||
{
|
||||
volume += .1f;
|
||||
|
|
|
@ -6,8 +6,18 @@ using UnityEngine;
|
|||
public class GameStartCountdownUI : MonoBehaviour
|
||||
{
|
||||
|
||||
private const string NUMBER_POPUP_ANIMATION = "NumberPopup";
|
||||
|
||||
[SerializeField] private TextMeshProUGUI countdownText;
|
||||
|
||||
private Animator animator;
|
||||
private int previousCountdownNumber;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameStateManager.Instace.OnStateChanged += GameStateManager_OnStateChanged;
|
||||
|
@ -30,7 +40,18 @@ public class GameStartCountdownUI : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
countdownText.text = Mathf.Ceil(GameStateManager.Instace.GetCountdownToStartTimer()).ToString();
|
||||
int countdownNumber = Mathf.CeilToInt(GameStateManager.Instace.GetCountdownToStartTimer());
|
||||
if (countdownNumber != previousCountdownNumber)
|
||||
{
|
||||
previousCountdownNumber = countdownNumber;
|
||||
|
||||
animator.SetTrigger(NUMBER_POPUP_ANIMATION);
|
||||
|
||||
countdownText.text = countdownNumber.ToString();
|
||||
|
||||
SoundManager.Instance.PlayCountdown();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void Show()
|
||||
|
|
Reference in a new issue