(use ctrl-f)
This is the button you want to use to interact with npcs/items/etc/whatever will have dialog
Holds an image to be displayed when your character is close enough to the speaker to initaite conversation
The canvas that holds the speech UI. Stored as a gameObject to be turned off/on when needed
this is the string that holds the name of the speaker
Takes a UnityUI Text GameObject that will display the speaker's name, if applicable
Takes a UnityUI Sprite GameObject that will display an image depicting the speaker, if applicable
Takes a UnityUI Image Gameobject that will provide the image to the speakerSprite object to display, if applicable
Indicates whether you have pressed the action button when you are within interaction range with a speaker. The range can be modified by changing the sphere collider's radius on the *speaker*'s VoiceBox
a boolean indicating whether or not the *speaker*'s dialog has completed
Takes a UnityUI Text GameObject that will display the dialog text
Holds an image to be displayed when the *speaker*'s sentences has ended, indicating to push the action button to continue
This is a list of SentenceHolders that will hold the dialog for the speaker to display
these are the sentences held by the speaker to be displayed to screen these are passed from the more general dialog holder (SentenceHolder) into their own array for individual processing
the index of the current sentence in the sentence array
the length in seconds of the delay between letters typed to screen
a copy of the typing delay speed is stored for when the sentence speed is temporarily changed to display it all at once (when action is pressed during display)
Points to a dialog object inside the dialog asset
Used to compare the displayed string to the user-given string. They are compared to see if the sentence has been displayed fully.
Used for checking vowels in the string processinhg
the variable that the user selects to indicate which sound mode from the SoundModes enum is selected
The index in the SoundMode enum that is selected by the user
These are the musical scales used for the voice. Scales can be added by adding their intervals to the scales array bellow Once the intervals have been added, the scale should be added here with its index correspoding to its intervals index in the scales array
the variable that the user selects to indicate which scale from the MusicScales enum is selected
The index in the vocalScale enum that is selected by the user
An int list that holds interval values for a scale
This is the list of chromatic notes starting with C and going up an octave
The index of the selected root note in the RootNotes enum
the index of the selected play style from the enum PlayStyles
the string that will hold the "start" tag for rich text example... <color=red>
the string that will hold the "closing" tag for rich text example... </color>
Keep count of tag openings ("<")
Keeps count of the number of charcaters that are rich text
To tell whether or not to display the characters of a sentence. example... You wouldn't display the characters for rich text tags
To tell whether the code should be storing the sentence characters as rich text tags or not
To tell whether the string between the < or >'s should be stored in the display string or not
This is the closing tag (of the form </>) that is generated by the code
the string to be displayed to the screen
An AudioSource GameObject Component, this will be what plays the voice sound
The audio clip to be played by the AudioSource myAudio Provided by the user
an int associated with transposing the notes
the index of the note when its playmode is ascending
the index of the note when its playmode is descending
a temporary holder for notes being created that are added to the scale being generated
The default Unity Start method. Initializes variables, adds needed components, creates a new scale for the speaker voice by calling the method GenerateScale, sets the speakers sentences by calling the method GetNewSentences.
public void GetNewSentences( |
| ) |
Sets the class variable sentences to the string[] newSentences. Can be called from outside to update or change the needed dialog as the situation requires.
newSentences string[] | The string[] of new sentences to be displayed |
public void GetNewDialog( |
| ) |
Sets the class variable dialogItems to the list newDialog The SentenceHolder is a custom asset that is an object that holds a string[]
newDialog List<SentenceHolder> | The List of sentenceHolders, each dialog element being its own set of sentences. |
void OnTriggerStay( |
| ) |
If the player is within the radius of the collider, allows the player to initiate dialog by pushing the initiateDialogButton designated by the user. If an initiate conversation display GameObject has been provided in the inspector, it will be displayed when the player enters the radius.
other Collider | the other collider involved in the collision, usually the player |
void OnTriggerExit( |
| ) |
If the player exits the radius of the collider and an initiate conversation display GameObject has been provided, it will be hidden.
other Collider | the other collider involved in the collision, usually the player |
This method starts the conversation (the dialog display). It checks that the dialog system isnt already 'speaking", then checks that the initiate dialog button has been pressed again. If the button has not been hit again, it makes the UI canvas active, and starts the sentences "typing" using the selected sound Mode. If the button has been hit again, it decreases the delay between characters being displayed so that the sentence can complete displaying near instantly.
When the sentence has finished displaying, the next sentence button display will become active, indicating to the player that a button press is required to move the dialog along. Once the player has pressed the button, the dialog will call the NextSentence method.
This method, processes the sentences stored in the class variable string[] sentences. This method breaks the string down into a char array, then iterates through that first looking for rich text tags, then looking for syllables. As it is scanning the sentence, it is displaying each (non-tag) letter to the screen, and playing the provided sound at each syllable.
public string GenerateCloseTagFromOpen( |
| ) |
This method takes a rich text "opening tag" (ex: <color=red>) and generates a "closing tag" (ex:</color>) This allows us to display rich text strings, per letter.
passedTag string | this is the "opening tag" that will be used to generate the "closing tag" |
toReturn | the string containing the "closing tag" |
Processes the sentences stored in the class variable string[] sentences. First it breaks the string down into a char array, then iterates through that looking for rich text tags. As it is scanning the sentence, it is displaying each (non-tag) letter to the screen, and playing the provided sound at each typed letter.
This method processes the sentences stored in the class variable string[] sentences. This method breaks the string down into a char array, then iterates through that looking for rich text tags. It is displaying each (non-tag) letter to the screen.
This method checks if the sentences[] has completed, if it hasnt, it loads the next sentences and speaks it, if there are no more sentences, the dialog is closed and the method to reset the dialog is called (with a 1 second delay so it doesn't reopen instantly).
This method checks the selected scale play mode (random order, ascending, descending, specific note) and calls the appropriate method to display the dialog.
This method plays a random note from the scale newScale.
This method plays the notes from scale newScale in ascending order. It uses the class int orderedNoteIndexAsc to keep track of where it is in the scale.
This method plays the notes from scale newScale in descending order. It uses the class int orderedNoteIndexDes to keep track of where it is in the scale.
public void PlayNote( |
| ) |
This method plays the specific note indicated by the parameter. The note is chosen from the chromatic scale starting and ending with C, numbered 0 - 12
note | the number indicating which note from the chromatic scale is to be played. |
public List<int> GenerateScale ( |
| ) |
This method generates a scale with a specific key for the voice. The scale is returned as a list.
root int | this is the key the newly generated scale will be in |
scale int | this is the type of scale it will be. The number indicates the scale type in the class int[][] scales. |
noteScale | the newly generated scale, stored as a List<int> |
IEnumerator PlayMyNote ( |
| ) |
This method plays the note specified in the parameter. The number represents the note on the chromatic scale, starting and ending with C, numbered 0 - 12
note int | the number of the note on the chromatic scale, to play. |
This method waits for 1 second before resetting the UI, strings, counters, variables, etc associated with the dialog. The delay is to allow a slight cool down period between dialog to prevent any errors.