Exemple #1
0
 private void tmrHold_Tick(object sender, EventArgs e)
 {
     tmrHold.Enabled      = false;
     tmrGameClock.Enabled = true;
     blockHold            = false;
     if (!GameField.IsEmpty((CurrentBlock.squareSW.Location.X - 1) / (GameField.SquareSize + 1), (CurrentBlock.squareSW.Location.Y - 1) / (GameField.SquareSize + 1) + 1) &&
         GameField.IsEmpty((CurrentBlock.squareSE.Location.X - 1) / (GameField.SquareSize + 1), (CurrentBlock.squareSE.Location.Y - 1) / (GameField.SquareSize + 1) + 1))
     {
         preMoveDirection = 'r';
     }
     else if (!GameField.IsEmpty((CurrentBlock.squareSE.Location.X - 1) / (GameField.SquareSize + 1), (CurrentBlock.squareSE.Location.Y - 1) / (GameField.SquareSize + 1) + 1) &&
              GameField.IsEmpty((CurrentBlock.squareSW.Location.X - 1) / (GameField.SquareSize + 1), (CurrentBlock.squareSW.Location.Y - 1) / (GameField.SquareSize + 1) + 1))
     {
         preMoveDirection = 'l';
     }
 }
Exemple #2
0
 public bool Left()
 {
     if (GameField.IsEmpty((squareSW.Location.X - 1) / (squareSize + 1) - 1, (squareSW.Location.Y - 1) / (squareSize + 1)) &&
         GameField.IsEmpty((squareNW.Location.X - 1) / (squareSize + 1) - 1, (squareNW.Location.Y - 1) / (squareSize + 1)))
     {
         //在原位置将方块消去
         Hide(GameField.WinHandle);
         //更新方块的位置
         squareSW.Location = new Point(squareSW.Location.X - squareSize - 1, squareSW.Location.Y);
         squareNW.Location = new Point(squareNW.Location.X - squareSize - 1, squareNW.Location.Y);
         squareSE.Location = new Point(squareSE.Location.X - squareSize - 1, squareSE.Location.Y);
         squareNE.Location = new Point(squareNE.Location.X - squareSize - 1, squareNE.Location.Y);
         //在新位置显示方块
         Show(GameField.WinHandle);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
        public bool Down()
        {
            //没有方块被挡住
            if (GameField.IsEmpty((squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1) + 1) &&
                GameField.IsEmpty((squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1) + 1))
            {
                Hide(GameField.WinHandle);
                squareSW.Location = new Point(squareSW.Location.X, squareSW.Location.Y + squareSize + 1);
                squareNW.Location = new Point(squareNW.Location.X, squareNW.Location.Y + squareSize + 1);
                squareSE.Location = new Point(squareSE.Location.X, squareSE.Location.Y + squareSize + 1);
                squareNE.Location = new Point(squareNE.Location.X, squareNE.Location.Y + squareSize + 1);
                Show(GameField.WinHandle);
                return(true);
            }

            //右半边方块被挡住
            else if (GameField.IsEmpty((squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1) + 1) &&
                     !GameField.IsEmpty((squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1) + 1))
            {
                GameField.StopSquare(squareSE, (squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNE, (squareNE.Location.X - 1) / (squareSize + 1), (squareNE.Location.Y - 1) / (squareSize + 1));
                //让左半边方块落地
                while (GameField.IsEmpty((squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1) + 1))
                {
                    squareSW.Hide(GameField.WinHandle);
                    squareNW.Hide(GameField.WinHandle);
                    squareSW.Location = new Point(squareSW.Location.X, squareSW.Location.Y + squareSize + 1);
                    squareNW.Location = new Point(squareNW.Location.X, squareNW.Location.Y + squareSize + 1);
                    squareSW.Show(GameField.WinHandle);
                    squareNW.Show(GameField.WinHandle);
                }
                GameField.StopSquare(squareSW, (squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNW, (squareNW.Location.X - 1) / (squareSize + 1), (squareNW.Location.Y - 1) / (squareSize + 1));
                GameField.CheckBlocks(0, GameField.Width - 1);
                if (GameField.DoSetDelCol)
                {
                    GameField.SetDelCol();
                }
                GameField.DoAllDeletedCheck = true;
                GameField.DoUniColorCheck   = true;
                return(false);
            }

            //左半边方块被挡住
            else if (!GameField.IsEmpty((squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1) + 1) &&
                     GameField.IsEmpty((squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1) + 1))
            {
                GameField.StopSquare(squareSW, (squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNW, (squareNW.Location.X - 1) / (squareSize + 1), (squareNW.Location.Y - 1) / (squareSize + 1));
                //让右半边方块落地
                while (GameField.IsEmpty((squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1) + 1))
                {
                    squareSE.Hide(GameField.WinHandle);
                    squareNE.Hide(GameField.WinHandle);
                    squareSE.Location = new Point(squareSE.Location.X, squareSE.Location.Y + squareSize + 1);
                    squareNE.Location = new Point(squareNE.Location.X, squareNE.Location.Y + squareSize + 1);
                    squareSE.Show(GameField.WinHandle);
                    squareNE.Show(GameField.WinHandle);
                }
                GameField.StopSquare(squareSE, (squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNE, (squareNE.Location.X - 1) / (squareSize + 1), (squareNE.Location.Y - 1) / (squareSize + 1));
                GameField.CheckBlocks(0, GameField.Width - 1);
                if (GameField.DoSetDelCol)
                {
                    GameField.SetDelCol();
                }
                GameField.DoAllDeletedCheck = true;
                GameField.DoUniColorCheck   = true;
                return(false);
            }

            //整个方块被挡住
            else
            {
                GameField.StopSquare(squareSW, (squareSW.Location.X - 1) / (squareSize + 1), (squareSW.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNW, (squareNW.Location.X - 1) / (squareSize + 1), (squareNW.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareSE, (squareSE.Location.X - 1) / (squareSize + 1), (squareSE.Location.Y - 1) / (squareSize + 1));
                GameField.StopSquare(squareNE, (squareNE.Location.X - 1) / (squareSize + 1), (squareNE.Location.Y - 1) / (squareSize + 1));
                GameField.CheckBlocks(0, GameField.Width - 1);
                if (GameField.DoSetDelCol)
                {
                    GameField.SetDelCol();
                }
                GameField.DoAllDeletedCheck = true;
                GameField.DoUniColorCheck   = true;
                return(false);
            }
        }