//--------------------------------------------------------------------------------------------------------------------------------------------------- // // 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 HUDDemo; /// /// Instance of a HUDEvent /// Extends GameEvent /// Used to update the images to the HUD /// public class HUDEvent : GameEvent { Texture2D texture; /// /// 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); this.toDraw = bool.Parse(node.Attributes["draw"].Value); texture = GameEventHandler.content.Load(texPath); //imageLocation = new Vector2(Constants.WindowWidth - this.texX, this.texY); } /// /// Adds/changes the HUDStack image /// public override void FireEvent() { if (this.HUDtypeID == "StackEvent") { for (int x = 0; x < HUDDemoMain.hud.imageDisplays.Count; x++) { if (HUDDemoMain.hud.imageDisplays[x].name == "stack") { HUDDemoMain.hud.imageDisplays[x].image = imageTexture; HUDDemoMain.hud.imageDisplays[x].position = imageLocation; } } isFinished = true; } else if (this.HUDtypeID == "MapEvent") { for (int x = 0; x < HUDDemoMain.hud.imageDisplays.Count; x++) { if (HUDDemoMain.hud.imageDisplays[x].name == "map") { HUDDemoMain.hud.imageDisplays[x].image = imageTexture; HUDDemoMain.hud.imageDisplays[x].position = imageLocation; } } isFinished = true; } } } }