game: fixed score-shift system

This commit is contained in:
kookiekenobi 2025-02-04 03:29:45 +08:00
parent 30b88c4da4
commit 5775d43770
7 changed files with 54 additions and 30 deletions

View file

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

View file

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

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d971d51c8e156241a4499e252f667ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -79,8 +79,6 @@ public class DeskButtons : MonoBehaviour
Debug.Log("incorrect");
Debug.Log(Player.score);
Debug.Log(Player.customersServed);
playerScript.CheckDayEnd();
}
}
}

View file

@ -21,6 +21,9 @@ public class GameManager : MonoBehaviour
/// </summary>
[SerializeField]
public bool dayEnded = false;
[SerializeField]
public bool shiftStarted;
/// <summary>
/// Do Not Destroy on Load

View file

@ -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<GameManager>();
}
public void CheckDayEnd()
{
if (score < 0)
{
gm.dayEnded = true;
daysPlayed += 1;
Debug.Log("Game Over, Day has ended");
Debug.Log(daysPlayed);
}
}
}

View file

@ -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<GameManager>();
gm.shiftStarted = false;
remainingTime = shiftDuration;
shiftTrigger = GetComponent<Collider>();
@ -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;
}
}