diff --git a/SSLR/Assets/Scripts/NPCMovementRework.cs b/SSLR/Assets/Scripts/NPCMovementRework.cs index 05021cd..c06a56d 100644 --- a/SSLR/Assets/Scripts/NPCMovementRework.cs +++ b/SSLR/Assets/Scripts/NPCMovementRework.cs @@ -21,6 +21,7 @@ public class NpcMovementRework : MonoBehaviour /// Animation assigning /// public Animator animator; + private static readonly int IsSitting = Animator.StringToHash("isSitting"); private static readonly int Speed = Animator.StringToHash("Speed"); @@ -28,6 +29,7 @@ public class NpcMovementRework : MonoBehaviour /// NPC's dialogue variables /// public TextMeshProUGUI npcWelcomeText; + public TextMeshProUGUI initialStatementText; public TextMeshProUGUI npcAnswerOneText; public TextMeshProUGUI npcAnswerTwoText; @@ -41,7 +43,7 @@ public class NpcMovementRework : MonoBehaviour /// NPC Data referemce /// public NpcData npcData; - + /// /// Variable to store service /// @@ -74,54 +76,33 @@ public class NpcMovementRework : MonoBehaviour npcSpeechBubble.SetActive(false); npcAnswerPanel.SetActive(false); StartCoroutine(SitDown()); - } - /// - /// Call coroutine to call client - /// - public void Called() - { - StartCoroutine(CustomerCalled()); - } /// /// Coroutine to get NPC to coe to table /// - /// - public IEnumerator CustomerCalled() + public void CustomerCalled() { animator.SetBool(IsSitting, false); var pos = NpcManager.instance.desk; agent.SetDestination(pos.position); - while (true) - { - var npcpos = gameObject.transform.position; - npcpos.y = 0; - var dist = Vector3.Distance(pos.position, npcpos); + var npcpos = gameObject.transform.position; + npcpos.y = 0; + } - if (dist < 1.0f) - { - agent.SetDestination(gameObject.transform.position); - gameObject.transform.rotation = pos.transform.rotation; + public void Stop() + { + agent.SetDestination(gameObject.transform.position); + GameManager.instance.SetCurrentNPC(this.gameObject); - GameManager.instance.SetCurrentNPC(this.gameObject); + npcSpeechBubble.SetActive(true); + npcAnswerPanel.SetActive(true); + PlayerDialogueInteraction.instance.playerDialogue.SetActive(true); + correctService = npcData.correctDepartment; - npcSpeechBubble.SetActive(true); - npcAnswerPanel.SetActive(true); - PlayerDialogueInteraction.instance.playerDialogue.SetActive(true); - - yield return new WaitUntil(() => npcData != null); - - correctService = npcData.correctDepartment; - - LoadNPCDialogue(); - break; - } - - yield return 0; - } + LoadNPCDialogue(); } @@ -139,10 +120,10 @@ public class NpcMovementRework : MonoBehaviour seat = NpcManager.instance.Seats[i]; yield return new WaitForSeconds(2f); } - + seat.Available = false; var sittingPosition = seat.SeatObject.transform.position; - + agent.SetDestination(sittingPosition); Debug.Log("Sitting down"); while (true) @@ -160,7 +141,7 @@ public class NpcMovementRework : MonoBehaviour yield return 0; } } - + /// /// Despawning NPCs diff --git a/SSLR/Assets/Scripts/NextButton.cs b/SSLR/Assets/Scripts/NextButton.cs index 927fe05..769c561 100644 --- a/SSLR/Assets/Scripts/NextButton.cs +++ b/SSLR/Assets/Scripts/NextButton.cs @@ -20,7 +20,7 @@ public class NextButton : MonoBehaviour var randomnpc = npcs[Random.Range(0, npcs.Count)]; GameManager.instance.SetCurrentNPC(randomnpc); - randomnpc.GetComponent().Called(); + randomnpc.GetComponent().CustomerCalled(); PlayerDialogueInteraction.instance.ResetChecklist(); PlayerDialogueInteraction.instance.ResetDialogue(); diff --git a/SSLR/Assets/Scripts/TableCollider.cs b/SSLR/Assets/Scripts/TableCollider.cs new file mode 100644 index 0000000..f1e2ab7 --- /dev/null +++ b/SSLR/Assets/Scripts/TableCollider.cs @@ -0,0 +1,14 @@ + +using System; +using UnityEngine; + +public class TableCollider : MonoBehaviour +{ + private void OnTriggerEnter(Collider other) + { + if (other.CompareTag("NPC")) + { + other.GetComponent().Stop(); + } + } +} diff --git a/SSLR/Assets/Scripts/TableCollider.cs.meta b/SSLR/Assets/Scripts/TableCollider.cs.meta new file mode 100644 index 0000000..a6c36d5 --- /dev/null +++ b/SSLR/Assets/Scripts/TableCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ed21d83f6d63754aad737a383513a18 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: