diff --git a/Assets/Dusty Char/ActivateTextAtLine.cs b/Assets/Dusty Char/ActivateTextAtLine.cs new file mode 100644 index 0000000..5d5cdea --- /dev/null +++ b/Assets/Dusty Char/ActivateTextAtLine.cs @@ -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(); + + } + + // 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; + + } +} diff --git a/Assets/Dusty Char/ActivateTextAtLine.cs.meta b/Assets/Dusty Char/ActivateTextAtLine.cs.meta new file mode 100644 index 0000000..9e2aa56 --- /dev/null +++ b/Assets/Dusty Char/ActivateTextAtLine.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 985b3be85d140e34bbb0d9eaa2612379 +timeCreated: 1454227733 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Dusty Char/Art/DialogueBox.png.meta b/Assets/Dusty Char/Art/DialogueBox.png.meta index d85c22c..09c8dfd 100644 --- a/Assets/Dusty Char/Art/DialogueBox.png.meta +++ b/Assets/Dusty Char/Art/DialogueBox.png.meta @@ -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: [] diff --git a/Assets/Dusty Char/TextBoxManager.cs b/Assets/Dusty Char/TextBoxManager.cs index 52a24ef..b2a28c9 100644 --- a/Assets/Dusty Char/TextBoxManager.cs +++ b/Assets/Dusty Char/TextBoxManager.cs @@ -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(); + player = FindObjectOfType(); //What ever you are using is what you should be "finding" - if (textfile != null) - { + if (textfile != null) textLines = (textfile.text.Split('\n')); - } - - if (endAtLine == 0) - { - endAtLine = textLines.Length - 1; - } + + 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')); + } + } } diff --git a/Assets/Resources/Scenes/Level1.unity b/Assets/Resources/Scenes/Level1.unity index 8a95bcf..e943623 100644 Binary files a/Assets/Resources/Scenes/Level1.unity and b/Assets/Resources/Scenes/Level1.unity differ diff --git a/Assets/Sprites/PaperClip/Panel.controller b/Assets/Sprites/PaperClip/Panel.controller new file mode 100644 index 0000000..f5f58ac Binary files /dev/null and b/Assets/Sprites/PaperClip/Panel.controller differ diff --git a/Assets/Sprites/PaperClip/Panel.controller.meta b/Assets/Sprites/PaperClip/Panel.controller.meta new file mode 100644 index 0000000..abbebc3 --- /dev/null +++ b/Assets/Sprites/PaperClip/Panel.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e51230ed0b5d7a04589b7966e997d519 +timeCreated: 1454226152 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/PaperClip/PapeStationary_0.controller b/Assets/Sprites/PaperClip/PapeStationary_0.controller index e645783..fb91a45 100644 Binary files a/Assets/Sprites/PaperClip/PapeStationary_0.controller and b/Assets/Sprites/PaperClip/PapeStationary_0.controller differ