コード例 #1
0
ファイル: Figure.cs プロジェクト: mtemplin/Tetris
 /**
  * Wird geprüft, ob der neue Stein überhaupt auf das Board passt
  */
 public void newOnBoard()
 {
     lock (App.myLock)
     {
         bool    fitsOnBoard  = doPointsFit(points);
         Point[] fallenPoints = simulatedFall();
         this.ghostPoints = fallenPoints;
         board.writeCell(points, fallenPoints, color, board.getFallenPreviewColor());
         if (!fitsOnBoard)
         {
             App.getInstance().gameOver();
         }
         else
         {
             board.addScore(5);
         }
     }
 }
コード例 #2
0
        /**
         * Methode für den Specialmode mit Speichern eines Steines
         */
        private void handleSpecialMode()
        {
            lock (App.myLock) {
                if (boardModel.getMemoryFigure() == null)
                {
                    Figure current = boardModel.getCurrentFigure();
                    current.removeFromBoard();
                    current.setInitPoints();
                    boardModel.setMemoryFigure(current);



                    Figure preview = boardModel.generateRandomFigure();
                    current = boardModel.generateRandomFigure();

                    boardModel.setCurrentFigure(current);
                    boardModel.setPreviewFigure(preview);

                    boardModel.getCurrentFigure().newOnBoard();
                }
                else
                {
                    Figure memory  = boardModel.getMemoryFigure();
                    Figure current = boardModel.getCurrentFigure();

                    current.removeFromBoard();
                    current.setInitPoints();
                    boardModel.setMemoryFigure(current);



                    boardModel.setCurrentFigure(memory);
                    boardModel.getCurrentFigure().newOnBoard();
                    boardModel.addScore(-5);
                }
            }
        }