did most of the work for the dialog box's....still needs to be tweaked....fuuuuuuckkkkk
This commit is contained in:
parent
68d0ac9c37
commit
bba23c0d98
65
Assets/Dusty Char/ActivateTextAtLine.cs
Normal file
65
Assets/Dusty Char/ActivateTextAtLine.cs
Normal 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;
|
||||
|
||||
}
|
||||
}
|
12
Assets/Dusty Char/ActivateTextAtLine.cs.meta
Normal file
12
Assets/Dusty Char/ActivateTextAtLine.cs.meta
Normal 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:
|
@ -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: []
|
||||
|
@ -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)
|
||||
{
|
||||
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'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
BIN
Assets/Sprites/PaperClip/Panel.controller
Normal file
BIN
Assets/Sprites/PaperClip/Panel.controller
Normal file
Binary file not shown.
8
Assets/Sprites/PaperClip/Panel.controller.meta
Normal file
8
Assets/Sprites/PaperClip/Panel.controller.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e51230ed0b5d7a04589b7966e997d519
|
||||
timeCreated: 1454226152
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Reference in New Issue
Block a user