Esempio 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);
        }
Esempio n. 2
0
        public XWorldCam(xCoord screen_dim)
        {
            mScreenDim = screen_dim;
            mAspect    = ((float)(screen_dim.y)) / screen_dim.x;
            InitFromWorld();

            mListener_MultiDrag = new XListener <XTouch.MultiDragData>(1, eEventQueueFullBehaviour.IgnoreOldest,
                                                                       "worldcammultidrag");
            XBulletinBoard.Instance().mBroadcaster_MultiDrag.Subscribe(mListener_MultiDrag);

            mListener_WorldRegenerated = new XListener <XWorld.WorldRegenerated>(1, eEventQueueFullBehaviour.IgnoreOldest,
                                                                                 "worldcamworldregenerated");
            XWorld.Instance().GetBroadcaster_WorldRegenerated().Subscribe(mListener_WorldRegenerated);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        private void InitFromWorld()
        {
            mWorldSize = XWorld.Instance().GetMapSize();

            // initial view of map
            xAABB2 world_view = new xAABB2(new Vector2(0, 0), new Vector2(mWorldSize.x, mWorldSize.y));

            mWorldView = ClampWorldView(world_view);

            // view matrix is unchanging
            Vector3 pos    = new Vector3(0, 0, 1f);
            Vector3 target = pos - 2f * Vector3.UnitZ;

            mViewMatrix = Matrix.CreateLookAt(pos, target, Vector3.UnitY);
            CalcProjectionMatrix();

            mMultiDragPrev             = new XTouch.MultiDragData(Vector2.Zero, 1f, 0);
            mDampedMaxScreenSeparation = -1f;
        }
Esempio n. 6
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();
        }