lose screen
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LoseScreenController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]private const string LoseSceneName = "Lose";
|
||||
|
||||
private List<PlayerStressController> players;
|
||||
private bool hasLost = false;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
players = FindObjectsOfType<PlayerStressController>().ToList();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (hasLost || players.Count == 0)
|
||||
return;
|
||||
|
||||
if (players.All(p => p.IsPanicking))
|
||||
{
|
||||
TriggerLose();
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerLose()
|
||||
{
|
||||
hasLost = true;
|
||||
SceneManager.LoadScene(LoseSceneName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5cdb566677d77e438cdf195197a5b85
|
||||
@@ -6,10 +6,17 @@ using UnityEngine;
|
||||
public class PlayerStressController : MonoBehaviour
|
||||
{
|
||||
public PlayerPickupController pickupController;
|
||||
|
||||
[Header("Stress Settings")]
|
||||
public float currentStress = 0f;
|
||||
public float maxStress = 100f;
|
||||
|
||||
[Header("Panic Settings")]
|
||||
[SerializeField] private float panicDuration = 1.2f;
|
||||
private float panicEndTime;
|
||||
|
||||
public bool IsPanicking => Time.time < panicEndTime;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Start the repeating loop
|
||||
@@ -46,6 +53,7 @@ public class PlayerStressController : MonoBehaviour
|
||||
|
||||
void HandlePanic()
|
||||
{
|
||||
panicEndTime = Time.time + panicDuration;
|
||||
Debug.Log("Player is freaking out man!");
|
||||
// Add effects like screen shake or slowing down the player here
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class WinScreenController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int winScore = 100;
|
||||
|
||||
private string winScreenScene = "Win"; // ✅ DECLARED HERE
|
||||
private string winScreenScene = "Win";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user