//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.EventSystem.EventTypes { using System; using System.Collections.Generic; using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Text; using System.Xml; /// /// Instance of a DialogueEvent /// Extends GameEvent /// Used to update the Dialogue graphics and text on the HUD /// public class DialogueEvent : GameEvent { Texture2D texture; Vector2 speakerOffSet; Vector2 textOffSet; Vector2 dialogueOffSet; /// /// Who is speaking /// public string speaker { get { return _speaker; } set { _speaker = value; } } private string _speaker; /// /// What the speaker is saying /// public string message { get { return _message; } set { _message = value; } } private string _message; /// /// The amount of time the message is to be shown /// public int time { get { return _time; } set { _time = value; } } private int _time; /// /// Path holding the texture we want to use /// public string texturePath { get { return _texturePath; } set { _texturePath = value; } } private string _texturePath; /// /// Create for the dialogue event /// /// Speaker of the message /// Message contents /// Time to run 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; eventLimitMilli = 10000; eventSpeaker = speaker; eventMessage = message; eventLimitMilli = time; texture = GameEventHandler.content.Load(texturePath); speakerOffSet = new Vector2(75, 10); textOffSet = new Vector2(35, 40); dialogueOffSet = new Vector2(175, -175); } /// /// Runs the dialogue on the HUD for the specified time /// public override void FireEvent() { //Game1.hud.imageDisplays[Constants.dialogueTextureIndex]._position = // World.getInstance().WorldToScreen(Constants.PlayerVars.allPlayers.getCurrent.WorldPosition) + dialogueOffSet; //Game1.hud.textDisplays[Constants.dialogueTextIndex]._position = // (Game1.hud.imageDisplays[Constants.dialogueTextureIndex]._position + textOffSet); //Game1.hud.textDisplays[Constants.dialogueSpeakerIndex]._position = // (Game1.hud.imageDisplays[Constants.dialogueTextureIndex]._position + speakerOffSet); // EventSystemDemo.EventSystemMain.hud.DisplayDialog(texture, eventSpeaker, eventMessage, eventLimitMilli); if (GameEventHandler.CurrentGameConditions._triggerSanity != -1) { // GameEventHandler.CurrentGameConditions._triggerSanity = -1; } isFinished = true; } } }