示例#1
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            float oldX = systemCenter.X, oldY = systemCenter.Y;

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, oldX, oldY))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }

            GlVectorR2 moveVector = new GlVectorR2(x - this.systemCenter.X, y - this.systemCenter.Y);

            this.systemCenter = new GlPointR2(x, y);

            foreach (GlFigure F in this.figuresAmount)
            {
                GlPointR2 newCenter = moveVector.fromPointToPoint(F.Center);
                F.moveTo(newCenter.X, newCenter.Y);
            }

            if (OnMoved != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }
        }
示例#2
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.x, this.y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.x, this.y);
            }

            float oldX = this.x, oldy = this.y;

            this.X = x;
            this.Y = y;

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, oldX, oldy);
            }
        }
示例#3
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            float oldX = this.Center.X;
            float oldY = this.Center.Y;

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, oldX, oldY))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }

            this.systemCenter = new GlPointR2(x, y);
            updatePointsPosition();

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, oldX, oldY);
            }
        }
示例#4
0
文件: Piece.cs 项目: lipz89/Klotski
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (isDown)
     {
         if (Dir == Direction.Horizontal)
         {
             if (e.X - downPoint.X > this.Height)
             {
                 OnMoving?.Invoke(this, new BlockMoveArgs(MoveDir.Right));
             }
             else if (downPoint.X - e.X > this.Height)
             {
                 OnMoving?.Invoke(this, new BlockMoveArgs(MoveDir.Left));
             }
         }
         else
         {
             if (e.Y - downPoint.Y > this.Width)
             {
                 OnMoving?.Invoke(this, new BlockMoveArgs(MoveDir.Down));
             }
             else if (downPoint.Y - e.Y > this.Width)
             {
                 OnMoving?.Invoke(this, new BlockMoveArgs(MoveDir.Up));
             }
         }
     }
 }
示例#5
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.polyCenter.X, this.polyCenter.Y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.polyCenter.X, this.polyCenter.Y);
            }

            GlVectorR2 delta = new GlVectorR2(x - polyCenter.X, y - polyCenter.Y);

            for (int i = 0; i < vertexes.Length; i++)
            {
                vertexes[i] = delta.fromPointToPoint(vertexes[i]);
            }

            GlPointR2 OP = new GlPointR2(this.polyCenter);

            this.polyCenter = new GlPointR2(x, y);

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, OP.X, OP.Y);
            }
        }
示例#6
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public void moveTo(GlPointR2 newBelongsPoint)
        {
            if (newBelongsPoint == null || newBelongsPoint.isNullPoint())
            {
                return;
            }

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y);
            }

            GlPointR2 OP = new GlPointR2(this.PointOfLine);

            this.pointOfLine = newBelongsPoint;

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, OP.X, OP.Y);
            }
        }
示例#7
0
        /// <summary>
        /// Updates a move operation based of the provided position. <see cref="OnMoving"/>
        /// </summary>
        /// <returns>True if a move operation is running.</returns>
        public bool Drag(float x, float y)
        {
            if (!IsMoving)
            {
                return(false);
            }

            float dx = x - originX;
            float dy = y - originY;

            float nx = originalSelection.X + dx;
            float ny = originalSelection.Y + dy;

            Selection = new RectangleF(nx, ny, Selection.Width, Selection.Height);

            foreach (TransformerItem item in items)
            {
                item.Item.X = item.OriginX + dx;
                item.Item.Y = item.OriginY + dy;
            }

            OnMoving?.Invoke(this, EventArgs.Empty);

            return(true);
        }
示例#8
0
 public virtual void MoveTo(PositionInGrid direction)
 {
     Board.ElementMoveTo(this, direction.x, direction.y);
     if (AudioSource && MoveSound)
     {
         AudioSource.clip = MoveSound;
         AudioSource.Play();
     }
     OnMoving?.Invoke(this);
     transform.position += new Vector3(direction.x, direction.y);
 }
示例#9
0
    private void FixedUpdate()
    {
        OnMovingArgs args = new OnMovingArgs(movement + (AddGravity ? Physics.gravity : Vector3.zero));

        if (OnMoving != null)
        {
            OnMoving.Invoke(this, args);
        }

        if (!args.Cancel)
        {
            physics.velocity = (args.Velocity * MovementMultiplicator);
            movement         = Vector3.zero;
        }
    }
示例#10
0
        public virtual void OnMouseMove(MouseEventArgs e)
        {
            if (!_enabled)
            {
                return;
            }


            if (Moving)
            {
                Point tempPoint = CMain.MPoint.Subtract(_movePoint);

                if (Parent == null)
                {
                    if (tempPoint.Y + TrueSize.Height > Settings.ScreenHeight)
                    {
                        tempPoint.Y = Settings.ScreenHeight - TrueSize.Height - 1;
                    }

                    if (tempPoint.X + TrueSize.Width > Settings.ScreenWidth)
                    {
                        tempPoint.X = Settings.ScreenWidth - TrueSize.Width - 1;
                    }
                }
                else
                {
                    if (tempPoint.Y + TrueSize.Height > Parent.TrueSize.Height)
                    {
                        tempPoint.Y = Parent.TrueSize.Height - TrueSize.Height;
                    }

                    if (tempPoint.X + TrueSize.Width > Parent.TrueSize.Width)
                    {
                        tempPoint.X = Parent.TrueSize.Width - TrueSize.Width;
                    }
                }

                if (tempPoint.X < 0)
                {
                    tempPoint.X = 0;
                }
                if (tempPoint.Y < 0)
                {
                    tempPoint.Y = 0;
                }

                Location = tempPoint;
                if (OnMoving != null)
                {
                    OnMoving.Invoke(this, e);
                }
                return;
            }

            if (Controls != null)
            {
                for (int i = Controls.Count - 1; i >= 0; i--)
                {
                    if (Controls[i].IsMouseOver(CMain.MPoint))
                    {
                        Controls[i].OnMouseMove(e);
                        return;
                    }
                }
            }

            Highlight();

            if (MouseMove != null)
            {
                MouseMove.Invoke(this, e);
            }
        }
示例#11
0
 private void OnMove(InputValue inputValue)
 {
     OnMoving?.Invoke(inputValue.Get <float>());
 }
 private void Moving(float inputAxis)
 {
     // TODO: Moving Implement Here
     OnMoving?.Invoke();
 }