From 82f4ed859fc356c97836d912adecef006f0e29f8 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 15 Feb 2025 22:00:37 +0800 Subject: [PATCH] game: removing depreciated scripts --- SSLR/Assets/Scenes/LiviPlayground.unity | 22 +-- SSLR/Assets/Scripts/DeskButtons.cs | 107 --------------- SSLR/Assets/Scripts/DeskButtons.cs.meta | 11 -- SSLR/Assets/Scripts/NPCBehaviour.cs | 60 -------- SSLR/Assets/Scripts/NPCBehaviour.cs.meta | 11 -- SSLR/Assets/Scripts/NPCMovement.cs | 167 ----------------------- SSLR/Assets/Scripts/NPCMovement.cs.meta | 11 -- SSLR/Assets/Scripts/NPCMovementRework.cs | 4 +- SSLR/Assets/Scripts/NpcManager.cs | 15 +- 9 files changed, 23 insertions(+), 385 deletions(-) delete mode 100644 SSLR/Assets/Scripts/DeskButtons.cs delete mode 100644 SSLR/Assets/Scripts/DeskButtons.cs.meta delete mode 100644 SSLR/Assets/Scripts/NPCBehaviour.cs delete mode 100644 SSLR/Assets/Scripts/NPCBehaviour.cs.meta delete mode 100644 SSLR/Assets/Scripts/NPCMovement.cs delete mode 100644 SSLR/Assets/Scripts/NPCMovement.cs.meta diff --git a/SSLR/Assets/Scenes/LiviPlayground.unity b/SSLR/Assets/Scenes/LiviPlayground.unity index f7614f0..f48ae20 100644 --- a/SSLR/Assets/Scenes/LiviPlayground.unity +++ b/SSLR/Assets/Scenes/LiviPlayground.unity @@ -4809,17 +4809,14 @@ MonoBehaviour: dayEnded: 0 shiftStarted: 0 currentNPC: {fileID: 0} - frontWalkPoints: - - {fileID: 1521924626} - - {fileID: 2036976913} - leftWalkPoints: - - {fileID: 950032348} - - {fileID: 397894338} - rightWalkPoints: - - {fileID: 2027209539} - - {fileID: 319260660} - leftWalkPointSet: {fileID: 2107051479} - rightWalkPointSet: {fileID: 1008392718} + initialStatementText: {fileID: 0} + playerQuestionOneText: {fileID: 0} + playerQuestionTwoText: {fileID: 0} + playerQuestionThreeText: {fileID: 0} + npcAnswerOneText: {fileID: 0} + npcAnswerTwoText: {fileID: 0} + npcAnswerThreeText: {fileID: 0} + playerResponse: {fileID: 0} --- !u!114 &520849217 MonoBehaviour: m_ObjectHideFlags: 0 @@ -4892,6 +4889,9 @@ MonoBehaviour: spawnPoints: - {fileID: 1126609777} npcBufferTime: 5 + Seats: + - SeatObject: {fileID: 0} + Available: 0 playerFree: 0 currentNpcs: [] despawnPoints: [] diff --git a/SSLR/Assets/Scripts/DeskButtons.cs b/SSLR/Assets/Scripts/DeskButtons.cs deleted file mode 100644 index c56c191..0000000 --- a/SSLR/Assets/Scripts/DeskButtons.cs +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Author: Livinia Poo - * Date: 29/1/25 - * Description: - * Managing behaviour of VR buttons at desk - */ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DeskButtons : MonoBehaviour -{ - NPCMovement npcMoveScript; - NPCBehaviour npcBehaviourScript; - private Player playerScript; - - public GameObject npcObject; - - private string correctDirection; - private string directionSent; - - void Start() - { - playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent(); - } - - void UpdateNPCReferences() - { - GameObject npcObject = GameManager.instance.currentNPC; - - if (npcObject != null) - { - npcMoveScript = npcObject.GetComponent(); - npcBehaviourScript = npcObject.GetComponent(); - } - } - - public void DirectToLeft() - { - UpdateNPCReferences(); - if (npcMoveScript == null || npcBehaviourScript == null) - { - Debug.LogWarning("NPC references are null"); - return; - } - - npcMoveScript.WalkToPlayerLeft(); - directionSent = "left"; - - if (npcBehaviourScript.navigationTxt.text == "I want to go left!") - { - correctDirection = "left"; - } - else - { - correctDirection = "right"; - } - - CheckCorrectDirection(); - } - - public void DirectToRight() - { - UpdateNPCReferences(); - if (npcMoveScript == null || npcBehaviourScript == null) - { - Debug.LogWarning("NPC references are null"); - return; - } - - npcMoveScript.WalkToPlayerRight(); - directionSent = "right"; - - if (npcBehaviourScript.navigationTxt.text == "I want to go right!") - { - correctDirection = "right"; - } - else - { - correctDirection = "left"; - } - - CheckCorrectDirection(); - - } - - void CheckCorrectDirection() - { - if (correctDirection == directionSent) - { - Player.score += 1; - Player.customersServed += 1; - Debug.Log("correct"); - Debug.Log(Player.score); - Debug.Log(Player.customersServed); - } - else - { - Player.score -= 1; - Player.customersServed += 1; - Debug.Log("incorrect"); - Debug.Log(Player.score); - Debug.Log(Player.customersServed); - } - } -} diff --git a/SSLR/Assets/Scripts/DeskButtons.cs.meta b/SSLR/Assets/Scripts/DeskButtons.cs.meta deleted file mode 100644 index e0f704f..0000000 --- a/SSLR/Assets/Scripts/DeskButtons.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8c6fa011a2b389049b558ccdf6b38c38 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SSLR/Assets/Scripts/NPCBehaviour.cs b/SSLR/Assets/Scripts/NPCBehaviour.cs deleted file mode 100644 index 81eb091..0000000 --- a/SSLR/Assets/Scripts/NPCBehaviour.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: Livinia Poo - * Date: 29/1/25 - * Description: - * Customer behaviour - */ - - -using System.Collections; -using System.Collections.Generic; -using TMPro; -using UnityEngine; - -public class NPCBehaviour : MonoBehaviour -{ - private NPCMovement npcMoveScript; - [SerializeField] private GameObject paperObject; - [SerializeField] private GameObject navigationTxtBubble; - [SerializeField] public TextMeshProUGUI navigationTxt; - - public static bool paperProduced; - - private string[] possibleSentences = - { - "I want to go left!", - "I want to go right!" - }; - - void Start() - { - npcMoveScript = GetComponent(); - - paperObject.SetActive(false); - navigationTxtBubble.SetActive(false); - - paperProduced = false; - - if (navigationTxt != null) - { - navigationTxt.text = GetRandomSentence(); - } - } - - void Update() - { - if (npcMoveScript.inFrontOfPlayer == true) - { - paperObject.SetActive(true); - navigationTxtBubble.SetActive(true); - - paperProduced = true; - } - } - - string GetRandomSentence() - { - int n = Random.Range(0, possibleSentences.Length); - return possibleSentences[n]; - } -} diff --git a/SSLR/Assets/Scripts/NPCBehaviour.cs.meta b/SSLR/Assets/Scripts/NPCBehaviour.cs.meta deleted file mode 100644 index 627f0e5..0000000 --- a/SSLR/Assets/Scripts/NPCBehaviour.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0063fdfa7f5e6c34581b4fd94accb6ff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SSLR/Assets/Scripts/NPCMovement.cs b/SSLR/Assets/Scripts/NPCMovement.cs deleted file mode 100644 index f2b1082..0000000 --- a/SSLR/Assets/Scripts/NPCMovement.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Author: Livinia Poo - * Date: 22/1/25 - * Description: - * Customer walking handling - */ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NPCMovement : MonoBehaviour -{ - /// - /// References and Variables - /// - /*public Transform[] frontWalkPoints; - public Transform[] leftWalkPoints; - public Transform[] rightWalkPoints;*/ - public float movementSpeed = 10.0f; - public float turnSpeed = 5.0f; - private int currentPtIndex = 0; - - /*[SerializeField] private GameObject leftWalkPointSet; - [SerializeField] private GameObject rightWalkPointSet;*/ - - public bool inFrontOfPlayer = false; - - private GameManager gm; - - /// - /// Start the coroutine - /// - void Start() - { - gm = GameManager.instance; - - StartCoroutine(WalkingToPlayer()); - } - - /// - /// - /// - public void WalkToPlayerLeft() - { - gm.leftWalkPointSet.SetActive(true); - StartCoroutine(WalkingToPlayerLeft()); - } - - public void WalkToPlayerRight() - { - gm.rightWalkPointSet.SetActive(true); - StartCoroutine(WalkingToPlayerRight()); - } - - /// - /// Coroutine for NPC to walk to each point - /// - /// - IEnumerator WalkingToPlayer() - { - while (currentPtIndex < gm.frontWalkPoints.Length) - { - if (gm.frontWalkPoints.Length == 0) - { - yield break; - } - - Transform targetPt = gm.frontWalkPoints[currentPtIndex]; - - Vector3 direction = targetPt.position - transform.position; - Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x,0,direction.z)); - - transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, turnSpeed * Time.deltaTime); - transform.position = Vector3.MoveTowards(transform.position, targetPt.position, movementSpeed * Time.deltaTime); - - if (Vector3.Distance(transform.position, targetPt.position) < 0.1f) - { - currentPtIndex++; - - if (currentPtIndex >= gm.frontWalkPoints.Length) - { - StopAllCoroutines(); - currentPtIndex = 0; - inFrontOfPlayer = true; - yield break; - } - } - - yield return null; - } - } - - /// - /// Coroutine for NPC to walk to each point - /// - /// - IEnumerator WalkingToPlayerLeft() - { - while (currentPtIndex < gm.leftWalkPoints.Length) - { - if (gm.leftWalkPoints.Length == 0) - { - yield break; - } - - Transform targetPt = gm.leftWalkPoints[currentPtIndex]; - - Vector3 direction = targetPt.position - transform.position; - Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x,0,direction.z)); - - transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, turnSpeed * Time.deltaTime); - transform.position = Vector3.MoveTowards(transform.position, targetPt.position, movementSpeed * Time.deltaTime); - - if (Vector3.Distance(transform.position, targetPt.position) < 0.1f) - { - currentPtIndex++; - - if (currentPtIndex >= gm.leftWalkPoints.Length) - { - StopAllCoroutines(); - currentPtIndex = 0; - yield break; - } - } - - yield return null; - } - } - - /// - /// Coroutine for NPC to walk to each point - /// - /// - IEnumerator WalkingToPlayerRight() - { - while (currentPtIndex < gm.rightWalkPoints.Length) - { - if (gm.rightWalkPoints.Length == 0) - { - yield break; - } - - Transform targetPt = gm.rightWalkPoints[currentPtIndex]; - - Vector3 direction = targetPt.position - transform.position; - Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x,0,direction.z)); - - transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, turnSpeed * Time.deltaTime); - transform.position = Vector3.MoveTowards(transform.position, targetPt.position, movementSpeed * Time.deltaTime); - - if (Vector3.Distance(transform.position, targetPt.position) < 0.1f) - { - currentPtIndex++; - - if (currentPtIndex >= gm.rightWalkPoints.Length) - { - StopAllCoroutines(); - currentPtIndex = 0; - yield break; - } - } - - yield return null; - } - } -} diff --git a/SSLR/Assets/Scripts/NPCMovement.cs.meta b/SSLR/Assets/Scripts/NPCMovement.cs.meta deleted file mode 100644 index 06bd36d..0000000 --- a/SSLR/Assets/Scripts/NPCMovement.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ee1f54676195faf4ba8ba4d5e99b916f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/SSLR/Assets/Scripts/NPCMovementRework.cs b/SSLR/Assets/Scripts/NPCMovementRework.cs index 7d864b1..9c5afa4 100644 --- a/SSLR/Assets/Scripts/NPCMovementRework.cs +++ b/SSLR/Assets/Scripts/NPCMovementRework.cs @@ -72,11 +72,11 @@ public class NpcMovementRework : MonoBehaviour public IEnumerator SitDown() { - var i = Random.Range(0, NpcManager.instance.Seats.Count); + var i = Random.Range(0, NpcManager.instance.Seats.Length); var seat = NpcManager.instance.Seats[i]; while (!seat.Available) { - i = Random.Range(0, NpcManager.instance.Seats.Count); + i = Random.Range(0, NpcManager.instance.Seats.Length); seat = NpcManager.instance.Seats[i]; } diff --git a/SSLR/Assets/Scripts/NpcManager.cs b/SSLR/Assets/Scripts/NpcManager.cs index 3e2cf2b..78fb56e 100644 --- a/SSLR/Assets/Scripts/NpcManager.cs +++ b/SSLR/Assets/Scripts/NpcManager.cs @@ -48,7 +48,9 @@ public class NpcManager : MonoBehaviour /// float for time between npc spawns /// [SerializeField] private float npcBufferTime; - + + public Seat[] Seats; + /// /// a bool to check if the player is free /// @@ -58,10 +60,7 @@ public class NpcManager : MonoBehaviour /// collection of all exiting npcs /// public List currentNpcs; - /// - /// a collection of positions for the chairs to sit for the npcs - /// - public GameObject[] chairPositions; + /// /// a collection of positions for the npcs to despawn /// @@ -136,4 +135,10 @@ public class NpcManager : MonoBehaviour } isSpawning = false; } + [Serializable] + public struct Seat + { + public GameObject SeatObject; + public bool Available; + } }