Animate and add sound to countdown

This commit is contained in:
BuyMyMojo 2023-03-04 09:06:17 +11:00
parent 60ee4185e2
commit 8b0817b15d
6 changed files with 66 additions and 5 deletions

2
.erp
View file

@ -5,7 +5,7 @@
<resetOnSceneChange>false</resetOnSceneChange>
<debugMode>false</debugMode>
<EditorClosed>true</EditorClosed>
<LastTimestamp>1677885521</LastTimestamp>
<LastTimestamp>1677887423</LastTimestamp>
<LastSessionID>2115309888051293429</LastSessionID>
<Errored>false</Errored>
</ERPSettings>

View file

@ -6779,6 +6779,8 @@ GameObject:
m_Component:
- component: {fileID: 848339331}
- component: {fileID: 848339332}
- component: {fileID: 848339334}
- component: {fileID: 848339333}
m_Layer: 5
m_Name: GameStartCountdownUI
m_TagString: Untagged
@ -6796,7 +6798,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 665722096}
m_Father: {fileID: 1955192637}
@ -6820,6 +6822,39 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
countdownText: {fileID: 665722097}
--- !u!225 &848339333
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 848339330}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!95 &848339334
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 848339330}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 9d9369ef6465eb747bbfabd3f6b33449, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &879897164
GameObject:
m_ObjectHideFlags: 0

View file

@ -23,7 +23,7 @@ public class PlatesCounter : BaseCounter
{
spawnPlateTimer = 0f;
if (platesSpawnedAmount < platesSpawnedMax)
if (GameStateManager.Instace.IsGamePlaying() && platesSpawnedAmount < platesSpawnedMax)
{
platesSpawnedAmount++;

View file

@ -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)];

View file

@ -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;

View file

@ -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()