public void Update(GameTime gameTime, Pantheon gameReference)
{
LinkedListNode<TextBubble> currentNode;
// Update the states...
foreach (string key in this.npcStates.Keys)
{
if (!gameReference.currentLevel.Entities.Keys.Contains(key)) continue; // BAD, FIX
Entity theEntity = gameReference.currentLevel.Entities[key];
switch (this.npcStates[key])
{
case DialogueManager.STATE_NONE:
if (this.npcStateBubbles[key] != null)
{
this.npcStateBubbles[key].isReadyForDeletion = true;
this.npcStateBubbles[key] = null;
}
break;
case DialogueManager.STATE_TALKING: // DON'T INTERRUPT, IT'S RUDE
if (this.npcStateBubbles[key] != null)
{
this.npcStateBubbles[key].isReadyForDeletion = true;
this.npcStateBubbles[key] = null;
}
break;
case DialogueManager.STATE_ALERT:
if (this.npcStateBubbles[key] == null)
{
this.npcStateBubbles[key] = new TextBubble(theEntity, "!");
}
else if (this.npcStateBubbles[key].Text != "!")
{
this.npcStateBubbles[key].isReadyForDeletion = true;
this.npcStateBubbles[key] = new TextBubble(theEntity, "!");
}
break;
case DialogueManager.STATE_TALKABLE:
if (this.npcStateBubbles[key] == null)
{
this.npcStateBubbles[key] = new TextBubble(theEntity, "...");
}
else if (this.npcStateBubbles[key].Text != "...")
{
this.npcStateBubbles[key].isReadyForDeletion = true;
this.npcStateBubbles[key] = new TextBubble(theEntity, "...");
}
break;
}
if(this.npcStateBubbles[key] != null)
this.npcStateBubbles[key].Update(gameTime, gameReference);
}
// Update each of the text bubbles...
currentNode = this.activeTextBubbles.First;
while (currentNode != null)
{
LinkedListNode<TextBubble> next = currentNode.Next;
currentNode.Value.Update(gameTime, gameReference);
if (currentNode.Value.isReadyForDeletion)
this.activeTextBubbles.Remove(currentNode);
currentNode = next;
}
}