using System; using System.Collections.Generic; using System.Linq; using System.Text; using DW.UserInterface_2D; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using DarkWynter.Engine.Menus; using DWGame.Globals; using DWGame; using DWControllerDemo; namespace DW.Stream { public class Renderer { public static List cameras; GraphicsDevice graphics; SpriteBatch spriteBatch; public static Vector2 screenSize; public static MenuSystem menuSystem; public Renderer(GraphicsDevice g) { graphics = g; cameras = new List(); menuSystem = new MenuSystem(); } public void AddCamera(Camera camera) { cameras.Add(camera); camera.viewport = graphics.Viewport; } public void Initialize() { // Renderer Initilize spriteBatch = new SpriteBatch(graphics); } public void Resize() { for (int x = 0; x < cameras.Count; x++) { cameras[x].Resize(); } } public void LoadContent() { for (int x = 0; x < cameras.Count; x++) { cameras[x].LoadContent(); } } public void UnloadContent() { for (int x = 0; x < cameras.Count; x++) { cameras[x].UnloadContent(); } } public void Update(GameTime gametime) { if (Statics.engineState == Enums_Engine.EngineState.MENU_MODE) { menuSystem.Update(); // Update all MenuControllers PhoenixGame.menuController = PhoenixGame.controllerManager.GetControllers(typeof(MenuController)); for (int i = 0; i < PhoenixGame.menuController.Count; i++) { PhoenixGame.menuController[i].Update(ref PhoenixGame.args); } } for (int x = 0; x < cameras.Count; x++) { cameras[x].Update(gametime); } } public void Draw(GraphicsDevice g, GameTime gametime) { g.Clear(Color.CornflowerBlue); if (Statics.engineState == Enums_Engine.EngineState.MENU_MODE) { menuSystem.Draw(spriteBatch); } if (Statics.engineState == Enums_Engine.EngineState.GAME_MODE) { // Draw each camera's view for (int i = 0; i < cameras.Count; i++) { cameras[i].Draw(g, gametime, spriteBatch); } } } } }