1
0
This repository has been archived on 2024-09-03. You can view files and clone it, but cannot push or open issues or pull requests.
System-Purge/Assets/Dusty Char/ActivateTextAtLine.cs

64 lines
1.5 KiB
C#

using UnityEngine;
using System.Collections;
public class ActivateTextAtLine : MonoBehaviour {
public TextAsset theText;
public int startLine;
public int endLine;
public TextBoxManager theTextBox;
public bool destroyWhenActivated;
public bool requireButtonPress;
private bool waitForPress;
// Use this for initialization
void Start () {
theTextBox = FindObjectOfType<TextBoxManager>();
}
// Update is called once per frame
void Update () {
if(waitForPress && Input.GetKeyDown(KeyCode.J))
{
theTextBox.ReloadScript(theText);
theTextBox.currentLine = startLine;
theTextBox.endAtLine = endLine;
theTextBox.EnableTextBox();
if (destroyWhenActivated)
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "CharacterRobotBoy") //need to do object type instead for "better purposes"
{
if(requireButtonPress)
{
waitForPress = true;
return;
}
theTextBox.ReloadScript(theText);
theTextBox.currentLine = startLine;
theTextBox.endAtLine = endLine;
theTextBox.EnableTextBox();
if (destroyWhenActivated)
Destroy(gameObject);
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.name == "CharacterRobotBoy")
waitForPress = false;
}
}