Game Development Reference
In-Depth Information
}
Now that we have our manager, we can start adding functionalities to it.
Starting a conversation
We want it to take a conversation item we have and do something with it because we have
a manager. So, create a new function as follows:
public void StartConversation(Conversation conversation)
{}
This enables us to start a new conversation anywhere in the code by using the following
code:
ConversationManager.Instance.StartConversation(conversation);
Displaying the conversation
The manager is in place and we have a method to start a conversation, but it's not doing
much right now. So, let's add some simple logic to display the text of the conversation on
the screen. We will keep it simple since we are going to look into more complex GUI-re-
lated functionalities in Chapter 8 , Shopping for Weapons .
Starting things off, we need some new properties in ConversationManager to con-
trol what needs to be displayed. So, open up the ConversationManager script and
add the following properties to it:
//Is there a conversation going on
bool talking = false;
//The current line of text being displayed
ConversationEntry currentConversationLine;
//Estimated width of characters in the font
int fontSpacing = 7;
//How wide does the dialog window need to be
int conversationTextWidth;
Search WWH ::




Custom Search