Esempio n. 1
0
        public virtual void Reset(int from, int to, int image, Glowing glowing, ICallback listener)
        {
            Revive();

            View(image, glowing);

            _callback = listener;

            Point(DungeonTilemap.TileToWorld(from));
            var dest = DungeonTilemap.TileToWorld(to);

            var d = PointF.Diff(dest, Point());

            Speed.Set(d).Normalize().Scale(SPEED);

            if (image == 31 || image == 108 || image == 109 || image == 110)
            {
                AngularSpeed = 0;
                Angle        = 135 - (float)(Math.Atan2(d.X, d.Y) / 3.1415926 * 180);
            }
            else
            {
                AngularSpeed = image == 15 || image == 106 ? 1440 : 720;
            }

            var tweener = new PosTweener(this, dest, d.Length / SPEED);

            tweener.Listener = this;
            Parent.Add(tweener);
        }
Esempio n. 2
0
        public virtual void Reset(int from, int to, ICallback callback)
        {
            _callback = callback;

            Revive();

            var pf = DungeonTilemap.TileCenterToWorld(from);
            var pt = DungeonTilemap.TileCenterToWorld(to);

            x      = pf.X;
            y      = pf.Y;
            Width  = 0;
            Height = 0;

            var d     = PointF.Diff(pt, pf);
            var speed = new PointF(d).Normalize().Scale(Speed);

            _sx   = speed.X;
            _sy   = speed.Y;
            _time = d.Length / Speed;
        }
Esempio n. 3
0
            protected override void OnDrag(Touch t)
            {
                if (_dragging)
                {
                    var content = _scrollPane.Content();
                    var c       = content.Camera;

                    c.Scroll.Offset(PointF.Diff(_lastPos, t.Current).InvScale(c.Zoom));

                    if (c.Scroll.X + Width > content.Width)
                    {
                        c.Scroll.X = content.Width - Width;
                    }

                    if (c.Scroll.X < 0)
                    {
                        c.Scroll.X = 0;
                    }

                    if (c.Scroll.Y + Height > content.Height)
                    {
                        c.Scroll.Y = content.Height - Height;
                    }

                    if (c.Scroll.Y < 0)
                    {
                        c.Scroll.Y = 0;
                    }

                    _lastPos.Set(t.Current);
                }
                else
                if (PointF.Distance(t.Current, t.Start) > _dragThreshold)
                {
                    _dragging = true;
                    _lastPos.Set(t.Current);
                }
            }
Esempio n. 4
0
        protected override void OnDrag(Touch t)
        {
            Camera.Target = null;

            if (_pinching)
            {
                var curSpan = PointF.Distance(Touch.Current, _another.Current);
                Camera.ZoomTo(GameMath.Gate(PixelScene.minZoom, _startZoom * curSpan / _startSpan, PixelScene.maxZoom));
            }
            else
            {
                if (!_dragging && PointF.Distance(t.Current, t.Start) > _dragThreshold)
                {
                    _dragging = true;
                    _lastPos.Set(t.Current);
                }
                else if (_dragging)
                {
                    Camera.Scroll.Offset(PointF.Diff(_lastPos, t.Current).InvScale(Camera.Zoom));
                    _lastPos.Set(t.Current);
                }
            }
        }