//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DarkWynter.Engine.EventControl.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 DarkWynter.Engine.Globals;
using DarkWynter.Engine.Utilities;
using DarkWynter.Engine.GameObjects;
using DarkWynter.Stream;
///
/// Instance of a HUDStackEvent
/// Extends GameEvent
/// Used to update the stack images to the HUD
///
public class HUDStackEvent : GameEvent
{
///
/// 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 drawStack { get { return _drawStack; } set { _drawStack = value; } }
private bool _drawStack;
Vector2 stackLocation;
Texture2D stackTexture;
///
/// Creates the HUDStackEvent from XML
///
/// XML Node
public HUDStackEvent(XmlNode node)
: base(node)
{
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.drawStack = true;
}
else
{
this.drawStack = false;
}
string filename = texPath;
stackTexture = Engine.Globals.Statics_Engine.SystemSettings.content.Load(filename);
stackLocation = new Vector2(Statics_Stream.RenderSettings.cameraList[0].viewport.Width - this.texX, this.texY);
}
///
/// Adds/changes the HUDStack image
///
public override void FireEvent()
{
if (GameEventHandler.HUD_StackIndex == -1)
{
GameEventHandler.HUD_StackIndex = DarkWynterEngine._HUD.AddImageDisplay(stackTexture, stackLocation, stackTexture.Width, stackTexture.Height, Color.White, drawStack);
}
else
{
DarkWynterEngine._HUD.UpdateImageDisplay(GameEventHandler.HUD_StackIndex, stackTexture, stackLocation, stackTexture.Width, stackTexture.Height, Color.White, drawStack);
}
isFinished = true;
}
}
}