EasyTalk API
Loading...
Searching...
No Matches
EasyTalk.Controller.AreaDialogueController Class Reference

Extends the standard DialogueController by adding functionality to either play dialogue automatically when a collider (such as a player) enters the trigger collider on the AreaDialogueController's GameObject, or sends a notification via the onPrompt UnityEvent to allow something else to determine whether the dialogue should play. More...

Inherits EasyTalk.Controller.DialogueController.

Public Types

enum  DialogueActivationMode { PLAY_ON_ENTER , PROMPT_ON_ENTER }
 The dialogue activation mode for an area controller. More...
 
enum  DialogueDeactivationMode { EXIT_ON_LEAVE_AREA , FINISH_PLAYING }
 The dialogue deactivation mode for an area controller. More...
 
- Public Types inherited from EasyTalk.Controller.DialogueController
enum  PlaybackType { AUTOPLAY , WAIT_FOR_COMMAND }
 Defines dialogue playback types used by dialogue controllers. More...
 

Public Member Functions

virtual void Prompt ()
 Triggers the onPrompt event.
 
virtual void Play ()
 Plays the Dialogue and triggers the onPlay event.
 
virtual void Exit ()
 Exits the Dialogue.
 
- Public Member Functions inherited from EasyTalk.Controller.DialogueController
void PlayDialogue (string entryPointName=null)
 Starts playback of the dialogue at the specified entry node.
 
void ChangeDialogue (Dialogue dialogue)
 Changes the Dialogue used by the controller.
 
void ExitDialogue ()
 Exits the dialogue playback immediately.
 
override void OnDialogueEntered (string entryPointName)
 Called when dialogue playback begins. This will switch conversation displays used if set to do so and call OnDialogueEntered on all Dialogue Listeners registered with the controller.
 
override void OnDialogueExited (string exitPointName)
 Called when dialogue playback exits. This will stop the autoplay routine and call OnDialogueExited on all registered Dialogue Listeners.
 
override void OnDisplayOptions (List< DialogueOption > options)
 Called whenever options are to be presented. This method filters out options which are set to not be displayed before sending the filtered list on to the OnDisplayOptions method on all registered Dialogue Listeners.
 
override void OnVariableUpdated (string variableName, object variableValue)
 Called whenever a variable value is updated in the dialogue. This method will trigger the OnVariableUpdated method on all registered Dialogue Listeners.
 
override void OnDisplayLine (ConversationLine line)
 Called whenever a line of dialogue is to be displayed. This method does the following:

  • Stops the current autoplay routine if it is running.
  • Switches conversation displays if the controller is set to do so, such as when the character changes or a target tag is specified on the l ine of dialogue.
  • Send a key tag value to any registered Dialogue Listeners via the OnActivateKey method.
  • Starts the autoplay routine or calls the OnDisplayLine method on all registered Dialogue Listeners.
  • Switches the audio to play audio for the new line of dialogue.

 
void SwitchLineAudio (ConversationLine line, ConversationLine previousLine)
 Stops any audio currently playing and starts playing audio for the provided line of dialogue.
 
void CharacterChanged (string newCharacterName)
 Called whenever a character change is detected. If this controller is set to switch conversation displays on character change, it will attempt to do so. Additionally, any Dialogue Listeners registered will have their OnCharacterChanged method triggered.
 
AudioSource GetAudioSource ()
 Finds and returns an audio source on this component or its child components. If the audio source is set on the controller, it will use that audio source instead of searching components for an audio source.
 
bool IsAudioPlaying ()
 Returns whether audio is currently being played by the controller.
 
override void OnConversationEnding (ConversationLine currentLine, Node nextNode)
 Called whenever the last line of dialogue in a conversation node is reached. If the next node is an option node, and options are set to be presented automatically, then the DisplayOptionsAfterDelay coroutine will be started to display options based on the delay settings. THis method also calls OnConversationEnding on all registered Dialogue Listeners.
 
virtual IEnumerator GoToOptionsAfterDelay (float delay, OptionNode optionNode)
 Tells the node handler to jump to the specified option node after a certain period of time.
 
void Continue ()
 Makes the dialogue continue forward from the current point. This method will also trigger the OnContinue method on all registered Dialogue Listeners.
 
override void OnAudioStarted (ConversationLine line)
 Called whenever audio playback starts for a line of dialogue. This will call the OnAudioStarted method of all registered Dialogue Listeners.
 
override void OnAudioCompleted (ConversationLine line, bool forced)
 Called whenever audio playback finishes or is interrupted for a line of dialogue. This will call the OnAudioCompleted method of all registered Dialogue Listeners.
 
override void OnNodeChanged (Node newNode)
 Called whenever the current node being processed changes.
 
void ChooseOption (DialogueOption option)
 Chooses the specified option and calls the OnOptionChosen method of all registered Dialogue Listeners.
 
override void Wait (float timeInSeconds)
 Creates a coroutine to wait for the specified duration before continuing. This method also calls the Wait method on all registered Dialogue Listeners.
 
override void OnPause (string signal)
 Called whenever a pause node is reached during dialogue playback.
Parameters
signalThe signal string of the pause node.

 
override void OnWaitingForNodeEvaluation (Node asyncNode)
 
override void OnExecuteAsyncNode (AsyncNode node)
 
override void OnNodeEvaluationCompleted (Node asyncNode)
 
NodeHandler GetNodeHandler ()
 Returns the node handler used by this controller.
 
ConversationDisplay GetConversationDisplay ()
 Returns the conversation display to use when entering dialogue playback via this controller.
 
string GetConversationDisplayID ()
 Returns the Display ID of the conversation display to use when entering dialogue playback via this controller.
 
void SetStringVariable (string variableName, string value)
 Sets the value of the specified variable.
 
string GetStringVariable (string variableName)
 Returns the string value of the specified variable.
 
void SetBoolVariable (string variableName, bool value)
 Sets the value of the specified variable.
 
bool GetBoolVariable (string variableName)
 Returns the bool value of the specified variable.
 
void SetIntVariable (string variableName, int value)
 Sets the value of the specified variable.
 
int GetIntVariable (string variableName)
 Returns the int value of the specified variable.
 
void SetFloatVariable (string variableName, float value)
 Sets the value of the specified variable.
 
float GetFloatVariable (string variableName)
 Returns the float value of the specified variable.
 
void AddDialogueListener (DialogueListener dialogueListener)
 Adds the specified Dialogue Listener to the controller's list of listeners.
 
void RemoveDialogueListener (DialogueListener dialogueListener)
 Removes the specified Dialogue Listener from the controller's list of listeners.
 
void RemoveDialogueListeners ()
 Removes all Dialogue Listeners from the controller.
 
PlaybackType GetPlaybackType ()
 Gets the playback type of this controller.
 
void SetPlaybackType (PlaybackType playbackType)
 Sets the playback type of this controller.
 
void SaveVariableValues (string prefix="", bool saveToPlayerPrefs=false)
 Saves the values of all variables in the Dialogue to either a file, or to the PlayerPrefs.
 
void SaveGlobalVariableValues (string prefix="", bool saveToPlayerPrefs=false)
 Saves all currently loaded global variable values to PlayerPrefs or a JSON file.
 
void LoadVariableValues (string prefix="", bool loadFromPlayerPrefs=false)
 Loads the states of the Dialogue's variables from a save if available.
 
void LoadGlobalVariableValues (string prefix="", bool loadFromPlayerPrefs=false)
 Loads global variable values from PlayerPrefs or a JSON file.
 
void InitializeGlobalVariables (DialogueRegistry registry=null)
 Initializes global variable values from the Dialogue Registry provided. If the registry is null, an attempt will be made to load a registry from the active Dialogue Settings set on the node handler, and then will attempt to locate a registry on a Dialogue Display's Dialogue Settings from the scene's Hierarchy.
 
void SetPlaybackType (string playbackType)
 Sets the playback mode of the controller. If the passed in string is "auto" or "autoplay", the mode will be set to AUTOPLAY; otherwise it will be set to WAIT_FOR_COMMAND mode.
 
void ChangePlaybackType ()
 Changes the playback mode of the controller to whichever mode it isn't currently in. If the controller is in WAIT_FOR_COMMAND mode, calling this method will switch it to AUTOPLAY mode, and vice versa.
 
- Public Member Functions inherited from EasyTalk.Controller.DialogueListener
virtual void OnContinue ()
 Called whenever the dialogue continues on to the next line.
 
virtual void OnOptionChosen (DialogueOption option)
 Called whenever an option is chosen from the currently presented list of options.
 
virtual void OnExitCompleted ()
 Called at least one frame after a dialogue is exited.
 
virtual void OnStory (string storyText)
 Called whenever a story node is encountered.
 
virtual void OnCharacterChanged (string oldCharacterName, string newCharacterName)
 Called whenever a character change is detected.
 
virtual void OnActivateKey (string key)
 Called whenever a key tag is present in a line of dialogue.
 

Public Attributes

UnityEvent onPrompt = new UnityEvent()
 An event which is triggered when the activator enters the trigger area of this GameObject and the activation mode is set to PROMPT_ON_ENTER.
 
UnityEvent onAreaEntered = new UnityEvent()
 An event which is triggered whenever the activator collider enters the trigger of this GameObject.
 
UnityEvent onAreaExited = new UnityEvent()
 An event which is triggered whenever the activator collider leaves the trigger of this GameObject.
 
- Public Attributes inherited from EasyTalk.Controller.DialogueController
UnityEvent onPlay = new UnityEvent()
 An event which is triggered when dialogue playback starts.
 
UnityEvent onStop = new UnityEvent()
 An event which is triggered when dialogue playback stops.
 
- Public Attributes inherited from EasyTalk.Controller.DialogueListener
bool debugEnabled = false
 When set to true, debug logging will be shown for each method called on the listener.
 
UnityEvent onContinue = new UnityEvent()
 An event which is triggered whenever the dialogue continues.
 
UnityEvent onDisplayOptions = new UnityEvent()
 An event which is triggered whenever options are to be displayed to the player.
 
UnityEvent onOptionChosen = new UnityEvent()
 An event which is triggered whenever the player chooses an option.
 
UnityEvent onDisplayLine = new UnityEvent()
 An event which is triggered whenever a line of dialogue is to be displayed.
 
UnityEvent onDialogueEntered = new UnityEvent()
 An event which is triggered whenever dialogue playback begins.
 
UnityEvent onDialogueExited = new UnityEvent()
 An event which is triggered whenever dialogue playback ends.
 
UnityEvent onExitCompleted = new UnityEvent()
 An event which is triggered one frame after dialogue playback ends.
 
UnityEvent onStory = new UnityEvent()
 An event which is triggered whenever a story node is encountered.
 
UnityEvent onVariableUpdated = new UnityEvent()
 An event which is triggered whenever a dialogue variable value is updated.
 
UnityEvent onCharacterChanged = new UnityEvent()
 An event which is triggered whenever a character name change is detected.
 
UnityEvent onAudioStarted = new UnityEvent()
 An event which is triggered whenever dialogue audio starts playing.
 
UnityEvent onAudioCompleted = new UnityEvent()
 An event which is triggered whenever dialogue audio finishes playing.
 
UnityEvent onActivateKey = new UnityEvent()
 An event which is triggered whenever a key is to be processed on a dialogue.
 
UnityEvent onWait = new UnityEvent()
 An event which is triggered whenever a dialogue starts waiting for a certain period of time before continuing.
 
UnityEvent onConversationEnding = new UnityEvent()
 An event which is triggered whenever the last line of dialogue in a conversation node is reached.
 
UnityEvent onNodeChanged = new UnityEvent()
 An event which is triggered whenever a the dialogue flows from one node to another.
 
UnityEvent onPause = new UnityEvent()
 An event which is triggered whenever the dialogue reaches a pause node, pausing and waiting for Continue() to be called.
 
UnityEvent onExecuteAsyncNode = new UnityEvent()
 
UnityEvent onWaitingForNodeCompletion = new UnityEvent()
 
UnityEvent onNodeEvaluationCompleted = new UnityEvent()
 

Private Member Functions

void OnTriggerEnter (Collider other)
 If the 'other' collider is the activator then the Dialogue will be played or the onPrompt event will be triggered, depending on the activation mode. This method will also trigger the onAreaEntered event.
 
void OnTriggerExit (Collider other)
 If the 'other' collider is the activator then the Dialogue will be exited if the deactivation mode is EXIT_ON_LEAVE_AREA. This method also triggers the onAreaExited event.
 

Private Attributes

Collider activator
 The collider which activates the controller when colliding with this GameObject.
 
string entryPoint
 The ID of the entry point where the Dialogue is entered when the controller is activated.
 
DialogueActivationMode activationMode = DialogueActivationMode.PLAY_ON_ENTER
 The activation mode of the controller.
 
DialogueDeactivationMode deactivationMode = DialogueDeactivationMode.FINISH_PLAYING
 The deactivation mode of the controller.
 

Additional Inherited Members

- Protected Member Functions inherited from EasyTalk.Controller.DialogueController
virtual void Init ()
 Initializes the controller to prepare it for playing dialogue.
 
virtual void ActivateKey (ConversationLine line)
 Activates the key of the specified line of dialogue by sending its key value to all registered Dialogue Listeners by calling their OnActivateKey methods.
 
IEnumerator PlayAudioClip (ConversationLine line)
 Plays the audio clip for the specified line of dialogue.
 
- Protected Attributes inherited from EasyTalk.Controller.DialogueController
Dialogue dialogue
 The Dialogue to use.
 
DialogueRegistry dialogueRegistry
 The Dialogue Registry to use when initializing global variables.
 
PlaybackType playbackType
 The playback type of the controller.
 
AbstractDialogueDisplay dialogueDisplay
 The dialogue display currently being used by this controller.
 
ConversationDisplay conversationDisplay = null
 The converstion display to use when playing dialogue.
 
string conversationDisplayID = null
 The ID of the conversation display to use when initializing a conversation on a dialogue display and no conversation display is set.
 
AudioSource audioSource
 The audio source to use for playing lines of dialogue.
 
List< DialogueListenerdialogueListeners = new List<DialogueListener>()
 A collection of DialogueListeners to call as dialogue playback occurs.
 
bool isRunning = false
 Whether the dialogue is currently being played.
 
- Properties inherited from EasyTalk.Controller.DialogueController
AbstractDialogueDisplay DialogueDisplay [get, set]
 Gets or sets the Dialogue Display currently used by this controller.
 
Dialogue CurrentDialogue [get]
 Gets the Dialogue currently set on the dialogue controller.
 

Detailed Description

Extends the standard DialogueController by adding functionality to either play dialogue automatically when a collider (such as a player) enters the trigger collider on the AreaDialogueController's GameObject, or sends a notification via the onPrompt UnityEvent to allow something else to determine whether the dialogue should play.

Member Enumeration Documentation

◆ DialogueActivationMode

The dialogue activation mode for an area controller.

Enumerator
PLAY_ON_ENTER 
PROMPT_ON_ENTER 

◆ DialogueDeactivationMode

The dialogue deactivation mode for an area controller.

Enumerator
EXIT_ON_LEAVE_AREA 
FINISH_PLAYING 

Member Function Documentation

◆ Exit()

virtual void EasyTalk.Controller.AreaDialogueController.Exit ( )
virtual

Exits the Dialogue.

◆ OnTriggerEnter()

void EasyTalk.Controller.AreaDialogueController.OnTriggerEnter ( Collider other)
private

If the 'other' collider is the activator then the Dialogue will be played or the onPrompt event will be triggered, depending on the activation mode. This method will also trigger the onAreaEntered event.

Parameters
otherThe collider which entered this trigger.

◆ OnTriggerExit()

void EasyTalk.Controller.AreaDialogueController.OnTriggerExit ( Collider other)
private

If the 'other' collider is the activator then the Dialogue will be exited if the deactivation mode is EXIT_ON_LEAVE_AREA. This method also triggers the onAreaExited event.

Parameters
otherThe collider which entered this trigger.

◆ Play()

virtual void EasyTalk.Controller.AreaDialogueController.Play ( )
virtual

Plays the Dialogue and triggers the onPlay event.

◆ Prompt()

virtual void EasyTalk.Controller.AreaDialogueController.Prompt ( )
virtual

Triggers the onPrompt event.

Member Data Documentation

◆ activationMode

DialogueActivationMode EasyTalk.Controller.AreaDialogueController.activationMode = DialogueActivationMode.PLAY_ON_ENTER
private

The activation mode of the controller.

◆ activator

Collider EasyTalk.Controller.AreaDialogueController.activator
private

The collider which activates the controller when colliding with this GameObject.

◆ deactivationMode

DialogueDeactivationMode EasyTalk.Controller.AreaDialogueController.deactivationMode = DialogueDeactivationMode.FINISH_PLAYING
private

The deactivation mode of the controller.

◆ entryPoint

string EasyTalk.Controller.AreaDialogueController.entryPoint
private

The ID of the entry point where the Dialogue is entered when the controller is activated.

◆ onAreaEntered

UnityEvent EasyTalk.Controller.AreaDialogueController.onAreaEntered = new UnityEvent()

An event which is triggered whenever the activator collider enters the trigger of this GameObject.

◆ onAreaExited

UnityEvent EasyTalk.Controller.AreaDialogueController.onAreaExited = new UnityEvent()

An event which is triggered whenever the activator collider leaves the trigger of this GameObject.

◆ onPrompt

UnityEvent EasyTalk.Controller.AreaDialogueController.onPrompt = new UnityEvent()

An event which is triggered when the activator enters the trigger area of this GameObject and the activation mode is set to PROMPT_ON_ENTER.