using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Net; using Microsoft.Xna.Framework.Storage; using DW.UserInterface_2D; using DW.Stream; using DWGame.Globals; using DarkWynter.Engine.Controllers; using DWControllerDemo; namespace DWGame { /// /// This is the main type for your game /// public class PhoenixGame :Microsoft.Xna.Framework.Game { Renderer renderer; GraphicsDeviceManager graphics; public static PhoenixGame _self; public static ControllerManager controllerManager; public static List args = new List(); public static List menuController; public static List gameController; public PhoenixGame() { graphics = new GraphicsDeviceManager(this); Statics.SystemSettings.content = new ContentManager(Services); Statics.SystemSettings.content.RootDirectory = "Content"; _self = this; } /// /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// protected override void Initialize() { graphics.IsFullScreen = false; Statics.gameFonts.Arial = Statics.SystemSettings.content.Load("_fonts/Arial"); renderer = new Renderer(graphics.GraphicsDevice); renderer.Initialize(); Statics.engineState = Enums_Engine.EngineState.MENU_MODE; // Create a List of Child Controllers List controllerTypes = new List(); controllerTypes.Add(typeof(MenuController)); controllerTypes.Add(typeof(GameController)); // Pass in Width and Height used by mouse. controllerManager = new ControllerManager(800,600, controllerTypes); // Pass “this” as EventArgs to Conroller delegates functions args.Add(this); base.Initialize(); } /// /// LoadContent will be called once per game and is the place to load /// all of your content. /// protected override void LoadContent() { base.LoadContent(); renderer.AddCamera(new Camera()); renderer.LoadContent(); } /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// protected override void UnloadContent() { base.UnloadContent(); renderer.UnloadContent(); } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. protected override void Update(GameTime gameTime) { // Checks if any controllers Added or Removed controllerManager.Update(); base.Update(gameTime); renderer.Update(gameTime); //// Allows the game to exit //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) // this.Exit(); } /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. protected override void Draw(GameTime gameTime) { renderer.Draw(this.GraphicsDevice, gameTime); base.Draw(gameTime); } } }