Ejemplo n.º 1
0
        void CustomActivity(bool firstTimeCalled)
        {
            PlayerCharacterInstance.CollideAgainst(() => mTileSolidCollision.CollideAgainstSolid(PlayerCharacterInstance.Collision), false);

            //this.PlayerCharacterInstance.CollideAgainst(SolidCollisions);
            this.PlayerCharacterInstance.DetermineMovementValues();
            Camera.Main.X = PlayerCharacterInstance.X;


            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryClick)
            {
                float x = cursor.WorldXAt(0);
                float y = cursor.WorldYAt(0);

                if (mTileSolidCollision.GetTileAt(x, y) == null)
                {
                    mTileSolidCollision.AddCollisionAtWorld(x, y);
                }
                else
                {
                    mTileSolidCollision.RemoveCollisionAtWorld(x, y);
                }
            }
        }
Ejemplo n.º 2
0
        private void HandleShowCursor()
        {
            FlatRedBall.Gui.Cursor cursor = FlatRedBall.Gui.GuiManager.Cursor;

            mDataUiGrid.Instance = cursor;
            mDataUiGrid.MembersToIgnore.Add("si");
            mDataUiGrid.MembersToIgnore.Add("tipXOffset");
            mDataUiGrid.MembersToIgnore.Add("tipYOffset");
            mDataUiGrid.MembersToIgnore.Add("mWindowSecondaryPushed");
            mDataUiGrid.MembersToIgnore.Add("StaticPosition");
            mDataUiGrid.MembersToIgnore.Add("mWindowGrabbed");
            mDataUiGrid.MembersToIgnore.Add("ObjectGrabbedRelativeX");
            mDataUiGrid.MembersToIgnore.Add("ObjectGrabbedRelativeY");
        }
Ejemplo n.º 3
0
 public bool IsMouseOver(FlatRedBall.Gui.Cursor cursor, Layer layer)
 {
     return(cursor.IsOn3D(this, layer));
 }
Ejemplo n.º 4
0
 bool IMouseOver.IsMouseOver(FlatRedBall.Gui.Cursor cursor)
 {
     return(cursor.IsOn3D(this));
 }
Ejemplo n.º 5
0
        void CustomInitialize()
        {
            Cursor cursor = GuiManager.Cursor;


            cursor.ScreenX = 0;
            cursor.ScreenY = 0;

            float worldXAt = cursor.WorldXAt(0);
            float worldYAt = cursor.WorldYAt(0);

            // Unlayered
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working");
            }

            worldXAt = cursor.WorldXAt(0, FullScreenLayer2D);
            worldYAt = cursor.WorldYAt(0, FullScreenLayer2D);
            // Full screen layer:
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working");
            }

            // Do a half-screen X Layer now:
            worldXAt = cursor.WorldXAt(0, LeftHalfLayer);
            worldYAt = cursor.WorldYAt(0, LeftHalfLayer);
            // Full screen layer:
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with Layers that do not take up the full screen");
            }

            // Now a half screen Y layer:
            worldXAt = cursor.WorldXAt(0, TopHalfLayer);
            worldYAt = cursor.WorldYAt(0, TopHalfLayer);
            // Full screen layer:
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0)) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with Layers that do not take up the full screen");
            }


            ZoomedLayer.LayerCameraSettings.OrthogonalWidth  /= 2.0f;
            ZoomedLayer.LayerCameraSettings.OrthogonalHeight /= 2.0f;
            worldXAt = cursor.WorldXAt(0, ZoomedLayer);
            worldYAt = cursor.WorldYAt(0, ZoomedLayer);
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0) / 2.0f) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with zoomed Layers");
            }
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0) / 2.0f) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with zoomed Layers");
            }

            Camera.Main.OrthogonalHeight /= 2;
            Camera.Main.OrthogonalWidth  /= 2;
            worldXAt = cursor.WorldXAt(0, ZoomedLayer);
            worldYAt = cursor.WorldYAt(0, ZoomedLayer);
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with zoomed Layers");
            }
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0)) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with zoomed Layers");
            }
        }
Ejemplo n.º 6
0
 public bool IsCursorOverSprite(Cursor cursor)
 {
     return(SpriteInstance.Alpha != 0 && SpriteInstance.AbsoluteVisible && cursor.IsOn3D(SpriteInstance, LayerProvidedByContainer));
 }
Ejemplo n.º 7
0
        void CustomInitialize()
        {
            Cursor cursor = GuiManager.Cursor;


            cursor.ScreenX = Camera.Main.DestinationRectangle.X;
            cursor.ScreenY = Camera.Main.DestinationRectangle.Y;

            float worldXAt = cursor.WorldXAt(0);
            float worldYAt = cursor.WorldYAt(0);

            // Unlayered
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working");
            }

            worldXAt = cursor.WorldXAt(0, FullScreenLayer2D);
            worldYAt = cursor.WorldYAt(0, FullScreenLayer2D);
            // Full screen layer:
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working");
            }


            if (LeftHalfLayer.LayerCameraSettings.LeftDestination != Camera.Main.LeftDestination)
            {
                throw new Exception("The LeftHalfLayer's left side should be aligned with the left of the Camera destination rectangle");
            }

            var expectedLeftHalfRightBound = Camera.Main.DestinationRectangle.Left + Camera.Main.DestinationRectangle.Width / 2;

            if (LeftHalfLayer.LayerCameraSettings.RightDestination != expectedLeftHalfRightBound)
            {
                string message = "The LeftHalfLayer should occupy half of the screen. On scaled displays this should scale with the display too." +
                                 $" Expected:{expectedLeftHalfRightBound}, Actual:{LeftHalfLayer.LayerCameraSettings.RightDestination}";
                throw new Exception(message);
            }


            // Do a half-screen X Layer now:
            worldXAt = cursor.WorldXAt(0, LeftHalfLayer);
            worldYAt = cursor.WorldYAt(0, LeftHalfLayer);

            if (worldXAt != -500)
            {
                // Vic says - I'm actually not sure if this behaves correctly under the following circumstances:
                // Aspect ratio 2
                // Resolution width 1000
                // Resolution Height 600
                // FRB treats Y as the dominant value, so the actual camera ortho values are 1200x600, packed in a 1000x500 section
                // In this case the layer doesn't match the resolution of the camera, so...should it return -600? Or -500? I need to research, but putting
                // -500 to pass the test for now.
                throw new Exception("WorldXAt should be -500 ...maybe, see the comment above.");
            }

            var absoluteCameraLeftXEdge = Camera.Main.AbsoluteLeftXEdgeAt(0);

            // Full screen layer:
            if (System.Math.Abs(worldXAt - absoluteCameraLeftXEdge) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with Layers that do not take up the full screen");
            }

            // Now a half screen Y layer:
            worldXAt = cursor.WorldXAt(0, TopHalfLayer);
            worldYAt = cursor.WorldYAt(0, TopHalfLayer);
            // Full screen layer:
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0)) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with Layers that do not take up the full screen");
            }


            ZoomedLayer.LayerCameraSettings.OrthogonalWidth  /= 2.0f;
            ZoomedLayer.LayerCameraSettings.OrthogonalHeight /= 2.0f;
            worldXAt = cursor.WorldXAt(0, ZoomedLayer);
            worldYAt = cursor.WorldYAt(0, ZoomedLayer);
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0) / 2.0f) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with zoomed Layers");
            }
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0) / 2.0f) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with zoomed Layers");
            }

            Camera.Main.OrthogonalHeight /= 2;
            Camera.Main.OrthogonalWidth  /= 2;
            worldXAt = cursor.WorldXAt(0, ZoomedLayer);
            worldYAt = cursor.WorldYAt(0, ZoomedLayer);
            if (System.Math.Abs(worldXAt - Camera.Main.AbsoluteLeftXEdgeAt(0)) > 1)
            {
                throw new Exception("WorldXAt isn't working when dealing with zoomed Layers");
            }
            if (System.Math.Abs(worldYAt - Camera.Main.AbsoluteTopYEdgeAt(0)) > 1)
            {
                throw new Exception("WorldYAt isn't working when dealing with zoomed Layers");
            }
        }
Ejemplo n.º 8
0
        public static float GumX(this FlatRedBall.Gui.Cursor cursor)
        {
            var zoom = RenderingLibrary.SystemManagers.Default.Renderer.Camera.Zoom;

            return(cursor.ScreenX / zoom);
        }