Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. [System.Serializable]
  7. public class dialogueLineCouplet
  8. {
  9. [Tooltip("This is the line that the character says to you.")]
  10. public string replyLine;
  11. public DialogueEntry replyEntry;
  12. [Tooltip("If you fill in an address here, it'll point to the line in the dialogue tree with that address instead of using a brand new entry. Use this to add loops to your tree.")]
  13. public string replyAddress;
  14. [Tooltip("A token to check in order for this line to appear. Leave the token name empty and it'll always show up.")]
  15. public tokenCondition condition;
  16. }
  17.  
  18. [System.Serializable]
  19. public class characterReply
  20. {
  21. public string replyLine;
  22. public AudioClip soundClip;
  23. [Tooltip("A token to check in order for this line to appear. Leave the token name empty and it'll always show up.")]
  24. public tokenCondition condition;
  25. }
  26.  
  27. [System.Serializable]
  28. public class DialogueEntry
  29. {
  30. public string entryPlayerLine;
  31. public List<characterReply> possibleCharacterReplies;
  32. public AudioClip soundClip;
  33. public List<dialogueLineCouplet> playerReplies;
  34. public List<string> eventsToFire;
  35. public string entryAddress;
  36.  
  37.  
  38. }
  39.  
  40. [System.Serializable]
  41. public class DialogueContainer
  42. {
  43.  
  44. public bool canExit;
  45. public string dialogueTitle;
  46. public string playerName = "You";
  47. public string characterName = "Them";
  48.  
  49. public DialogueEntry dialogueHead;
  50.  
  51. public DialogueEntry getEntryByAddress(string searchAddress)
  52. {
  53. return getEntryByAddress(searchAddress, dialogueHead);
  54. }
  55.  
  56. public DialogueEntry getEntryByAddress(string searchAddress, DialogueEntry head)
  57. {
  58. DialogueEntry tempEntry;
  59. if (head.entryAddress == searchAddress)
  60. return head;
  61. else
  62. {
  63. foreach (dialogueLineCouplet dlc in head.playerReplies)
  64. {
  65. if ((dlc.replyEntry != null) && (dlc.replyAddress == "")) //there is an entry to drill into and it's not trying to simply reference another branch of the tree by address reference (which could lead to infinite recursion, stack overflow, etc)
  66. {
  67. tempEntry = getEntryByAddress(searchAddress, dlc.replyEntry);
  68. if (tempEntry != null)
  69. return tempEntry;
  70. }
  71. }
  72. //we've iterated through the branches to no avail, return null
  73. return null;
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement