60 lines
1.3 KiB
C#
60 lines
1.3 KiB
C#
/*
|
|
* 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<NPCMovement>();
|
|
|
|
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];
|
|
}
|
|
}
|