From 839b4e32170c2a22c487360beeedb94fdaf4c42d Mon Sep 17 00:00:00 2001 From: Valtorix5 Date: Sun, 31 Jan 2016 14:45:21 -0500 Subject: [PATCH] worked on the dialog shit...for the third time. --- Assets/Dusty Char/ActivateTextAtLine.cs | 63 ++++++++++++++++++++ Assets/Dusty Char/ActivateTextAtLine.cs.meta | 12 ++++ Assets/Dusty Char/CharacterMovement.cs | 6 +- Assets/Dusty Char/TextBoxManager.cs | 23 ++++++- Assets/Dusty Char/TextImporter.cs | 4 +- 5 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 Assets/Dusty Char/ActivateTextAtLine.cs create mode 100644 Assets/Dusty Char/ActivateTextAtLine.cs.meta diff --git a/Assets/Dusty Char/ActivateTextAtLine.cs b/Assets/Dusty Char/ActivateTextAtLine.cs new file mode 100644 index 0000000..24b6f3b --- /dev/null +++ b/Assets/Dusty Char/ActivateTextAtLine.cs @@ -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(); + + } + + // 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; + } + +} diff --git a/Assets/Dusty Char/ActivateTextAtLine.cs.meta b/Assets/Dusty Char/ActivateTextAtLine.cs.meta new file mode 100644 index 0000000..808fdc4 --- /dev/null +++ b/Assets/Dusty Char/ActivateTextAtLine.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9d3a91edf675e3440aee1f05323b59db +timeCreated: 1454260365 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Dusty Char/CharacterMovement.cs b/Assets/Dusty Char/CharacterMovement.cs index bf5b611..b515bdd 100644 --- a/Assets/Dusty Char/CharacterMovement.cs +++ b/Assets/Dusty Char/CharacterMovement.cs @@ -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; diff --git a/Assets/Dusty Char/TextBoxManager.cs b/Assets/Dusty Char/TextBoxManager.cs index 52a24ef..559f4c7 100644 --- a/Assets/Dusty Char/TextBoxManager.cs +++ b/Assets/Dusty Char/TextBoxManager.cs @@ -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(); + player = FindObjectOfType(); // 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')); + + } + } } diff --git a/Assets/Dusty Char/TextImporter.cs b/Assets/Dusty Char/TextImporter.cs index bf86c24..ec79ad7 100644 --- a/Assets/Dusty Char/TextImporter.cs +++ b/Assets/Dusty Char/TextImporter.cs @@ -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