namespace DarkWynter.Engine.GameObjects
{
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.Xml;
using System.Diagnostics;
#endregion
using DarkWynter.Engine.GameObjects;
using DarkWynter.Engine.Init;
using DarkWynter.Engine.Globals;
///
/// User-Defined types can be added to the engine by inheriting from GameObjectTypes
/// and overloading it's CreateGameobjectType method. This method must create a new
/// GameObject and assign it to the incoming GameObject. Creation of the GameObject
/// by the overloaded User-Defined class should use a case statement to decide what
/// kind of GameObject to create based on the Xml-based "type" parameter.
///
public class UserDefinedTypes : GameObjectTypes
{
///
/// Create an GameObject using the "type" string included in the XmlNode.
/// GameObject must be included in Engine, or added using GameObject override in Game.
///
/// Xml data describing the Gameobject.
/// A blank GameObject to replace with User-Defined GameObject.
/// Returns true if GameObject was successfully created.
public override bool CreateGameObjectType(ref GameObject gameObject)
{
// Get the Object Type
string type = gameObject.load.node.LocalName;
// Create the GameObject based on type
switch (type)
{
case "Human":
gameObject = new Human(gameObject.load);
return true;
case "Bot":
gameObject = new AI(gameObject.load);
return true;
case "GameObject":
if (gameObject.load.node.Attributes["typeID"].Value == "Nightmare")
{
gameObject = new NightmaresAI(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Thought")
{
gameObject = new ThoughtsAI(gameObject.load);
Statics_Engine.GameSettings.myThoughts.Add(gameObject);
return true;
} if (gameObject.load.node.Attributes["typeID"].Value == "Wish")
{
gameObject = new WishesAI(gameObject.load);
Statics_Engine.GameSettings.myThoughts.Add(gameObject);
return true;
} if (gameObject.load.node.Attributes["typeID"].Value == "Cera")
{
gameObject = new CeraAI(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Sky")
{
gameObject = new SkySphere(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Portal")
{
gameObject = new Portal(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes[0].Value == "WaterPlane")
{
gameObject = new WaterPlane(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "TriggerPlane")
{
gameObject = new TriggerPlane(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Bomb")
{
gameObject = new Bomb(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Coins")
{
gameObject = new Coins(gameObject.load);
return true;
}
if (gameObject.load.node.Attributes["typeID"].Value == "Arrows")
{
gameObject = new Arrows(gameObject.load);
return true;
}
break;
default:
Console.WriteLine("Error Loading XML Object: " + type);
break;
}
return false;
}
}
}