Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.IO;
  9.  
  10. public class DialogueParser : MonoBehaviour {
  11.  
  12. public List<LineComponents> lines;
  13.  
  14. public struct LineComponents
  15. {
  16. public string name;
  17. public string words;
  18. public int pose;
  19.  
  20. public LineComponents(string getName, string getWords, int getPose)
  21. {
  22. name = getName;
  23. words = getWords;
  24. pose = getPose;
  25. }
  26. }
  27.  
  28. public TextAsset openDialogue;
  29.  
  30. public string[] readers;
  31.  
  32. private DialogueDisplay dialogueDisplay;
  33.  
  34. void Start()
  35. {
  36. dialogueDisplay = GameObject.Find("Canvas").GetComponent<DialogueDisplay>();
  37. lines = new List<LineComponents>();
  38. }
  39.  
  40. void Update()
  41. {
  42. BuildDialogue();
  43. }
  44.  
  45. void BuildDialogue()
  46. {
  47. readers = dialogueDisplay.currentString.Split('#');
  48. LineComponents entries = new LineComponents(readers[0], readers[1],
  49. int.Parse(readers[2]));
  50. lines.Add(entries);
  51.  
  52.  
  53. }
  54.  
  55. //for displaying name, dialogue, and pose
  56. public string GetName(int lineNumber)
  57. {
  58. return lines[lineNumber].name;
  59. }
  60. public string GetWords(int lineNumber)
  61. {
  62. return lines[lineNumber].words;
  63. }
  64. /*public int GetPose(int lineNumber)
  65. {
  66. if (lineNumber < lines.Count)
  67. {
  68. return lines[lineNumber].pose;
  69. }
  70. else return 0;
  71. }*/
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement