//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// 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 AIEvent
/// Extends GameEvent
/// Used to setPosition for AI to walk to (straight line)
///
public class AIEvent : GameEvent
{
///
/// Destinations.X coordinate
///
public int destX { get { return _destX; } set { _destX = value; } }
private int _destX;
///
/// Destinations.Y coordinate
///
public int destY { get { return _destY; } set { _destY = value; } }
private int _destY;
///
/// Destinations.Z coordinate
///
public int destZ { get { return _destZ; } set { _destZ = value; } }
private int _destZ;
Vector3 AIDestination;
Draw draw;
///
/// Creates the AIEvent from XML
/// Has a model to draw for LevelEditing
///
/// XML Node
public AIEvent(XmlNode node)
: base(node)
{
// AI Waypoint In-Order Indexing
this._trigger_ID = int.Parse(node.Attributes["ID"].Value);
this.destX = int.Parse(node.Attributes["destX"].Value);
this.destY = int.Parse(node.Attributes["destY"].Value);
this.destZ = int.Parse(node.Attributes["destZ"].Value);
AIDestination.X = destX;
AIDestination.Y = destY;
AIDestination.Z = destZ;
draw = new Draw(Enums_Stream.DrawMethod.BasicGameObject_Draw, "BasicLightingShaderMain");
draw.textureList = new List();
draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/bomb1"));
draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/bomb1"));
draw.model = Statics_Engine.SystemSettings.content.Load("Content/_models/GenericSphere");
foreach (ModelMesh mesh in draw.model.Meshes)
{
for (int i = 0; i < mesh.MeshParts.Count; i++)
{
// Add effect to mesh
mesh.MeshParts[i].Effect = ShaderParameters.DrawFX.effect;
}
}
}
///
/// Fires the Event based on matching the Event Conditions to the SBE
///
public override void FireEvent()
{
GameObject thought = DarkWynterEngine.engine.objectLibrary.gameObjectList[0];
thought.destination = AIDestination;
thought.destinationReached = false;
isFinished = true;
}
///
/// Adds the AI model to the draw list for LevelEditing
///
/// Returns the drawList
public override List Draw()
{
float yValue = this.destY * DarkWynter.Engine.Globals.Statics_Engine.TerrainSettings.terrainScaleFactor;
drawList.Clear();
// Calculate ObjectSpace(Rotation) and WorldSpace(Translation) Transformation Matrix
if (drawable)
{
draw.matrix =
draw.initialTransform *
Matrix.CreateScale(100) *
Matrix.CreateTranslation(new Vector3(this.destX, yValue, this.destZ));
drawList.Add(draw);
return drawList;
}
return drawList;
}
}
}