Advertisement
evelynshilosky

NPC - Part 27

Dec 12th, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6.  
  7. public class NPC : MonoBehaviour
  8. {
  9.  
  10.     public bool playerInRange;
  11.  
  12.     public bool isTalkingWithPlayer;
  13.  
  14.  
  15.  
  16.     private void OnTriggerEnter(Collider other)
  17.     {
  18.         if (other.CompareTag("Player"))
  19.         {
  20.             playerInRange = true;
  21.         }
  22.     }
  23.  
  24.     private void OnTriggerExit(Collider other)
  25.     {
  26.         if (other.CompareTag("Player"))
  27.         {
  28.             playerInRange = false;
  29.         }
  30.     }
  31.  
  32.     public void StartConversation()
  33.     {
  34.         isTalkingWithPlayer = true;
  35.  
  36.         print("Conversation Started");
  37.  
  38.         DialogueSystem.Instance.OpenDialogueUI();
  39.         DialogueSystem.Instance.dialogueText.text = "Hello There";
  40.         DialogueSystem.Instance.option1BTN.transform.Find("Text (TMP)").GetComponent<TextMeshProUGUI>().text = "Bye";
  41.         DialogueSystem.Instance.option1BTN.onClick.AddListener(() => {
  42.             DialogueSystem.Instance.CloseDialogueUI();
  43.             isTalkingWithPlayer = false;
  44.         });
  45.  
  46.  
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement