//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Game.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; #endregion using DarkWynter.Engine.Globals; using DarkWynter.Engine.Physics; using DarkWynter.Engine.ObjectLib; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.Init; using DarkWynter.Stream; public class Landscape : GameObject { List billboards; Texture2D locationMap; float _recenteringThreshold = 1000; public float recenteringThreshold { get { return _recenteringThreshold; } set { _recenteringThreshold = value; } } /// /// Portal constructor /// public Landscape(Load gameObjectLoader) : base(gameObjectLoader) { } public override bool Load(ObjectLibrary objectLibrary) { //return base.Load(objectLibrary); // Load Location Map locationMap = Statics_Engine.SystemSettings.content.Load("Content/_textures/FireRed"); // Load Textures for Billboards draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/FireRed")); // Create billboards based on player posiiton billboards = new List(); // for( each pixel in locationMap) { // Get pixel position from locationmap and scale to world position Vector3 position = new Vector3(0); Billboard billboard = new Billboard(null); billboard.Load(position, new Vector3(0), 600.0f, 800.0f, draw.textureList[0]); } return true; } /// /// Clip to Player position if distance between Player and center of Landscape exceeds threshold. /// /// public override void Update(ref ObjectLibrary objectLibrary) { // No physics required.. base.Update(ref objectLibrary); // Recenter if distance between Player and center of Landscape exceeds threshold Vector3 distance = DarkWynter.Engine.DarkWynterEngine.objectLibrary.humans[0].mass.currentPosition - this.mass.currentPosition; if(distance.Length() > recenteringThreshold) { this.mass.currentPosition = DarkWynter.Engine.DarkWynterEngine.objectLibrary.humans[0].mass.currentPosition; for (int i = 0; i < billboards.Count; i++) { // NOTE: Add random offset to new position to eliminate repetative pattern billboards[i].Position = billboards[i].Position + distance; } } } public override void Draw_Billboards(ObjectLibrary objectLibrary, BillboardList gameObjectBillboards) { // draw all billboard in list for (int i = 0; i < billboards.Count; i++) { gameObjectBillboards.Add(billboards[i] as IBillboard); } } } }