Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- public class Dialogue : MonoBehaviour {
- public string[] convo;
- bool started = false;
- int convoPiece = 0;
- public GameObject dialogueBox;
- public TMP_Text textBox;
- public Image benjaminImage;
- public Image npcImage;
- void Update()
- {
- if(Input.GetButtonDown("Fire1") && PlayerActions.instance.isChat && !started)
- {
- StartConvo();
- started = true;
- }
- else if (Input.GetButtonDown("Fire1") && PlayerActions.instance.isChat && started)
- {
- if(convoPiece >= convo.Length)
- {
- EndConvo();
- }
- else
- {
- ContinueConvo();
- }
- }
- }
- void OnTriggerStay(Collider other)
- {
- if (other.tag == "Player")
- {
- PlayerActions.instance.isChat = true;
- }
- }
- void OnTriggerExit(Collider other)
- {
- if (other.tag == "Player")
- {
- EndConvo();
- PlayerActions.instance.isChat = false;
- }
- }
- void StartConvo() // Is Benjamin good or evil? Which stage of game?
- {
- convoPiece = 0;
- dialogueBox.SetActive(true);
- textBox.text = this.convo[convoPiece];
- convoPiece++;
- // Change the Images
- }
- void ContinueConvo() // Is Benjamin good or evil? Which stage of game?
- {
- textBox.text = this.convo[convoPiece];
- convoPiece++;
- // Change the Images
- }
- void EndConvo()
- {
- started = false;
- //Array.Clear(convo,0,convo.Length);
- dialogueBox.SetActive(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement