protected void interact(Event firedEvent)
{
string entityName = firedEvent.payload["EntityKey"];
Entity entity = firedEvent.GameReference.currentLevel.Entities[entityName];
if (this.conversations.Keys.Contains(firedEvent.payload["EntityKey"]))
{
if (this.currentConversation == null)
{
this.StartConversation(entityName, entity);
}
else if (((DialogueNode)this.currentConversation[this.currentConversationState]).NextState == 0)
{
this.EndConversation(entityName);
}
else
{
DialogueNode currentDiagNode = (DialogueNode)this.currentConversation[this.currentConversationState];
this.currentConversationBubble.isReadyForDeletion = true;
this.currentConversationState = currentDiagNode.NextState;
currentDiagNode = (DialogueNode)this.currentConversation[this.currentConversationState];
this.currentConversationBubble = new TextBubble(entity, currentDiagNode.Text);
this.activeTextBubbles.AddLast(this.currentConversationBubble);
}
if (this.currentConversation != null)
{
Event newEvent = new Event();
newEvent.GameReference = firedEvent.GameReference;
newEvent.Type = firedEvent.payload["EntityKey"] + "Speaking";
newEvent.payload.Add("State", "" + this.currentConversationState);
firedEvent.GameReference.EventManager.notify(newEvent);
}
}
else
Console.WriteLine("ENTITY[" + firedEvent.payload["EntityKey"] + "] HAS NO DIALOGUE");
}