private void MoveCharacterByInputs()
 {
     if (World.InGame && !Pathfinder.AutoWalking)
     {
         Point     center    = new Point(Engine.Profile.Current.GameWindowPosition.X + (Engine.Profile.Current.GameWindowSize.X >> 1), Engine.Profile.Current.GameWindowPosition.Y + (Engine.Profile.Current.GameWindowSize.Y >> 1));
         Direction direction = DirectionHelper.DirectionFromPoints(center, Mouse.Position);
         World.Player.Walk(direction, true);
     }
 }
Example #2
0
 private void MoveCharacterByInputs()
 {
     if (World.InGame)
     {
         Point     center    = new Point(_settings.GameWindowX + _settings.GameWindowWidth / 2, _settings.GameWindowY + _settings.GameWindowHeight / 2);
         Direction direction = DirectionHelper.DirectionFromPoints(center, Mouse.Position);
         World.Player.Walk(direction, true);
     }
 }
Example #3
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            var screenLeft = Engine.Profile.Current.GameWindowPosition.X;
            var screenTop  = Engine.Profile.Current.GameWindowPosition.Y;

            int screenRight  = screenLeft + Engine.Profile.Current.GameWindowSize.X;
            int screenBottom = screenTop + Engine.Profile.Current.GameWindowSize.Y;

            int screenCenterX = (screenRight - screenLeft) / 2;
            int screenCenterY = (screenBottom - screenTop) / 2;

            int offsetX = _mx - World.Player.X;
            int offsetY = _my - World.Player.Y;

            int drawX = screenLeft + (int)(screenCenterX + (offsetX - offsetY) * 22) + 3;
            int drawY = screenTop + (int)(screenCenterY + (offsetX + offsetY) * 22) + 3;

            var direction = DirectionHelper.DirectionFromPoints(
                new Point(screenCenterX, screenCenterY),
                new Point(drawX, drawY));

            if (_direction != direction || _arrow == null)
            {
                UpdateArrow(direction);
            }

            var arrowWidth  = _arrowBounds.Width;
            var arrowHeight = _arrowBounds.Height;

            drawX += (int)(_offsetTableX[(int)direction] * (arrowWidth + 22)) - (arrowWidth / 2);
            drawY += (int)(_offsetTableY[(int)direction] * (arrowHeight + 22)) - (arrowHeight / 2);

            if (drawX < screenLeft)
            {
                drawX = screenLeft;
            }
            if (drawY < screenTop)
            {
                drawY = screenTop;
            }

            if (drawX + arrowWidth > screenRight)
            {
                drawX = (screenRight - arrowWidth);
            }
            if (drawY + arrowHeight > screenBottom)
            {
                drawY = (screenBottom - arrowHeight);
            }

            X = drawX;
            Y = drawY;
        }
Example #4
0
        private void doMouseMovement(double frameMS)
        {
            Mobile player = (Mobile)WorldModel.Entities.GetPlayerEntity();

            if (player == null)
            {
                return;
            }

            // if the move button is pressed, change facing and move based on mouse cursor direction.
            if (ContinuousMouseMovementCheck)
            {
                ResolutionProperty resolution = Settings.UserInterface.PlayWindowGumpResolution;
                Point     centerScreen        = new Point(resolution.Width / 2, resolution.Height / 2);
                Direction mouseDirection      = DirectionHelper.DirectionFromPoints(centerScreen, MouseOverWorldPosition);

                m_TimeSinceMovementButtonPressed += frameMS;

                if (m_TimeSinceMovementButtonPressed >= c_PauseBeforeMouseMovementMS)
                {
                    // Get the move direction.
                    Direction moveDirection = mouseDirection;

                    // add the running flag if the mouse cursor is far enough away from the center of the screen.
                    float distanceFromCenterOfScreen = Utility.DistanceBetweenTwoPoints(centerScreen, MouseOverWorldPosition);

                    if (distanceFromCenterOfScreen >= 150.0f || Settings.UserInterface.AlwaysRun)
                    {
                        moveDirection |= Direction.Running;
                    }

                    player.PlayerMobile_Move(moveDirection);
                }
                else
                {
                    // Get the move direction.
                    Direction facing = mouseDirection;
                    if (player.Facing != facing)
                    {
                        // Tell the player entity to change facing to this direction.
                        player.PlayerMobile_ChangeFacing(facing);
                        // reset the time since the mouse cursor was pressed - allows multiple facing changes.
                        m_TimeSinceMovementButtonPressed = 0d;
                    }
                }
            }
            else
            {
                m_TimeSinceMovementButtonPressed = 0d;
                // Tell the player to stop moving.
                player.PlayerMobile_Move(Direction.Nothing);
            }
        }
Example #5
0
        private void MoveCharacterByInputs()
        {
            if (World.InGame && !Pathfinder.AutoWalking)
            {
                Point     center    = new Point(Engine.Profile.Current.GameWindowPosition.X + (Engine.Profile.Current.GameWindowSize.X >> 1), Engine.Profile.Current.GameWindowPosition.Y + (Engine.Profile.Current.GameWindowSize.Y >> 1));
                Direction direction = DirectionHelper.DirectionFromPoints(center, Mouse.Position);

                float distanceFromCenter = Utility.MathHelper.GetDistance(center, Mouse.Position);

                bool run = distanceFromCenter >= 150.0f;

                World.Player.Walk(direction, run);
            }
        }
Example #6
0
        protected override void BeforeDraw(SpriteBatchUI spriteBatch, Vector2Int position)
        {
            var player = WorldModel.Entities.GetPlayerEntity();

            // Hue the cursor if not in warmode and in trammel.
            if (WorldModel.IsInWorld && !player.Flags.IsWarMode && (_world.MapIndex == 1))
            {
                CursorHue = 2414;
            }
            else
            {
                CursorHue = 0;
            }
            if (IsHoldingItem)
            {
                ItemSpriteArtIndex = HeldItem.DisplayItemID;
                if (_itemSprite != null)
                {
                    _itemSprite.Hue    = HeldItem.Hue;
                    _itemSprite.Offset = _heldItemOffset;
                    if (HeldItem.Amount > 1 && HeldItem.ItemData.IsGeneric && HeldItem.DisplayItemID == HeldItem.ItemID)
                    {
                        int offset = HeldItem.ItemData.Unknown4;
                        _itemSprite.Draw(spriteBatch, new Vector2Int(position.x - 5, position.y - 5));
                    }
                    _itemSprite.Draw(spriteBatch, position);
                }
                // set up to draw standard cursor sprite above item art.
                base.BeforeDraw(spriteBatch, position);
            }
            else if (IsTargeting)
            {
                var artworkIndex = 8310;
                if (WorldModel.IsInWorld && player.Flags.IsWarMode)
                {
                    // Over the interface or not in world. Display a default cursor.
                    artworkIndex -= 23;
                }
                CursorSpriteArtIndex = artworkIndex;
                CursorOffset         = new Vector2Int(13, 13);
                // sourceRect = new RectInt(1, 1, 46, 34);

                /*if (_targetingMulti != -1)
                 * {
                 *  // UNIMPLEMENTED !!! Draw a transparent multi
                 * }*/
            }
            else if ((_world.Input.ContinuousMouseMovementCheck || _world.Input.IsMouseOverWorld) && !_userInterface.IsModalControlOpen)
            {
                var resolution     = UltimaGameSettings.UserInterface.PlayWindowGumpResolution;
                var mouseDirection = DirectionHelper.DirectionFromPoints(new Vector2Int(resolution.Width / 2, resolution.Height / 2), _world.Input.MouseOverWorldPosition);
                var artIndex       = 0;
                switch (mouseDirection)
                {
                case Direction.North:
                    CursorOffset = new Vector2Int(29, 1);
                    artIndex     = 8299;
                    break;

                case Direction.Right:
                    CursorOffset = new Vector2Int(41, 9);
                    artIndex     = 8300;
                    break;

                case Direction.East:
                    CursorOffset = new Vector2Int(36, 24);
                    artIndex     = 8301; break;

                case Direction.Down:
                    CursorOffset = new Vector2Int(14, 33);
                    artIndex     = 8302;
                    break;

                case Direction.South:
                    CursorOffset = new Vector2Int(2, 26);
                    artIndex     = 8303;
                    break;

                case Direction.Left:
                    CursorOffset = new Vector2Int(2, 10);
                    artIndex     = 8304;
                    break;

                case Direction.West:
                    CursorOffset = new Vector2Int(1, 1);
                    artIndex     = 8305;
                    break;

                case Direction.Up:
                    CursorOffset = new Vector2Int(4, 2);
                    artIndex     = 8298;
                    break;

                default:
                    CursorOffset = new Vector2Int(2, 10);
                    artIndex     = 8309;
                    break;
                }
                if (WorldModel.IsInWorld && player.Flags.IsWarMode)
                {
                    // Over the interface or not in world. Display a default cursor.
                    artIndex -= 23;
                }
                CursorSpriteArtIndex = artIndex;
            }
            // cursor is over UI or there is a modal message box open. Set up to draw standard cursor sprite.
            else
            {
                base.BeforeDraw(spriteBatch, position);
            }
        }
Example #7
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            var scale    = Engine.SceneManager.GetScene <GameScene>().Scale;
            var viewport = Engine.SceneManager.GetScene <GameScene>().Scale;

            var screenLeft   = Engine.Profile.Current.GameWindowPosition.X;
            var screenTop    = Engine.Profile.Current.GameWindowPosition.Y;
            int screenRight  = screenLeft + Engine.Profile.Current.GameWindowSize.X;
            int screenBottom = screenTop + Engine.Profile.Current.GameWindowSize.Y;



            var screenCenterX = ((screenRight - screenLeft) / 2);
            var screenCenterY = ((screenBottom - screenTop) / 2);

            var offsetX = ((_mx - World.Player.X) / scale);
            var offsetY = ((_my - World.Player.Y) / scale);
            var offsetZ = World.Map.GetTileZ(_mx, _my) / scale;

            int relativeX = (int)((screenCenterX + (offsetX - offsetY) * 22));
            int relativeY = (int)((screenCenterY + (offsetX + offsetY) * 22));

            var direction = DirectionHelper.DirectionFromPoints(
                new Point(screenCenterX, screenCenterY),
                new Point(relativeX, relativeY));

            int drawX = screenLeft + relativeX;
            int drawY = screenTop + relativeY;

            if (_direction != direction || _arrow == null)
            {
                UpdateArrow(direction);
            }

            var arrowWidth  = _arrowBounds.Width;
            var arrowHeight = _arrowBounds.Height;

            drawX += (int)((_offsetTableX[(int)direction] * (arrowWidth + 22)) - (arrowWidth / 2));
            drawY += (int)((_offsetTableY[(int)direction] * (arrowHeight + 22)) - (arrowHeight / 2));
            drawY -= (int)(offsetZ * 3);

            if (drawX < screenLeft)
            {
                drawX = screenLeft;
            }
            if (drawY < screenTop)
            {
                drawY = screenTop;
            }

            if (drawX + arrowWidth > screenRight)
            {
                drawX = (screenRight - arrowWidth);
            }
            if (drawY + arrowHeight > screenBottom)
            {
                drawY = (screenBottom - arrowHeight);
            }

            X = drawX;
            Y = drawY;
        }