/// <summary>
        /// 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.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            Components.Add(new GUIManager(this));
            Components.Add(new Camera(this));
            Components.Add(new InputHandler(this));
            Components.Add(new PhysicsManager(this));
            Components.Add(new Level(this, "level1"));

            console = new DeveloperConsole(this);
            Components.Add(console);

            // Gosh I'm tricksy
            console.DrawOrder = 9999999;


            console.MessageHandler += new DeveloperConsole.DeveloperConsoleMessageHandler(ConsoleMessageHandler);

            // attempt at AA : Taken from http://www.xnasociety.com/articles/4
            graphics.PreferMultiSampling      = true;
            graphics.PreparingDeviceSettings += DeviceSettings;
            graphics.ApplyChanges();

            base.Initialize();
        }
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            input   = (InputHandler)Game.Services.GetService(typeof(IInputHandler));
            console = (DeveloperConsole)Game.Services.GetService(typeof(IDeveloperConsole));
            console.MessageHandler += new DeveloperConsole.DeveloperConsoleMessageHandler(ConsoleMessageHandler);
            camera     = (Camera)Game.Services.GetService(typeof(ICamera));
            guimanager = (GUIManager)Game.Services.GetService(typeof(IGUIManager));

            // Define the World
            Simulator = new PhysicsSimulator(new Vector2(0, 8));
            debugView = new PhysicsSimulatorView(Simulator);

            base.Initialize();

            controlPanel = new GUIPhysicsControls(Game);
            controlPanel.Initialize();
            guimanager.AddComponent(controlPanel);
            GUIButton btn = (GUIButton)controlPanel.getComponent("pause");

            btn.OnMouseClick += new GUIButton.MouseClickHandler(PauseButtonMouseClick);

            btn = (GUIButton)controlPanel.getComponent("play");
            btn.OnMouseClick += new GUIButton.MouseClickHandler(PlayButtonMouseClick);

            statusLabel = (GUILabel)controlPanel.getComponent("status");
            //start off paused.
            Paused = true;

            GUICheckbox cb = (GUICheckbox)controlPanel.getComponent("debugdraw");

            cb.CheckStateChange += new GUICheckbox.CheckChangeEventHandler(DebugDrawCheckStateChanged);
            cb.Checked           = debugDraw;
        }
示例#3
0
 public override void Initialize()
 {
     base.Initialize();
     ScreenCentre.X          = Game.GraphicsDevice.Viewport.Width / 2;
     ScreenCentre.Y          = Game.GraphicsDevice.Viewport.Height / 2;
     input                   = (InputHandler)Game.Services.GetService(typeof(IInputHandler));
     console                 = (DeveloperConsole)Game.Services.GetService(typeof(IDeveloperConsole));
     console.MessageHandler += new DeveloperConsole.DeveloperConsoleMessageHandler(ConsoleMessageHandler);
 }
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            screenCentre = new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height / 2);
            Mouse.SetPosition(Convert.ToInt32(screenCentre.X), Convert.ToInt32(screenCentre.Y));

            console = (DeveloperConsole)Game.Services.GetService(typeof(IDeveloperConsole));
            base.Initialize();
        }
示例#5
0
        public virtual void Initialise(Game game, Vector2 startingPosition)
        {
            camera         = (Camera)game.Services.GetService(typeof(ICamera));
            physicsManager = (PhysicsManager)game.Services.GetService(typeof(IPhysicsManager));
            console        = (DeveloperConsole)game.Services.GetService(typeof(IDeveloperConsole));

            this.game      = game;
            screenCentre.X = game.GraphicsDevice.Viewport.Width / 2;
            screenCentre.Y = game.GraphicsDevice.Viewport.Height / 2;
            ScreenDepth    = 0.0f;
            WorldPosition  = startingPosition;
        }
示例#6
0
        protected override void LoadContent()
        {
            base.LoadContent();
            artBatch  = new SpriteBatch(GraphicsDevice);
            gridBatch = new PrimitiveBatch(GraphicsDevice);

            input   = (InputHandler)Game.Services.GetService(typeof(IInputHandler));
            camera  = (Camera)Game.Services.GetService(typeof(ICamera));
            console = (DeveloperConsole)Game.Services.GetService(typeof(IDeveloperConsole));

            guimanager = (GUIManager)Game.Services.GetService(typeof(IGUIManager));

            console.MessageHandler += new DeveloperConsole.DeveloperConsoleMessageHandler(ConsoleMessageHandler);
            LoadLevel(LevelFilename);

            InitEditor();
            //Random r = new Random();
            //for (var i = 0; i < 100; i++)
            //{
            //    DynamicObjects.Add(new DynamicLevelObject(Game, new Vector2(r.Next(200)-100, 50 - r.Next(400)), @"LevelArt\WallTest01"));
            //}
        }