Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ItemDialouge : MonoBehaviour
- {
- public GameObject TextBox;
- public Text Dialouge;
- public string[] ChatArray;
- private int index;
- private bool MyBool;
- private PlayerMovement Simon;
- private void OnTriggerEnter2D(Collider2D collision)
- {
- MyBool = true;
- Simon = collision.gameObject.GetComponent<PlayerMovement>();
- index = 0;
- Dialouge.text = ChatArray[index];
- }
- private void OnTriggerExit2D(Collider2D collision)
- {
- MyBool = false;
- index = 0;
- }
- void Start()
- {
- TextBox.SetActive(false);
- }
- public void Update()
- {
- Dialouge.text = ChatArray[index];
- if(MyBool == true)
- {
- if (Input.GetKeyDown("e"))
- {
- Time.timeScale = 0;
- TextBox.SetActive(true);
- Simon.moveSpeed = 0;
- index = 0;
- Dialouge.text = ChatArray[index];
- }
- if (Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.Space))
- {
- index ++;
- Dialouge.text = ChatArray[index];
- }
- if (index >= ChatArray.Length)
- {
- Simon.moveSpeed = 5;
- index = 0;
- TextBox.SetActive(false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement