1
0
This commit is contained in:
CoryAlanDavis 2016-01-31 14:56:27 -05:00
commit 4fbed299e2
8 changed files with 100 additions and 8 deletions

View File

@ -0,0 +1,63 @@
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;
}
}

View File

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

View File

@ -62,7 +62,7 @@ public class CharacterMovement : MonoBehaviour {
// transform.eulerAngles = new Vector2(0, 180);
//}
if (Input.GetKeyDown(KeyCode.T))
if (Input.GetKeyDown(KeyCode.E))
{
powerTeleport();
}
@ -76,7 +76,7 @@ public class CharacterMovement : MonoBehaviour {
canPass = true;
}
if (Input.GetKeyDown(KeyCode.P))
if (Input.GetKeyDown(KeyCode.Q))
{
if(SceneManager.GetActiveScene().name == "GMLevel1")
{
@ -89,7 +89,7 @@ public class CharacterMovement : MonoBehaviour {
}
if (Input.GetKeyDown(KeyCode.G))
if (Input.GetKeyDown(KeyCode.R))
{
if (changeBox == true)
changeBox = false;

View File

@ -1,6 +1,8 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityStandardAssets._2D;
public class TextBoxManager : MonoBehaviour {
@ -12,7 +14,10 @@ public class TextBoxManager : MonoBehaviour {
public int currentLine;
public int endAtLine;
public PlayerCharacter player;
//public PlatformerCharacter2D player; // Need to wait till don gets here to figure out what we did the first time....
//public PlayerCharacter player;
//public PlatformerCharacter2D player;
public Platformer2DUserControl player;
public bool isActive;
public bool stopPlayerMovement;
@ -22,7 +27,7 @@ public class TextBoxManager : MonoBehaviour {
// Use this for initialization
void Start()
{
player = FindObjectOfType<PlayerCharacter>();
player = FindObjectOfType<Platformer2DUserControl>(); // need to change...again....(i think platformer2dusercontrol)
if (textfile != null)
{
@ -52,7 +57,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 +67,7 @@ public class TextBoxManager : MonoBehaviour {
public void EnableTextBox()
{
textBox.SetActive(true);
isActive = true;
if (stopPlayerMovement)
player.canMove = false;
@ -70,6 +76,17 @@ public class TextBoxManager : MonoBehaviour {
public void DisableTextBox()
{
textBox.SetActive(false); //Once we get to the end of the "lines" we turn off the text block.
isActive = false;
player.canMove = true;
}
public void ReloadScript(TextAsset theText)
{
if(theText != null)
{
textLines = new string[1];
textLines = (theText.text.Split('\n'));
}
}
}

View File

@ -3,8 +3,8 @@ using System.Collections;
public class TextImporter : MonoBehaviour {
public TextAsset textfile;
public string[] textLines;
public TextAsset textfile; //A block of text that will be "put" into the box.
public string[] textLines; //An array of lines that will be put on screen line by line.
// Use this for initialization

Binary file not shown.

Binary file not shown.

Binary file not shown.