////--------------------------------------------------------------------------------------------------------------------------------------------------- //// //// Copyright (C)2007 DarkWynter Studios. All rights reserved. //// ////--------------------------------------------------------------------------------------------------------------------------------------------------- //// {Contact : darkwynter.com for licensing information ////--------------------------------------------------------------------------------------------------------------------------------------------------- //namespace ElementalGame //{ // #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; // #endregion // using DarkWynterEngine.Globals; // using DarkWynterEngine.ObjectLib; // using DarkWynterEngine.GameObjects; // using DarkWynterEngine.Utilities; // using GameObjects; // User Defined Types (add in override) // using RuleBook; // GameRules (provide override) // using GraphicUserInterface; // MenuSystem (move to engine) // /// // /// Owns and controlls the GameRules, ObjectLibrary, and MenuSystem componenets. // /// // public class GameFlow // { // //// CLEAN: MOVE TO ELEGAME // //private List gameObjectTypes; // //private GameRules gameRules; // ///// // ///// A scenegraph/collections class, contains all GameObject instants // ///// // //public ObjectLibrary objectLibrary; // ///// // ///// Menu System Componenets // ///// // //private MenuSystem menuSystem; // /// // /// Load System from Xml and create ObjectLibrary and GameRules instances. // /// // public GameFlow() // { // //// Pass in user defined GameObjectTypes // //gameObjectTypes = new List(); // //gameObjectTypes.Add(new UserDefinedTypes()); // //objectLibrary = new ObjectLibrary(gameObjectTypes); // //// Menu System // //menuSystem = new MenuSystem(); // //// Set up the Game Rules // //gameRules = new GameRules(); // } // /// // /// Call ObjectLibrary LoadLevel function. // /// Call GameRules LoadLevel function. // /// // public void Load() // { // //// Call Load Sequence // //objectLibrary.LoadLevel(); // //// Reset Survival Stopwatch // //if (Statics.gameType == Enums_Engine.GameType.SURVIVAL) // //{ // // gameRules.StartGameTimer(); // //} // } // /// // /// Call ObjectLibrary Update. // /// // /// SpriteBatch used to draw // public void Update(SpriteBatch spriteBatch) // { // //if (Statics.gameState == Enums_Engine.EngineState.GAME_MODE) // //{ // // // Update ObjectLibrary // // objectLibrary.Update(ref objectLibrary); // // // Update GameRules // // gameRules.Update(ref objectLibrary, menuSystem); // //} // //// Update menu system // //menuSystem.Update(objectLibrary); // } // /// // /// Calls ObjectLibrary or MenuSystem draw, dependant on Statics.gameState. // /// // /// SpriteBatch used to draw used to draw 2D components. // /// Screen saver object. // public void Draw(SpriteBatch spriteBatch, ScreenSaver screenSaver) // { // //// If in Game Mode (or paused) call game draw function // //if (Statics.gameState == Enums_Engine.EngineState.GAME_MODE || Statics.gameState == Enums_Engine.EngineState.GAME_PAUSE) // //{ // // objectLibrary.Draw(spriteBatch); // //} // //else if (Statics.gameState != Enums_Engine.EngineState.GAME_MODE) // //{ // // menuSystem.Draw(spriteBatch, screenSaver); // //} // } // } //} /* Legacy Code - Terrain Demo // // Draw the Terrain Demo Screen // public void DrawTerrainDemo(GraphicsDevice graphicsDevice, float dt) // { // // Create the viewport for the terrain // demoViewport = new Viewport(); // // Top Left = 260, 96 // Top Right = 710, 96 // // Bottom Left = 260, 435 // Bottom Right = 710, 435 // demoViewport.X = 260 * Statics.SystemSettings.GAME_WINDOW_WIDTH / 800; // demoViewport.Y = 96 * Statics.SystemSettings.GAME_WINDOW_HEIGHT / 600; // demoViewport.Width = 450 * Statics.SystemSettings.GAME_WINDOW_WIDTH / 800; // demoViewport.Height = 339 * Statics.SystemSettings.GAME_WINDOW_HEIGHT / 600; // demoViewport.MinDepth = Statics.defaultViewport.MinDepth; // demoViewport.MaxDepth = Statics.defaultViewport.MaxDepth; // // Top Left = 260, 96 // Top Right = 710, 96 // // Bottom Left = 260, 435 // Bottom Right = 710, 435 // graphicsDevice.Viewport = demoViewport; // graphicsDevice.Clear(Color.Black); // gameScreenRotation += dt; // if (gameScreenRotation > Math.PI * 2.0f) // { // gameScreenRotation -= (float)Math.PI * 2.0f; // } // Matrix matrix = Matrix.Identity; // float dx = (float)((Statics.collisionMapSize / 2.0f) * Math.Sin(gameScreenRotation)) + (Statics.collisionMapSize / 2.0f); // float dz = (float)((Statics.collisionMapSize / 2.0f) * Math.Cos(gameScreenRotation)) + (Statics.collisionMapSize / 2.0f); // // Calculate the player's ModelView Matrix // Matrix matrixModelView = Matrix.CreateLookAt(new Vector3(dx, 1000.0f, dz), // new Vector3(Statics.collisionMapSize / 2, 0, Statics.collisionMapSize / 2), // Vector3.Up); // // Calculate the player's Projection Matrix // Matrix matrixProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 3.0f, // demoViewport.Width / demoViewport.Height, // 0.3f, // 100000f); // // Set shader parameters required by the demo // ShaderParameters.light0.SetValue(Statics.LevelSettings.lightInfo1); // ShaderParameters.light1.SetValue(Statics.LevelSettings.lightInfo2); // ShaderParameters.fogColor.SetValue(Statics.LevelSettings.fogColor); // ShaderParameters.fogDensity.SetValue(Statics.LevelSettings.fogDensity); // ShaderParameters.ViewProj.SetValue(matrixModelView * matrixProjection); // ShaderParameters.playerIsDead.SetValue(false); // if (Statics.LevelSettings.fogDensity != 0.0f) // { // ShaderParameters.fogDensity.SetValue(0.0003f); // } // ShaderParameters.EyePostion.SetValue(Matrix.Invert(matrixModelView)); // _objectLibrary.skySphere.Draw(new ModelManager()); // _objectLibrary.terrain.Draw(new ModelManager()); // } // // Draw the Player Demo Screen // public void DrawPlayerDemo(GraphicsDevice graphicsDevice, float dt, int playerIndex) // { // graphicsDevice.Viewport = demoViewport; // graphicsDevice.Clear(Color.Black); // gameScreenRotation += dt; // if (gameScreenRotation > Math.PI * 2.0f) // { // gameScreenRotation -= (float)Math.PI * 2.0f; // } // Matrix matrix = Matrix.CreateScale(_objectLibrary.humans[playerIndex].mass.scale); // float dx = (float)((Statics.PlayerSettings.DEFAULT_PLAYER_HEIGHT * 0.5f) * Math.Sin(gameScreenRotation)); // float dz = (float)((Statics.PlayerSettings.DEFAULT_PLAYER_HEIGHT * 0.5f) * Math.Cos(gameScreenRotation)); // // Calculate the player's ModelView Matrix // Matrix matrixModelView = Matrix.CreateLookAt(new Vector3(dx, 5.0f, dz), // new Vector3(0, 5.0f, 0), // Vector3.Up); // // Calculate the player's Projection Matrix // Matrix matrixProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 3.0f, // demoViewport.Width / demoViewport.Height, // 0.3f, // 100000f); // Statics.matrixModelView = matrixModelView; // Statics.matrixProjection = matrixProjection; // BoundingFrustum frustum = new BoundingFrustum(matrixModelView * matrixProjection); // ShaderParameters.light0.SetValue(Statics.LevelSettings.lightInfo1); // ShaderParameters.light1.SetValue(Statics.LevelSettings.lightInfo2); // ShaderParameters.fogColor.SetValue(new Vector4(0.0f)); // ShaderParameters.fogDensity.SetValue(0.0f); // ShaderParameters.World.SetValue(matrix); // ShaderParameters.ViewProj.SetValue(matrixModelView * matrixProjection); // ShaderParameters.playerIsDead.SetValue(false); // _objectLibrary.skySphere.Draw(new ModelManager()); // _objectLibrary.humans[playerIndex].DrawPlayerDemo(matrixModelView, matrixProjection); // } //*/