/// <summary> /// The TrocarPecaAtual /// </summary> private void TrocarPecaAtual() { GuardarBlocos(); CurrentPiece = NextPiece.Clone(); NextPiece = CreateRandomBlock(); Stats.IncludeBlock(); OnRefresh?.Invoke(); }
public object Clone() { TetrisPieceWithPosition clone = new TetrisPieceWithPosition { NextPiece = (TetrisPiece)NextPiece.Clone(), Piece = (TetrisPiece)Piece.Clone(), Position = (Coordinates)Position.Clone() }; return(clone); }
private void GeneratePiece() { CurrPiece.Reset(templatePieces[nextPieceTemplateIndex]); nextPieceTemplateIndex = Random.Range(0, templatePieces.Length); NextPiece.Reset(templatePieces[nextPieceTemplateIndex]); EventSystem <TetrisGameEvent, TemplatePiece> .TriggerEvent(TetrisGameEvent.NextPiece, templatePieces[nextPieceTemplateIndex]); PiecePos = new Vector2Int(5, 20); ComputeProjection(); }
/// <summary> /// Draws the next block on the specified location. /// </summary> private void DrawNextBlock() { Console.MoveBufferArea( _nextX, _nextY + 4, 8, 4, _nextX, _nextY); if (NextPiece != null) { NextPiece.Draw(_nextX, _nextY); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } GameState other = obj as GameState; if (other != null) { return (((Board == null && other.Board == null) || (Board != null && Board.Equals(other.Board))) && ((Piece == null && other.Piece == null) || (Piece != null && Piece.Equals(other.Piece))) && ((NextPiece == null && other.NextPiece == null) || (NextPiece != null && NextPiece.Equals(other.NextPiece)))); } return(false); }
public override int GetHashCode() { return(Lines ^ (Piece.GetHashCode() << 5) ^ ((int)NextPiece.GetValueOrDefault() << 20)); }
public Color?[,] GetFourByFourTable() { return(NextPiece.GetFourByFourTable()); }
public void displayGameBoard(WoodsyGameData W, String currentParticipantId) { //-- Get the player information and find our player. //-- Make a player pointer array to point to the game version's index for the actual order of players, //-- since in the display the active player is always on top. int wNumPlayers = W.getNumberOfParticipants(); List <String> playerIds = W.getParticipantIds(); int currentPlayerIndex = -1; for (int i = 0; i < wNumPlayers; i++) { if (playerIds[i].Equals(currentParticipantId)) { currentPlayerIndex = i; } } int[] playPointer = new int[wNumPlayers]; playPointer[0] = currentPlayerIndex; int j = 1; for (int i = 0; i < wNumPlayers; i++) { if (i == currentPlayerIndex) { continue; } playPointer[j] = i; j++; } if (currentPlayerIndex == -1) { Toast("Unexpected problem locating player"); currentPlayerIndex = 0; currentParticipantId = playerIds[0]; } //-- Set the captions. Set whether the board is read-only or not. for (int i = 0; i < 4; i++) { if (i < wNumPlayers) { BoardCaptions[i].Text = playerIds[playPointer[i]] + "'s Board (Coins: " + W.getScore(playerIds[playPointer[i]]) + ")"; if (i == 0) { // active player BoardViews[i].setReadOnlyMode(false); } else { BoardViews[i].setReadOnlyMode(true); } } } //-- Now set the next piece. NextPiece.setPiece(W.getNextPiece()); int nleft = WoodsyGame.piecesLeftInBag(); PiecesLeftText.Text = ("(Pieces Left: " + nleft + ")"); //-- Next, draw the game boards. for (int i = 0; i < wNumPlayers; i++) { if (i == 0) { BoardViews[i].setBoard(W.getCurrentBoard()); } else { BoardViews[i].setBoard(W.getBoard(playerIds[playPointer[i]])); } } }