Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="game_time">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime game_time)
        {
            // user controller app exit
            // TODO: get this into exit event framework below.
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            ExitGameEvent e = mListener_ExitGameEvent.GetMaxOne();

            if (e != null)
            {
                // elaborate shutdown code goes here.
                Exit();
            }

            // TODO: Add your update logic here
            XTouch.Instance().Update(game_time);
            XKeyInput.Instance().Update();
            XMouse.Instance().Update(game_time);
            XUI.Instance().Update(game_time);
            XRootDebugMenu.Instance().Update();
            XWorld.Instance().Update();

            base.Update(game_time);
        }
Exemplo n.º 2
0
        /// <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()
        {
            XBulletinBoard.Instance().Init();
            XTouch.Instance().Init();
            XKeyInput.Instance().Init();
            XWorld.Instance().Init();
            XMouse.Instance().Init();
            XFontDraw.Instance().Init(GraphicsDevice, Content);
            XRenderManager.Instance().Initialize(GraphicsDevice, mGraphicsDeviceManager, Content);
            XUI.Instance().Init();
            XRootDebugMenu.Instance().Init();

            base.Initialize();

            XBulletinBoard.Instance().mBroadcaster_ExitGameEvent.Subscribe(mListener_ExitGameEvent);
        }
Exemplo n.º 3
0
        public Game1()
        {
            mGraphicsDeviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory  = "Content";

            mListener_ExitGameEvent = new XListener <ExitGameEvent>(1, eEventQueueFullBehaviour.Ignore, "ExitGame");

            XBulletinBoard.CreateInstance();
            XFontDraw.CreateInstance();
            XRenderManager.CreateInstance();
            XTouch.CreateInstance();
            XKeyInput.CreateInstance();
            XWorld.CreateInstance();
            XMouse.CreateInstance();
            XUI.CreateInstance();
            XRootDebugMenu.CreateInstance();
        }
Exemplo n.º 4
0
        public void Draw(GameTime game_time)
        {
            mGraphicsDevice.Clear(Color.CornflowerBlue);

            RasterizerState rasterizerState = new RasterizerState();

            rasterizerState.CullMode        = CullMode.None;
            mGraphicsDevice.RasterizerState = rasterizerState;

            // maybe not the best place for this
            // also, screen cam not updating anywhere
            mMainWorldCam.Update(game_time);
            UpdateCameras();

            // simple draw only clients
            XWorld.Instance().RenderWorld(game_time, mMainWorldCam.GetViewAABB());
            XMouse mouse = XMouse.Instance();

            mouse.RenderWorld(game_time);
            mouse.RenderScreen(game_time);
            XUI.Instance().Draw();

            mBasicEffect_World.VertexColorEnabled = true;

            XSimpleDraw simple_draw_world_transient      = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Transient);
            XSimpleDraw simple_draw_world_persistent     = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent);
            XSimpleDraw simple_draw_screen_transient     = XSimpleDraw.Instance(xeSimpleDrawType.ScreenSpace_Transient);
            XSimpleDraw simple_draw_screen_persistent    = XSimpleDraw.Instance(xeSimpleDrawType.ScreenSpace_Persistent);
            XSimpleDraw simple_draw_world_map_persistent = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent_Map);

            foreach (EffectPass pass in mBasicEffect_World.CurrentTechnique.Passes)
            {
                pass.Apply();

                // actually render simple draw stuff.  possible layers needed.
                simple_draw_world_map_persistent.DrawAllPrimitives();
                simple_draw_world_persistent.DrawAllPrimitives();
                simple_draw_world_transient.DrawAllPrimitives();

                // render clients who do their own rendering.  they should probably have pre-renders like simple draw, especially if there is more than one pass.
            }

            // simple draw screen
            mBasicEffect_Screen.VertexColorEnabled = true;

            //foreach ( EffectPass pass in effectPassCollection )
            foreach (EffectPass pass in mBasicEffect_Screen.CurrentTechnique.Passes)
            {
                pass.Apply();

                // actually render simple draw stuff.  possible layers needed.
                simple_draw_screen_persistent.DrawAllPrimitives();
                simple_draw_screen_transient.DrawAllPrimitives();

                // render clients who do their own rendering.  they should probably have pre-renders like simple draw, especially if there is more than one pass.
            }

            //mSpriteBatch.Begin();
            // do sprite batch rendering here
            //mSpriteBatch.End();

            XFontDraw.Instance().Draw();
        }