예제 #1
0
        public void DoMotion(Board board, MotionSide side)
        {
            Motion moving = new Motion(side);

            // Setting figure to board
            if (side == MotionSide.Bottom && CheckMotion(board, side) == false)
            {
                this.isSet = true;
                for (int x = 0; x < state.currentState.width; x++)
                {
                    for (int y = 0; y < state.currentState.height; y++)
                    {
                        board.matrix[x + this.anchor.X, y + this.anchor.Y] = true;
                    }
                }
            }
            if (CheckMotion(board, side) == true)
            {
                this.anchor.X += moving.dx;
                this.anchor.Y += moving.dy;

                if (side == MotionSide.Rotate)
                {
                    this.state = this.state.nextState;
                }
            }
        }
예제 #2
0
        public bool CheckMotion(MotionSide side)
        {
            bool   available   = true;
            Motion motion      = new Motion(side);
            Figure movedFigure = new Figure();

            movedFigure.anchor.X = currentFigure.anchor.X + motion.dx;
            movedFigure.anchor.Y = currentFigure.anchor.Y + motion.dy;
            if (side == MotionSide.Rotate)
            {
                movedFigure.state = currentFigure.state.nextState;
            }
            else
            {
                movedFigure.state = currentFigure.state;
            }

            for (int x = 0; x < movedFigure.state.currentState.width; x++)
            {
                for (int y = 0; y < movedFigure.state.currentState.height; y++)
                {
                    if (movedFigure.state.currentState.matrix[x, y] == true &&
                        (x + movedFigure.anchor.X < 0 ||
                         x + movedFigure.anchor.X >= board.width ||
                         y + movedFigure.anchor.Y < 0 ||
                         y + movedFigure.anchor.Y >= board.height))
                    {
                        available = false;
                        return(available);
                    }
                    if (movedFigure.state.currentState.matrix[x, y] == true &&
                        board.matrix[x + movedFigure.anchor.X, y + movedFigure.anchor.Y] == true)
                    {
                        available = false;
                        return(available);
                    }
                }
            }
            if (end == true)
            {
                available = false;
            }
            return(available);
        }
예제 #3
0
 public Motion(MotionSide side)
 {
     if (side == MotionSide.Left)
     {
         dx = -1; dy = 0;
     }
     if (side == MotionSide.Bottom)
     {
         dx = 0; dy = -1;
     }
     if (side == MotionSide.Right)
     {
         dx = 1; dy = 0;
     }
     if (side == MotionSide.Rotate)
     {
         dx = 0; dy = 0;
     }
 }
예제 #4
0
        public void DoMotion(MotionSide side)
        {
            Motion moving = new Motion(side);

            // Setting figure to board
            if (side == MotionSide.Bottom && CheckMotion(side) == false)
            {
                SetFigure();
                Scoring();
                SpawnFigure();
            }
            if (CheckMotion(side) == true)
            {
                currentFigure.anchor.X += moving.dx;
                currentFigure.anchor.Y += moving.dy;

                if (side == MotionSide.Rotate)
                {
                    currentFigure.state = currentFigure.state.nextState;
                }
            }
        }