From d7e0577c4234f3f2b213693c8232050d09890393 Mon Sep 17 00:00:00 2001 From: kookiekenobi Date: Wed, 29 Jan 2025 05:02:18 +0800 Subject: [PATCH] game: added randomized debug dialogue --- SSLR/Assets/Scenes/LiviPlayground.unity | 7 ++++--- SSLR/Assets/Scripts/NPCBehaviour.cs | 27 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/SSLR/Assets/Scenes/LiviPlayground.unity b/SSLR/Assets/Scenes/LiviPlayground.unity index 00601cf..9f7ce8f 100644 --- a/SSLR/Assets/Scenes/LiviPlayground.unity +++ b/SSLR/Assets/Scenes/LiviPlayground.unity @@ -900,7 +900,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: paperObject: {fileID: 1179830388} - navigationTxt: {fileID: 32539959} + navigationTxtBubble: {fileID: 32539959} + navigationTxt: {fileID: 726703123} --- !u!1 &711059148 GameObject: m_ObjectHideFlags: 0 @@ -1024,7 +1025,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: I want to go left! + m_text: m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -1264,7 +1265,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1179830389 Transform: m_ObjectHideFlags: 0 diff --git a/SSLR/Assets/Scripts/NPCBehaviour.cs b/SSLR/Assets/Scripts/NPCBehaviour.cs index 5a3ed6d..b197e37 100644 --- a/SSLR/Assets/Scripts/NPCBehaviour.cs +++ b/SSLR/Assets/Scripts/NPCBehaviour.cs @@ -8,28 +8,47 @@ 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 navigationTxt; + [SerializeField] private GameObject navigationTxtBubble; + [SerializeField] TextMeshProUGUI navigationTxt; + + private string[] possibleSentences = + { + "I want to go left!", + "I want to go right!" + }; void Start() { npcMoveScript = GetComponent(); paperObject.SetActive(false); - navigationTxt.SetActive(false); + navigationTxtBubble.SetActive(false); + + if (navigationTxt != null) + { + navigationTxt.text = GetRandomSentence(); + } } void Update() { if (npcMoveScript.inFrontOfPlayer == true) { - paperObject.SetActive(true); - navigationTxt.SetActive(true); + //paperObject.SetActive(true); + navigationTxtBubble.SetActive(true); } } + + string GetRandomSentence() + { + int n = Random.Range(0, possibleSentences.Length); + return possibleSentences[n]; + } }