Exemplo n.º 1
0
            public ValidityResult IsValidPosition(EdtrisPiece piece, int colOffset, int rowOffset)
            {
                piece.col += colOffset;
                piece.row += rowOffset;

                ValidityResult result = IsValidPosition(piece);

                piece.col -= colOffset;
                piece.row -= rowOffset;

                return(result);
            }
Exemplo n.º 2
0
            private void SpawnPiece()
            {
                currentPiece                   = new EdtrisPiece();
                currentPiece.col               = (gameBoardCols / 2);
                currentPiece.row               = 0;
                lastCurrentPieceMoveDownTime   = EditorApplication.timeSinceStartup;
                failedCurrentPieceDownAttempts = 0;

                if (ValidityResult.Valid != IsValidPosition(currentPiece))
                {
                    isPlaying = false;
                    SetInfoMessage("Game Over!", Color.red);
                    currentPiece = null;
                }
            }
Exemplo n.º 3
0
            public ValidityResult IsValidPosition(EdtrisPiece piece)
            {
                for (int row = piece.row; row < piece.row + 4; ++row)
                {
                    for (int col = piece.col; col < piece.col + 4; ++col)
                    {
                        if (piece.IsHit(col, row))
                        {
                            if (col >= gameBoardCols || col < 0 || row >= gameBoardRows || row < 0)
                            {
                                return(ValidityResult.OutOfBounds);
                            }
                            if (gameBoard[Index(col, row, gameBoardCols)].isFilled)
                            {
                                return(ValidityResult.IntersectsBlock);
                            }
                        }
                    }
                }

                return(ValidityResult.Valid);
            }