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 void Update(GameTime game_time)
 {
     if (mTestTriggerCount == 0 && mListener_FourContacts.GetMaxOne() != null)
     {
         ++mTestTriggerCount;
         //Test_Label();
         //Test_Panel();
         Test_Button();
     }
 }
Esempio n. 3
0
        void XICamera.Update(GameTime game_time)
        {
            if (mListener_WorldRegenerated.GetMaxOne() != null)
            {
                InitFromWorld();
            }

            XTouch.MultiDragData multi_drag_msg = mListener_MultiDrag.GetMaxOne();

            if (multi_drag_msg != null)
            {
                if (multi_drag_msg.mFrameCount == 0)
                {
                    mMultiDragPrev = multi_drag_msg;
                }

                // figure out zoom.  damp so that human powered drag zoom is not jittery.
                // it's not that there is anything wrong with the measurement or the calculation, it's
                // that people don't seem to keep their fingers at constant separation when they mean to.
                const float k_zoom_damping   = 0.8f;
                float       ideal_zoom_ratio = (float)(mMultiDragPrev.mMaxScreenSeparation / multi_drag_msg.mMaxScreenSeparation);

                float zoom_ratio = (mDampedMaxScreenSeparation > -1f)                                                                                                                  ?
                                   (k_zoom_damping * mDampedMaxScreenSeparation + (1f - k_zoom_damping) * ideal_zoom_ratio)        :
                                   ideal_zoom_ratio;

                mDampedMaxScreenSeparation = zoom_ratio;

                // place new world view so that the zoom point in world space is at the same place on the screen.
                Vector2 size_0         = mWorldView.GetSize();
                Vector2 size_1         = zoom_ratio * size_0;
                Vector2 avg_world_pos  = CalcWorldPos(multi_drag_msg.mAvgScreenPos);
                float   pos_x_fraction = multi_drag_msg.mAvgScreenPos.X / mScreenDim.x;
                float   pos_y_fraction = multi_drag_msg.mAvgScreenPos.Y / mScreenDim.y;
                float   dx_world       = pos_x_fraction * size_1.X;
                float   dy_world       = pos_y_fraction * size_1.Y;
                Vector2 p0             = new Vector2(avg_world_pos.X - dx_world, avg_world_pos.Y - dy_world);
                Vector2 p1             = p0 + size_1;
                xAABB2  world_view     = new xAABB2(p0, p1);

                // figure out translation
                // this calculation assumes fullscreen, viewport not taken into consideration
                Vector2 pixel_move      = multi_drag_msg.mAvgScreenPos - mMultiDragPrev.mAvgScreenPos;
                Vector2 screen_fraction = new Vector2(pixel_move.X / mScreenDim.x, pixel_move.Y / mScreenDim.y);
                Vector2 world_view_size = world_view.GetSize();
                Vector2 world_move      = new Vector2(screen_fraction.X * world_view_size.X, screen_fraction.Y * world_view_size.Y);
                world_view.Translate(-world_move);
                mMultiDragPrev = multi_drag_msg;

                // clamp and calc projection matrix
                mWorldView = ClampWorldView(world_view);
                CalcProjectionMatrix();
            }
        }
Esempio n. 4
0
        public void Update()
        {
            // check for create menu
            var enumerator_fiveContacts = mListener_FiveContacts.CreateEnumerator();

            if (enumerator_fiveContacts.MoveNext())
            {
                if (mRootSelector == null)
                {
                    mRootSelector = XUI.Instance().CreateSelector(new XUI._Position(), "Debug Menu",
                                                                  XUI.eStyle.Frontend, XUI.eStyle.FrontendButton,
                                                                  XUI.eStyle.FrontendTitle, mOptions);
                }
            }

            // check for menu selection
            var selection_data = mListener_SelectorSelection.GetMaxOne();

            if (selection_data != null)
            {
                if (selection_data.mSelectorID == mRootSelector.GetID())
                {
                    // destroy this selector
                    XUI.Instance().DestroySelector(mRootSelector.GetID());
                    mRootSelector = null;

                    switch (selection_data.mIndexSelected)
                    {
                    case 0:
                        // map selected, sent message for that system to do what it wants
                        Console.WriteLine("map selected");
                        mBroadcaster_MenuSelection.Post(new MenuSelectionEvent(selection_data.mSelectorID, mOptions[0]));
                        break;

                    case 2:
                        // exit selected, do nothing, menu will close
                        break;

                    case 4:
                        // quit selected, send message to end program.  this menu will close
                        XBulletinBoard.Instance().mBroadcaster_ExitGameEvent.Post(new Game1.ExitGameEvent());
                        break;

                    default:
                        // problem
                        XUtils.Assert(false);
                        break;
                    }
                }
            }
        }