diff --git a/Assets/Graphics/Thumbs.db b/Assets/Graphics/Thumbs.db new file mode 100644 index 0000000..3f2ecd5 Binary files /dev/null and b/Assets/Graphics/Thumbs.db differ diff --git a/Assets/Graphics/Foreground/Thumbs.db.meta b/Assets/Graphics/Thumbs.db.meta similarity index 64% rename from Assets/Graphics/Foreground/Thumbs.db.meta rename to Assets/Graphics/Thumbs.db.meta index f8140a6..9942473 100644 --- a/Assets/Graphics/Foreground/Thumbs.db.meta +++ b/Assets/Graphics/Thumbs.db.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: cb37ca3d5df44164a97b4a47dc05d185 -timeCreated: 1458864715 +guid: 36a6239b6e4209947924ec74cdc1e7f5 +timeCreated: 1459328380 licenseType: Free DefaultImporter: userData: diff --git a/Assets/Scenes/GenerationTestScene.unity b/Assets/Scenes/GenerationTestScene.unity index 498b681..51a698d 100644 Binary files a/Assets/Scenes/GenerationTestScene.unity and b/Assets/Scenes/GenerationTestScene.unity differ diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity index c1617ce..672aa4a 100644 Binary files a/Assets/Scenes/TestScene.unity and b/Assets/Scenes/TestScene.unity differ diff --git a/Assets/Scripts/TextBoxManager.cs b/Assets/Scripts/TextBoxManager.cs new file mode 100644 index 0000000..d3b905f --- /dev/null +++ b/Assets/Scripts/TextBoxManager.cs @@ -0,0 +1,93 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.UI; + +public class TextBoxManager : MonoBehaviour +{ + /** + For a text box to simulate a conversation between two characters. + + Things that need to be specified: + - names of the first and second speaker. + - file that contains the dialogue. + + In the text file, format should look something like: + Zimri: Hello. + NPC: I must go. + Good bye! + Zimri: Have a nice day. + If a speaker has more than one line, you can include the speaker's name in each + line after the first, but it is not necessary. + See sampledialogue.txt for an example. + **/ + + public GameObject textBox; + + public Text thedialogue; + + public TextAsset dialogue; + public string[] dialoguelines; + + int currentLine = 0; + int endAtLine; + public string firstCharacter; + public string secondCharacter; + bool firstSpeaker = true; + + // Use this for initialization + void Start() + { + //Each line in the text file stored into dialogueLines. + if (dialogue != null) + { + dialoguelines = (dialogue.text.Split('\n')); + } + + if (endAtLine == 0) + { + endAtLine = dialoguelines.Length - 1; + } + } + + // Update is called once per frame + void Update() + { + //Detects a change in speaker. + if (dialoguelines[currentLine].Contains(firstCharacter)) + { + firstSpeaker = true; + } + + if (dialoguelines[currentLine].Contains(secondCharacter)) + { + firstSpeaker = false; + } + + //Text color changes depending on speaker. + if (firstSpeaker == true) + { + thedialogue.color = Color.red; + } + else + { + thedialogue.color = Color.blue; + } + + //Display line. + thedialogue.text = dialoguelines[currentLine]; + + //Press U for next line. + if (Input.GetKeyDown(KeyCode.U)) + { + currentLine += 1; + } + + //Text box disappears after all lines have been spoken. + if (currentLine > endAtLine) + { + textBox.SetActive(false); + } + + + } +} diff --git a/Assets/Scripts/TextBoxManager.cs.meta b/Assets/Scripts/TextBoxManager.cs.meta new file mode 100644 index 0000000..14483ff --- /dev/null +++ b/Assets/Scripts/TextBoxManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 885b4f12cefee944d9fa639afb46fa2d +timeCreated: 1459326703 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Text/sampleDialogue.txt b/Assets/Text/sampleDialogue.txt new file mode 100644 index 0000000..a09e5d1 --- /dev/null +++ b/Assets/Text/sampleDialogue.txt @@ -0,0 +1,5 @@ +Zimri: Hello. +NPC: Good morning. +Zimri: Good bye. +NPC: Wish you well. +Have a nice day! \ No newline at end of file diff --git a/Assets/Text/sampleDialogue.txt.meta b/Assets/Text/sampleDialogue.txt.meta new file mode 100644 index 0000000..1c1af96 --- /dev/null +++ b/Assets/Text/sampleDialogue.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c4fe8c35f50158f4b93a08b808e465ef +timeCreated: 1459360583 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index e7d4ce8..7c0ac3c 100644 Binary files a/ProjectSettings/GraphicsSettings.asset and b/ProjectSettings/GraphicsSettings.asset differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index a64d8c7..621cb81 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index d0aa952..bb60c06 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.3.2p1 +m_EditorVersion: 5.3.2f1 m_StandardAssetsVersion: 0 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 603e796..a9a39c4 100644 Binary files a/ProjectSettings/QualitySettings.asset and b/ProjectSettings/QualitySettings.asset differ