1
0
This commit is contained in:
MoMack20 2016-01-31 04:32:52 -05:00
commit cf1f714343
13 changed files with 130 additions and 23 deletions

View File

@ -0,0 +1,65 @@
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.K))
{
theTextBox.ReloadScript(theText);
theTextBox.currentLine = startLine;
theTextBox.endAtLine = endLine;
theTextBox.EnableTextBox();
if (destroyWhenActivated)
Destroy(gameObject);
}
}
void OnTriggerEnter2d(Collider2D other)
{
if (other.name == "player")
{
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 == "player") // going to change this with checking for a layer instead.
waitForPress = false;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 985b3be85d140e34bbb0d9eaa2612379
timeCreated: 1454227733
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 67f32f2ed28878c449691b538a289a10
timeCreated: 1454220581
timeCreated: 1454222316
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
@ -26,11 +26,11 @@ TextureImporter:
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
@ -43,8 +43,8 @@ TextureImporter:
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
spriteBorder: {x: 109, y: 234, z: 154, w: 134}
spritePixelsToUnits: 64
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []

View File

@ -4,10 +4,10 @@ using UnityEngine.UI;
public class TextBoxManager : MonoBehaviour {
public GameObject textBox;
public Text theText;
public GameObject textBox; //This is the "panel" that is needed for the "dialog box"
public Text theText; //This is the "text" section of the Panel box, for rendering text
public TextAsset textfile;
public TextAsset textfile; //Whichever textfile that is needed to be "rendered" on the screen.
public string[] textLines;
public int currentLine;
@ -22,26 +22,20 @@ public class TextBoxManager : MonoBehaviour {
// Use this for initialization
void Start()
{
player = FindObjectOfType<PlayerCharacter>();
player = FindObjectOfType<PlayerCharacter>(); //What ever you are using is what you should be "finding"
if (textfile != null)
{
textLines = (textfile.text.Split('\n'));
}
if (endAtLine == 0)
{
endAtLine = textLines.Length - 1;
}
if(isActive)
{
EnableTextBox();
}
else
{
DisableTextBox();
}
}
@ -52,7 +46,7 @@ public class TextBoxManager : MonoBehaviour {
theText.text = textLines[currentLine];
if (Input.GetKeyDown(KeyCode.Space))
if (Input.GetKeyDown(KeyCode.K))
currentLine++;
if (currentLine > endAtLine)
@ -62,6 +56,7 @@ public class TextBoxManager : MonoBehaviour {
public void EnableTextBox()
{
textBox.SetActive(true);
isActive = true;
if (stopPlayerMovement)
player.canMove = false;
@ -71,5 +66,16 @@ public class TextBoxManager : MonoBehaviour {
{
textBox.SetActive(false); //Once we get to the end of the "lines" we turn off the text block.
player.canMove = true;
isActive = false;
}
public void ReloadScript(TextAsset theText)
{
if (theText != null) //making sure there is a file being passed in.
{
textLines = new string[1]; //take the array that already exists, remove it, and starts to fill it in with a new one....
textLines = (theText.text.Split('\n'));
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0ca9e5973d5c46441aa9b7f296afd5f5
timeCreated: 1454227455
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e51230ed0b5d7a04589b7966e997d519
timeCreated: 1454226152
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d2869984de847554e868d28f5163f916
timeCreated: 1454227456
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant: