-
Notifications
You must be signed in to change notification settings - Fork 2
Events
Jeppe Zapp edited this page Jul 30, 2014
·
1 revision
Events in OpenConvo are the logic that you execute during key points of the conversation, e.g. when the speaker changes or when the conversation begins/ends.
First, you create the event handler script and link it to an object. It should be a subclass of OCEventHandler
public class MyEventHandler : OCEventHandler {
}Let's add some callbacks to the handler
public class MyEventHandler : OCEventHandler {
public void OnConversationStart ( OCTree tree ) {
Debug.Log ( "Conversation with " + tree.gameObject.name + " started" );
}
public void OnSetSpeaker ( OCSpeaker speaker, OCSpeak node ) {
// This type of node doesn't change the camera
if ( node.smalltalk ) {
Debug.Log ( speaker.name + ": " + node.lines[0].text );
// Only one line, proceed
} else if ( node.lines.Length == 1 ) {
Camera.main.transform.LookAt ( speaker.gameObject.transform.position );
Debug.Log ( speaker.name + ": " + node.lines[0].text );
// Multiple lines, this is a player choice
} else {
for ( int i = 0; i < node.lines.Length; i++ ) {
uiInstance.SetChoice ( i, node.lines[i].string );
}
}
}
public void OnConversationEnd () {
Debug.Log ( "Conversation ended" );
}
}