//--------------------------------------------------------------------------------------------------------------------------------------------------- // <copyright file="DialogueEvent.cs" company="DarkWynter Studios"> // Copyright (C)2007 DarkWynter Studios. All rights reserved. // </copyright> //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Engine.EventControl.EventTypes { using System; using System.Collections.Generic; using System.Diagnostics; using DarkWynter.Engine.Globals; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.UserInterface; using System.Text; using System.Xml; /// <summary> /// Instance of a DialogueEvent /// Extends GameEvent /// Used to update the Dialogue graphics and text on the HUD /// </summary> public class DialogueEvent : GameEvent { /// <summary> /// Who is speaking /// </summary> public string speaker { get { return _speaker; } set { _speaker = value; } } private string _speaker; /// <summary> /// What the speaker is saying /// </summary> public string message { get { return _message; } set { _message = value; } } private string _message; /// <summary> /// The amount of time the message is to be shown /// </summary> public int time { get { return _time; } set { _time = value; } } private int _time; /// <summary> /// Path holding the texture we want to use /// </summary> public string texturePath { get { return _texturePath; } set { _texturePath = value; } } private string _texturePath; /// <summary> /// Create for the dialogue event /// </summary> /// <param name="speaker">Speaker of the message</param> /// <param name="message">Message contents</param> /// <param name="time">Time to run</param> public DialogueEvent(XmlNode node ) :base(node) { this.speaker = node.Attributes["speaker"].Value; this.message = node.Attributes["message"].Value; this.time = int.Parse(node.Attributes["time"].Value); this.texturePath = node.Attributes["texturePath"].Value; Texture2D dialogueTexture = Statics_Engine.SystemSettings.content.Load<Texture2D>(texturePath); eventLimitMilli = 10000; eventSpeaker = speaker; eventMessage = message; eventLimitMilli = time; eventTexture = dialogueTexture; } /// <summary> /// Runs the dialogue on the HUD for the specified time /// </summary> public override void FireEvent() { DarkWynterEngine.HUD.DisplayDialog(eventTexture, eventSpeaker, eventMessage, eventLimitMilli); if (GameEventHandler.CurrentGameConditions._triggerSanity != -1) { GameEventHandler.CurrentGameConditions._triggerSanity = -1; } if (this.eventMessage.Contains("We must have made the wrong choice.")) { Statics_Engine.GameSettings.experiencePoints -= 10; } isFinished = true; } } }