Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using TMPro;
  7.  
  8.  
  9.  
  10. public class Dialogue : MonoBehaviour {
  11.  
  12. public string[] convo;
  13.  
  14. bool started = false;
  15. int convoPiece = 0;
  16.  
  17. public GameObject dialogueBox;
  18. public TMP_Text textBox;
  19.  
  20. public Image benjaminImage;
  21. public Image npcImage;
  22.  
  23. void Update()
  24. {
  25. if(Input.GetButtonDown("Fire1") && PlayerActions.instance.isChat && !started)
  26. {
  27. StartConvo();
  28. started = true;
  29. }
  30. else if (Input.GetButtonDown("Fire1") && PlayerActions.instance.isChat && started)
  31. {
  32. if(convoPiece >= convo.Length)
  33. {
  34. EndConvo();
  35. }
  36. else
  37. {
  38. ContinueConvo();
  39. }
  40. }
  41. }
  42.  
  43. void OnTriggerStay(Collider other)
  44. {
  45. if (other.tag == "Player")
  46. {
  47. PlayerActions.instance.isChat = true;
  48. }
  49. }
  50.  
  51. void OnTriggerExit(Collider other)
  52. {
  53. if (other.tag == "Player")
  54. {
  55. EndConvo();
  56. PlayerActions.instance.isChat = false;
  57. }
  58. }
  59.  
  60. void StartConvo() // Is Benjamin good or evil? Which stage of game?
  61. {
  62.  
  63. convoPiece = 0;
  64. dialogueBox.SetActive(true);
  65. textBox.text = this.convo[convoPiece];
  66. convoPiece++;
  67. // Change the Images
  68. }
  69. void ContinueConvo() // Is Benjamin good or evil? Which stage of game?
  70. {
  71. textBox.text = this.convo[convoPiece];
  72. convoPiece++;
  73. // Change the Images
  74. }
  75.  
  76. void EndConvo()
  77. {
  78. started = false;
  79. //Array.Clear(convo,0,convo.Length);
  80. dialogueBox.SetActive(false);
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement