using System; using System.Collections.Generic; using System.Text; using System.Xml; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using DarkWynter.Engine.Globals; using DarkWynter.Engine.ObjectLib; using DarkWynter.Engine.GameObjects; using DarkWynter.Stream; namespace DarkWynter.Engine.Init { public class Load { /// /// Contains properties of the object that this Load belongs to. /// public XmlNode node; /// /// Postion of this object, cooresponding to its pixel stored in the LocationMap. /// public Vector4 startPosition; public Load(XmlNode objectNode, Vector4 startingLocation) { startPosition = startingLocation + Vector4.Zero; node = objectNode; } /// /// Load object data from Xml. /// /// ObjectLibrary that this object belongs to. /// True if load was successful public bool Load_Default(ObjectLibrary objectLibrary, GameObject gameObject, bool randomRotation) { // Start Type properties gameObject.mass.gameObjectPointer = gameObject; gameObject.objectModelName = node.Attributes["name"].Value; // Load model file if (!gameObject.LoadModel(node)) { return false; } // Get terrain height at position float yPosition = objectLibrary.terrain.GetTerrainHeight(startPosition.X / Statics_Engine.TerrainSettings.terrainScaleFactor, startPosition.Z / Statics_Engine.TerrainSettings.terrainScaleFactor); // Set position and reference Vector3 locpos = new Vector3(startPosition.X, yPosition, startPosition.Z); Vector3 refpos = new Vector3(startPosition.X, yPosition, startPosition.Z - 1); gameObject.mass.SetPosition(locpos, refpos); // Random Rotation if (randomRotation) { Random rand = new Random(); gameObject.mass.Rotate(0.0f, (float)(2 * Math.PI * rand.NextDouble())); } else { gameObject.mass.Rotate(0.0f, 0.0f); } // Scaling and weight gameObject.mass.scale = new Vector3((int)(float.Parse(node.Attributes["maxScale"].Value))); gameObject.mass.mass = float.Parse(node.Attributes["mass"].Value); gameObject.mass.isMoving = false; // Set GameObject properties gameObject.isCollectable = bool.Parse(node.Attributes["isCollectable"].Value); gameObject.isKey = bool.Parse(node.Attributes["isKey"].Value); // Is a level keys if (gameObject.isKey) { gameObject.collisionWithPlayerResponse = Enums_Engine.CollisionResponses.HEALTHBONUS; } return true; } //public Vector3 Load_Position(ObjectLibrary objectLibrary) //{ //} } }