//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Game { #region Using Statements using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Threading; using System.Net; 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 System.Windows.Forms; using System.Collections; using DarkWynter.Engine; using DarkWynter.Engine.Globals; using DarkWynter.Engine.Menus; using DarkWynter.Engine.Networking; using DarkWynter.Engine.Utilities; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.EventControl; using DarkWynter.Game.GameObjects; using DarkWynter.Stream; //using WindowsGame2; //using CSTextEditor; /// /// Base class for creating a game using the DarkWynter Engine. /// DarkWynterEngine extends object modification to the user through XML. /// DakrWynterEngine extends functionality to the user through overridable objects. /// public class DarkWynterGame : DarkWynterEngine { #region Properties //-- COMPILER //Panel drawSurface; //MainForm compilerForm; //Form gameForm; ///// ///// Simple Network Client ///// //private Client chatClient; #endregion #region Methods // --------------- Constructor ----------------- /// /// Main Engine Class. /// Check for Hardware Capabilities. /// Create GraphicsDeviceManager and ContentManager. /// public DarkWynterGame():base() { //-- COMPILER //drawSurface = new Panel(); //gameForm = Form.FromHandle(this.Window.Handle).FindForm(); //gameForm.IsMdiContainer = true; //compilerForm = new MainForm(); //compilerForm.MdiParent = gameForm; //Statics_Stream.RenderSettings.graphics.PreparingDeviceSettings += OnPreparingDeviceSettings; } ///// ///// Set Form Draw Surface to Window Handle ///// ///// ///// //private void OnPreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs args) //{ // args.GraphicsDeviceInformation.PresentationParameters.DeviceWindowHandle = drawSurface.Handle; //} // ----------------- Load ---------------------- /// /// Set Up Display Window. /// Create Logging, XML, GameFlow, Renderer, SpriteBatch, /// FontWriter, MenuSystem, Audio, ShaderParameters, ChatClient, /// Frames Per Second Counter, and Screensaver /// protected override void Initialize() { base.Initialize(new UserDefinedTypes()); #region Old Compiler Code //-- COMPILER //drawSurface.Width = Statics_Stream.RenderSettings.clientWidth; //drawSurface.Height = Statics_Stream.RenderSettings.clientHeight; //drawSurface.Dock = DockStyle.Top; //compilerForm.StartPosition = FormStartPosition.Manual; //compilerForm.Location= new System.Drawing.Point(0, 650); //compilerForm.Width = Statics_Stream.RenderSettings.clientWidth; //compilerForm.Height = Statics_Stream.RenderSettings.clientHeight - 650; //compilerForm.Dock = DockStyle.Bottom; //compilerForm.MinimizeBox = false; //compilerForm.MaximizeBox = false; //compilerForm.TopLevel = false; //compilerForm.FormBorderStyle = FormBorderStyle.None; //compilerForm.Show(); //compilerForm.BackColor = System.Drawing.Color.Black; //compilerForm.TransparencyKey = System.Drawing.Color.Black; //this.Window.AllowUserResizing = true; //gameForm.Text = "DarkWynterEngine Demo from www.darkwynter.com"; //gameForm.MinimizeBox = true; //gameForm.MaximizeBox = true; //gameForm.FormBorderStyle = FormBorderStyle.Fixed3D; //gameForm.Controls.Add(drawSurface); //gameForm.Controls.Add(compilerForm); this.IsMouseVisible = false; #endregion // Get a web page //string result = Socket_Simple.SocketSendReceive("DarkWynter.com", 80); // Open a chat connection //chatClient = new Client(); //chatClient.OpenConnection("amanda", 7777); } // --------------- Update --------------------- /// /// Update MenuSystemGame, Audio, FPS. /// Check For Level Loading Request. /// Check For Exit. /// /// XNA GameTime protected override void Update(GameTime gameTime) { // Game Update current section of Game Pipeline if (Statics_Engine.SystemSettings.gameState == Enums_Engine.EngineState.GAME_MODE) { //Update Event Handler GameEventHandler.UpdateEvents(); } // Check for user exit request CheckExit(); base.Update(gameTime); } // ----------------- Draw ---------------------- /// /// Draw Game or MenuSystem Screen /// /// XNA GameTime protected override void Draw(GameTime gameTime) { base.Draw(gameTime); renderer.DisableSpriteBatches(); } // ---------------- Exit ----------------------- /// /// Reset the Graphics Device Settings after using SpriteBatch. /// Use this function if you are experiencing weird effects after using SpriteBatch. /// /// /// Check to see if user has requested to exit the application. /// protected override void CheckExit() { if (Statics_Engine.SystemSettings.gameState == Enums_Engine.EngineState.EXIT) { DarkWynter.Engine.Controllers.Controller.StopRumble(objectLibrary); base.CheckExit(); } } #endregion private void InitializeComponent() { this.SuspendLayout(); // // DarkWynterGame // this.Name = "DarkWynterGame"; this.Size = new System.Drawing.Size(537, 314); this.ResumeLayout(false); } } }