diff --git a/SSLR/Assets/Scenes/LiviPlayground.unity b/SSLR/Assets/Scenes/LiviPlayground.unity index 0f06c02..55fa0d7 100644 --- a/SSLR/Assets/Scenes/LiviPlayground.unity +++ b/SSLR/Assets/Scenes/LiviPlayground.unity @@ -918,6 +918,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: dayEnded: 0 + shiftStarted: 0 --- !u!114 &520849217 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1376,7 +1377,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0bab791ccf13189449b82b8f0b70b269, type: 3} m_Name: m_EditorClassIdentifier: - shiftDuration: 5 + shiftDuration: 20 --- !u!1 &756192406 GameObject: m_ObjectHideFlags: 0 diff --git a/SSLR/Assets/Scripts/DayManager.cs b/SSLR/Assets/Scripts/DayManager.cs new file mode 100644 index 0000000..5c305fd --- /dev/null +++ b/SSLR/Assets/Scripts/DayManager.cs @@ -0,0 +1,25 @@ +/* + * Author: Livinia Poo + * Date: 4/2/25 + * Description: + * Managing start and end days + */ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DayManager : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/SSLR/Assets/Scripts/DayManager.cs.meta b/SSLR/Assets/Scripts/DayManager.cs.meta new file mode 100644 index 0000000..a877b2d --- /dev/null +++ b/SSLR/Assets/Scripts/DayManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d971d51c8e156241a4499e252f667ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SSLR/Assets/Scripts/DeskButtons.cs b/SSLR/Assets/Scripts/DeskButtons.cs index d1f2cdc..9b31ae9 100644 --- a/SSLR/Assets/Scripts/DeskButtons.cs +++ b/SSLR/Assets/Scripts/DeskButtons.cs @@ -79,8 +79,6 @@ public class DeskButtons : MonoBehaviour Debug.Log("incorrect"); Debug.Log(Player.score); Debug.Log(Player.customersServed); - - playerScript.CheckDayEnd(); } } } diff --git a/SSLR/Assets/Scripts/GameManager.cs b/SSLR/Assets/Scripts/GameManager.cs index f2e8daf..90cd4eb 100644 --- a/SSLR/Assets/Scripts/GameManager.cs +++ b/SSLR/Assets/Scripts/GameManager.cs @@ -21,6 +21,9 @@ public class GameManager : MonoBehaviour /// [SerializeField] public bool dayEnded = false; + + [SerializeField] + public bool shiftStarted; /// /// Do Not Destroy on Load diff --git a/SSLR/Assets/Scripts/Player.cs b/SSLR/Assets/Scripts/Player.cs index f352738..a6299eb 100644 --- a/SSLR/Assets/Scripts/Player.cs +++ b/SSLR/Assets/Scripts/Player.cs @@ -14,22 +14,4 @@ public class Player : MonoBehaviour public static int score = 0; public static int customersServed = 0; public static int daysPlayed = 0; - - private GameManager gm; - - void Start() - { - gm = GameObject.Find("Game Manager").GetComponent(); - } - - public void CheckDayEnd() - { - if (score < 0) - { - gm.dayEnded = true; - daysPlayed += 1; - Debug.Log("Game Over, Day has ended"); - Debug.Log(daysPlayed); - } - } } diff --git a/SSLR/Assets/Scripts/ShiftManager.cs b/SSLR/Assets/Scripts/ShiftManager.cs index 6c13c2d..7623234 100644 --- a/SSLR/Assets/Scripts/ShiftManager.cs +++ b/SSLR/Assets/Scripts/ShiftManager.cs @@ -11,16 +11,18 @@ using UnityEngine; public class ShiftManager : MonoBehaviour { - private bool shiftStarted; [SerializeField] private float shiftDuration; private float remainingTime; private Collider shiftTrigger; + private GameManager gm; void Awake() { - shiftStarted = false; + gm = GameObject.Find("Game Manager").GetComponent(); + + gm.shiftStarted = false; remainingTime = shiftDuration; shiftTrigger = GetComponent(); @@ -28,11 +30,11 @@ public class ShiftManager : MonoBehaviour void OnTriggerEnter(Collider other) { - if (other.tag == "Player" && !shiftStarted) + if (other.tag == "Player" && !gm.shiftStarted) { Debug.Log("Shift started"); - shiftStarted = true; + gm.shiftStarted = true; shiftTrigger.enabled = false; StartCoroutine(StartWorkShift()); } @@ -43,8 +45,13 @@ public class ShiftManager : MonoBehaviour while (remainingTime > 0) { remainingTime -= Time.deltaTime; - Debug.Log("Shift: " + remainingTime); + + if (Player.score < 0) + { + Debug.Log("Too many mistakes! Shift ended!"); + break; + } yield return null; } @@ -55,10 +62,7 @@ public class ShiftManager : MonoBehaviour { Debug.Log("Shift ended!"); - /* - shiftTrigger.enabled = true; - */ remainingTime = shiftDuration; - shiftStarted = false; + gm.shiftStarted = false; } }