示例#1
0
        private bool MoveCharacterByMouseInput()
        {
            if ((_rightMousePressed || _continueRunning) && World.InGame) // && !Pathfinder.AutoWalking)
            {
                if (Pathfinder.AutoWalking)
                {
                    Pathfinder.StopAutoWalk();
                }

                int x = ProfileManager.CurrentProfile.GameWindowPosition.X + (ProfileManager.CurrentProfile.GameWindowSize.X >> 1);
                int y = ProfileManager.CurrentProfile.GameWindowPosition.Y + (ProfileManager.CurrentProfile.GameWindowSize.Y >> 1);

                Direction direction = (Direction)GameCursor.GetMouseDirection
                                      (
                    x,
                    y,
                    Mouse.Position.X,
                    Mouse.Position.Y,
                    1
                                      );

                double mouseRange = MathHelper.Hypotenuse(x - Mouse.Position.X, y - Mouse.Position.Y);

                Direction facing = direction;

                if (facing == Direction.North)
                {
                    facing = (Direction)8;
                }

                bool run = mouseRange >= 190;

                if (World.Player.IsDrivingBoat)
                {
                    if (!_boatIsMoving || _boatRun != run || _lastBoatDirection != facing - 1)
                    {
                        _boatRun           = run;
                        _lastBoatDirection = facing - 1;
                        _boatIsMoving      = true;

                        BoatMovingManager.MoveRequest(facing - 1, (byte)(run ? 2 : 1));
                    }
                }
                else
                {
                    World.Player.Walk(facing - 1, run);
                }

                return(true);
            }

            return(false);
        }
示例#2
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            if (!World.InGame)
            {
                Dispose();
            }

            var scene = Engine.SceneManager.GetScene <GameScene>();

            if (IsDisposed || Engine.Profile.Current == null || scene == null)
            {
                return;
            }

            Direction dir    = (Direction)GameCursor.GetMouseDirection(World.Player.X, World.Player.Y, _mx, _my, 0);
            ushort    gumpID = (ushort)(0x1194 + ((int)dir + 1) % 8);

            if (_direction != dir || _arrow == null)
            {
                _direction = dir;

                if (_arrow == null)
                {
                    Add(_arrow = new GumpPic(0, 0, gumpID, 0));
                }
                else
                {
                    _arrow.Graphic = gumpID;
                }
            }

            int gox = _mx - World.Player.X;
            int goy = _my - World.Player.Y;

            int x = Engine.Profile.Current.GameWindowPosition.X + (Engine.Profile.Current.GameWindowSize.X >> 1) + ((gox - goy) * 22 - _arrow.Width);
            int y = Engine.Profile.Current.GameWindowPosition.Y + (Engine.Profile.Current.GameWindowSize.Y >> 1) + (gox + goy) * 22 + _arrow.Height * 2;

            if (x < Engine.Profile.Current.GameWindowPosition.X)
            {
                x = Engine.Profile.Current.GameWindowPosition.X;
            }
            else if (x > Engine.Profile.Current.GameWindowPosition.X + Engine.Profile.Current.GameWindowSize.X - _arrow.Width)
            {
                x = Engine.Profile.Current.GameWindowPosition.X + Engine.Profile.Current.GameWindowSize.X - _arrow.Width;
            }


            if (y < Engine.Profile.Current.GameWindowPosition.Y)
            {
                y = Engine.Profile.Current.GameWindowPosition.Y;
            }
            else if (y > Engine.Profile.Current.GameWindowPosition.Y + Engine.Profile.Current.GameWindowSize.Y - _arrow.Height)
            {
                y = Engine.Profile.Current.GameWindowPosition.Y + Engine.Profile.Current.GameWindowSize.Y - _arrow.Height;
            }
            var scale = scene.Scale;

            X = (int)(x / scale);
            Y = (int)(y / scale);

            if (_timer < Engine.Ticks)
            {
                _timer   = Engine.Ticks + 1000;
                _needHue = !_needHue;
            }

            _arrow.Hue = (Hue)(_needHue ? 0 : 0x21);
        }
示例#3
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            if (!World.InGame)
            {
                Dispose();
            }

            var scene = CUOEnviroment.Client.GetScene <GameScene>();

            if (IsDisposed || ProfileManager.Current == null || scene == null)
            {
                return;
            }

            Direction dir    = (Direction)GameCursor.GetMouseDirection(World.Player.X, World.Player.Y, _mx, _my, 0);
            ushort    gumpID = (ushort)(0x1194 + ((int)dir + 1) % 8);

            if (_direction != dir || _arrow == null)
            {
                _direction = dir;

                if (_arrow == null)
                {
                    Add(_arrow = new GumpPic(0, 0, gumpID, 0));
                }
                else
                {
                    _arrow.Graphic = gumpID;
                }

                Width  = _arrow.Width;
                Height = _arrow.Height;
            }

            var scale = scene.Scale;


            int gox = _mx - World.Player.X;
            int goy = _my - World.Player.Y;


            int x = (ProfileManager.Current.GameWindowPosition.X + (ProfileManager.Current.GameWindowSize.X >> 1)) + 6 + ((gox - goy) * (int)(22 / scale)) - (int)((_arrow.Width / 2f) / scale);
            int y = (ProfileManager.Current.GameWindowPosition.Y + (ProfileManager.Current.GameWindowSize.Y >> 1)) + 6 + ((gox + goy) * (int)(22 / scale)) + (int)((_arrow.Height) / scale);

            x -= (int)(World.Player.Offset.X / scale);
            y -= (int)(((World.Player.Offset.Y - World.Player.Offset.Z) + (World.Player.Z >> 2)) / scale);


            if (x < ProfileManager.Current.GameWindowPosition.X)
            {
                x = ProfileManager.Current.GameWindowPosition.X;
            }
            else if (x > ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width)
            {
                x = ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width;
            }


            if (y < ProfileManager.Current.GameWindowPosition.Y)
            {
                y = ProfileManager.Current.GameWindowPosition.Y;
            }
            else if (y > ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height)
            {
                y = ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height;
            }

            X = x;
            Y = y;

            if (_timer < Time.Ticks)
            {
                _timer   = Time.Ticks + 1000;
                _needHue = !_needHue;
            }

            _arrow.Hue = (Hue)(_needHue ? 0 : 0x21);
        }
示例#4
0
        public override void Update(double totalTime, double frameTime)
        {
            base.Update(totalTime, frameTime);

            if (!World.InGame)
            {
                Dispose();
            }

            GameScene scene = Client.Game.GetScene <GameScene>();

            if (IsDisposed || ProfileManager.CurrentProfile == null || scene == null)
            {
                return;
            }

            Direction dir    = (Direction)GameCursor.GetMouseDirection(World.Player.X, World.Player.Y, _mx, _my, 0);
            ushort    gumpID = (ushort)(0x1194 + ((int)dir + 1) % 8);

            if (_direction != dir || _arrow == null)
            {
                _direction = dir;

                if (_arrow == null)
                {
                    Add(_arrow = new GumpPic(0, 0, gumpID, 0));
                }
                else
                {
                    _arrow.Graphic = gumpID;
                }

                Width  = _arrow.Width;
                Height = _arrow.Height;
            }

            int gox = World.Player.X - _mx;
            int goy = World.Player.Y - _my;


            int x = (ProfileManager.CurrentProfile.GameWindowSize.X >> 1) - (gox - goy) * 22;
            int y = (ProfileManager.CurrentProfile.GameWindowSize.Y >> 1) - (gox + goy) * 22;

            x -= (int)World.Player.Offset.X;
            y -= (int)(World.Player.Offset.Y - World.Player.Offset.Z);
            y += World.Player.Z << 2;


            switch (dir)
            {
            case Direction.North:
                x -= _arrow.Width;

                break;

            case Direction.South:
                y -= _arrow.Height;

                break;

            case Direction.East:
                x -= _arrow.Width;
                y -= _arrow.Height;

                break;

            case Direction.West: break;

            case Direction.Right:
                x -= _arrow.Width;
                y -= _arrow.Height / 2;

                break;

            case Direction.Left:
                x += _arrow.Width / 2;
                y -= _arrow.Height / 2;

                break;

            case Direction.Up:
                x -= _arrow.Width / 2;
                y += _arrow.Height / 2;

                break;

            case Direction.Down:
                x -= _arrow.Width / 2;
                y -= _arrow.Height;

                break;
            }


            Point p = new Point(x, y);

            p    = Client.Game.Scene.Camera.WorldToScreen(p);
            p.X += ProfileManager.CurrentProfile.GameWindowPosition.X;
            p.Y += ProfileManager.CurrentProfile.GameWindowPosition.Y;
            x    = p.X;
            y    = p.Y;

            if (x < ProfileManager.CurrentProfile.GameWindowPosition.X)
            {
                x = ProfileManager.CurrentProfile.GameWindowPosition.X;
            }
            else if (x > ProfileManager.CurrentProfile.GameWindowPosition.X + ProfileManager.CurrentProfile.GameWindowSize.X -
                     _arrow.Width)
            {
                x = ProfileManager.CurrentProfile.GameWindowPosition.X + ProfileManager.CurrentProfile.GameWindowSize.X -
                    _arrow.Width;
            }


            if (y < ProfileManager.CurrentProfile.GameWindowPosition.Y)
            {
                y = ProfileManager.CurrentProfile.GameWindowPosition.Y;
            }
            else if (y > ProfileManager.CurrentProfile.GameWindowPosition.Y + ProfileManager.CurrentProfile.GameWindowSize.Y -
                     _arrow.Height)
            {
                y = ProfileManager.CurrentProfile.GameWindowPosition.Y + ProfileManager.CurrentProfile.GameWindowSize.Y -
                    _arrow.Height;
            }

            X = x;
            Y = y;

            if (_timer < Time.Ticks)
            {
                _timer   = Time.Ticks + 1000;
                _needHue = !_needHue;
            }

            _arrow.Hue = (ushort)(_needHue ? 0 : 0x21);
        }