Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [System.Serializable]
- public class dialogueLineCouplet
- {
- [Tooltip("This is the line that the character says to you.")]
- public string replyLine;
- public DialogueEntry replyEntry;
- [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.")]
- public string replyAddress;
- [Tooltip("A token to check in order for this line to appear. Leave the token name empty and it'll always show up.")]
- public tokenCondition condition;
- }
- [System.Serializable]
- public class characterReply
- {
- public string replyLine;
- public AudioClip soundClip;
- [Tooltip("A token to check in order for this line to appear. Leave the token name empty and it'll always show up.")]
- public tokenCondition condition;
- }
- [System.Serializable]
- public class DialogueEntry
- {
- public string entryPlayerLine;
- public List<characterReply> possibleCharacterReplies;
- public AudioClip soundClip;
- public List<dialogueLineCouplet> playerReplies;
- public List<string> eventsToFire;
- public string entryAddress;
- }
- [System.Serializable]
- public class DialogueContainer
- {
- public bool canExit;
- public string dialogueTitle;
- public string playerName = "You";
- public string characterName = "Them";
- public DialogueEntry dialogueHead;
- public DialogueEntry getEntryByAddress(string searchAddress)
- {
- return getEntryByAddress(searchAddress, dialogueHead);
- }
- public DialogueEntry getEntryByAddress(string searchAddress, DialogueEntry head)
- {
- DialogueEntry tempEntry;
- if (head.entryAddress == searchAddress)
- return head;
- else
- {
- foreach (dialogueLineCouplet dlc in head.playerReplies)
- {
- 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)
- {
- tempEntry = getEntryByAddress(searchAddress, dlc.replyEntry);
- if (tempEntry != null)
- return tempEntry;
- }
- }
- //we've iterated through the branches to no avail, return null
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement