Exemplo n.º 1
0
        public override bool IsMouseOn(Vector2 position)
        {
            if (!base.IsMouseOn(position))
            {
                return(false);
            }

            if (StairDirection == Direction.None)
            {
                Vector2 rectSize = rect.Size.ToVector2();
                if (BodyWidth > 0.0f)
                {
                    rectSize.X = BodyWidth;
                }
                if (BodyHeight > 0.0f)
                {
                    rectSize.Y = BodyHeight;
                }

                Vector2 bodyPos = WorldPosition + BodyOffset;

                Vector2 transformedMousePos = MathUtils.RotatePointAroundTarget(position, bodyPos, MathHelper.ToDegrees(BodyRotation));

                return
                    (Math.Abs(transformedMousePos.X - bodyPos.X) < rectSize.X / 2.0f &&
                     Math.Abs(transformedMousePos.Y - bodyPos.Y) < rectSize.Y / 2.0f);
            }
            else
            {
                if (StairDirection == Direction.Left)
                {
                    return(MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y), new Vector2(WorldRect.Right, WorldRect.Y - WorldRect.Height), position) < 40.0f);
                }
                else
                {
                    return(MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y - rect.Height), new Vector2(WorldRect.Right, WorldRect.Y), position) < 40.0f);
                }
            }
        }
Exemplo n.º 2
0
        public override bool IsMouseOn(Vector2 position)
        {
            if (StairDirection == Direction.None)
            {
                return(base.IsMouseOn(position));
            }
            else
            {
                if (!base.IsMouseOn(position))
                {
                    return(false);
                }

                if (StairDirection == Direction.Left)
                {
                    return(MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y), new Vector2(WorldRect.Right, WorldRect.Y - WorldRect.Height), position) < 40.0f);
                }
                else
                {
                    return(MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y - rect.Height), new Vector2(WorldRect.Right, WorldRect.Y), position) < 40.0f);
                }
            }
        }