//--------------------------------------------------------------------------------------------------------------------------------------------------- // // 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 System.Text; using System.Xml; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using NoName; using NoName.Statics; /// /// Instance of a HUDEvent /// Extends GameEvent /// Used to update the images to the HUD /// public class HUDEvent : GameEvent { /// /// The type of HUD Event /// public string HUDtypeID { get { return _HUDtypeID; } set { _HUDtypeID = value; } } private string _HUDtypeID; /// /// The texture to use for the event /// public string texPath { get { return _texPath; } set { _texPath = value; } } private string _texPath; /// /// The texture's width /// public int texX { get { return _texX; } set { _texX = value; } } private int _texX; /// /// The texture's height /// public int texY { get { return _texY; } set { _texY = value; } } private int _texY; /// /// A boolean which returns true if image is being drawn /// public bool toDraw { get { return _toDraw; } set { _toDraw = value; } } private bool _toDraw; Vector2 imageLocation; Texture2D imageTexture; /// /// Creates the HUDStackEvent from XML /// /// XML Node public HUDEvent(XmlNode node) : base(node) { this.typeID = node.Attributes["typeID"].Value; this.HUDtypeID = node.Attributes["name"].Value; this.texPath = node.Attributes["texture"].Value; this.texX = int.Parse(node.Attributes["texX"].Value); this.texY = int.Parse(node.Attributes["texY"].Value); string value = node.Attributes["draw"].Value; if (value == "Yes") { this.toDraw = true; } else { this.toDraw = false; } imageTexture = NoName.Statics.Globals.content.Load(texPath); imageLocation = new Vector2(NoName.Statics.Globals.GAME_WINDOW_WIDTH - this.texX, this.texY); } /// /// Adds/changes the HUDStack image /// public override void FireEvent() { if (this.HUDtypeID == "StackEvent") { for (int x = 0; x < NoName.Statics.Globals.hud.imageDisplays.Count; x++) { if (NoName.Statics.Globals.hud.imageDisplays[x].name == "stack") { NoName.Statics.Globals.hud.imageDisplays[x].image = imageTexture; NoName.Statics.Globals.hud.imageDisplays[x].position = imageLocation; } } isFinished = true; } else if (this.HUDtypeID == "MapEvent") { for (int x = 0; x < NoName.Statics.Globals.hud.imageDisplays.Count; x++) { if (NoName.Statics.Globals.hud.imageDisplays[x].name == "map") { NoName.Statics.Globals.hud.imageDisplays[x].image = imageTexture; NoName.Statics.Globals.hud.imageDisplays[x].position = imageLocation; } } isFinished = true; } } } }