Add Game Over screen and count down clock for game time
This commit is contained in:
parent
15abaa80fa
commit
0c71d06fb8
10 changed files with 934 additions and 9 deletions
|
@ -18,6 +18,7 @@ public class DeliveryManager : MonoBehaviour
|
|||
private float spawnRecipeTimer;
|
||||
private float spawnRecipeTimerMax = 4f;
|
||||
private int waitingRecipesMax = 4;
|
||||
private int successfulRecipesAmount;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
@ -84,6 +85,8 @@ public class DeliveryManager : MonoBehaviour
|
|||
{
|
||||
// Player delivered correct recipe
|
||||
|
||||
successfulRecipesAmount++;
|
||||
|
||||
waitingRecipeSOList.RemoveAt(i);
|
||||
|
||||
OnRecipeCompleted?.Invoke(this, EventArgs.Empty);
|
||||
|
@ -105,4 +108,9 @@ public class DeliveryManager : MonoBehaviour
|
|||
return waitingRecipeSOList;
|
||||
}
|
||||
|
||||
public int GetSuccessfulRecipesAmount()
|
||||
{
|
||||
return successfulRecipesAmount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ public class GameStateManager : MonoBehaviour
|
|||
// --- Timers ---
|
||||
private float waitingToStartTimer = 1f;
|
||||
private float countdownToStartTimer = 3f;
|
||||
private float gamePlayTimer = 10f;
|
||||
private float gamePlayTimer;
|
||||
private float gamePlayTimerMax = 10f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
@ -48,6 +49,9 @@ public class GameStateManager : MonoBehaviour
|
|||
if (countdownToStartTimer < 0f)
|
||||
{
|
||||
state = State.GamePlaying;
|
||||
|
||||
gamePlayTimer = gamePlayTimerMax;
|
||||
|
||||
OnStateChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
break;
|
||||
|
@ -76,9 +80,19 @@ public class GameStateManager : MonoBehaviour
|
|||
return state == State.StartingCountdown;
|
||||
}
|
||||
|
||||
public bool IsGameOver()
|
||||
{
|
||||
return state == State.GameOver;
|
||||
}
|
||||
|
||||
public float GetCountdownToStartTimer()
|
||||
{
|
||||
return countdownToStartTimer;
|
||||
}
|
||||
|
||||
public float GetGamePlayingTimerNomalized()
|
||||
{
|
||||
return gamePlayTimer / gamePlayTimerMax;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent
|
|||
|
||||
private void GameInput_OnInteractAlteranteAction(object sender, EventArgs e)
|
||||
{
|
||||
if (GameStateManager.Instace.IsGamePlaying()) return;
|
||||
if (!GameStateManager.Instace.IsGamePlaying()) return;
|
||||
|
||||
if (selectedCounter != null)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent
|
|||
|
||||
private void GameInput_OnInteractAction(object sender, System.EventArgs e)
|
||||
{
|
||||
if (GameStateManager.Instace.IsGamePlaying()) return;
|
||||
if (!GameStateManager.Instace.IsGamePlaying()) return;
|
||||
|
||||
if (selectedCounter != null)
|
||||
{
|
||||
|
|
45
Assets/Scripts/UI/GameOverUI.cs
Normal file
45
Assets/Scripts/UI/GameOverUI.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameOverUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private TextMeshProUGUI recipesDeliveredText;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameStateManager.Instace.OnStateChanged += GameStateManager_OnStateChanged;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void GameStateManager_OnStateChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if (GameStateManager.Instace.IsGameOver())
|
||||
{
|
||||
recipesDeliveredText.text = DeliveryManager.Instance.GetSuccessfulRecipesAmount().ToString();
|
||||
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/GameOverUI.cs.meta
Normal file
11
Assets/Scripts/UI/GameOverUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 013706d69218eaf4c8846347c7623231
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Assets/Scripts/UI/GamePlayingClockUI.cs
Normal file
19
Assets/Scripts/UI/GamePlayingClockUI.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GamePlayingClockUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private Image timerImage;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GameStateManager.Instace.IsGamePlaying())
|
||||
{
|
||||
timerImage.fillAmount = GameStateManager.Instace.GetGamePlayingTimerNomalized();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/GamePlayingClockUI.cs.meta
Normal file
11
Assets/Scripts/UI/GamePlayingClockUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e35db9a44b52331429d72e840a753447
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue