Exemple #1
0
    void SetVaribles()
    {
        GameObject totalHeightTextobject = GameObject.Find("Game Over");

        totalHeightTextobject.gameObject.transform.GetChild(0).gameObject.SetActive(true);
        totalHeightText = GameObject.Find("New High Score Text").GetComponent <Text>();
        Spawner         = GameObject.Find("Spawner");
        text            = GameObject.Find("Height Text").GetComponent <TextMesh>();
        moveTextScript  = text.GetComponent <MoveText>();
        totalHeightTextobject.gameObject.transform.GetChild(0).gameObject.SetActive(false);
    }
Exemple #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Event != null ? Event.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Site != null ? Site.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (White != null ? White.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Black != null ? Black.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Date != null ? Date.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Round != null ? Round.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)Result;
         hashCode = (hashCode * 397) ^ (MoveText != null ? MoveText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Eco != null ? Eco.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ WhiteElo.GetHashCode();
         hashCode = (hashCode * 397) ^ BlackElo.GetHashCode();
         return(hashCode);
     }
 }
Exemple #3
0
 void GetVaribles()
 {
     heightLine     = GameObject.Find("HeightLine");
     text           = GameObject.Find("Goal Text").GetComponent <TextMesh>();
     moveTextScript = text.GetComponent <MoveText>();
 }
        // Entry point for moves which first validates input, then either passes on to validate move based on piece rules
        // Message is the button text
        public void Move(object message)
        {
            MoveText += (string)message;
            OnPropertyChanged(nameof(MoveText));

            // If moveText is over 4 it is an invalid move, so reset moveText and return
            if (MoveText.Length > 4)
            {
                MoveText = "";
                OnPropertyChanged(nameof(MoveText));
                return;
            }

            // Don't allow player to move other's pieces or select empty spots
            if (IsBlacksTurn ==
                !Board[8 - (int)char.GetNumericValue(MoveText[1])][(int)MoveText[0] - 65].Piece.IsBlack ||
                Board[8 - (int)char.GetNumericValue(MoveText[1])][(int)MoveText[0] - 65].Piece.Name == '\0')
            {
                MoveText = "";
                OnPropertyChanged(nameof(MoveText));
                return;
            }

            if (ValidInputCheck(MoveText))
            {
                // Converts input to valid Column/Row indices
                int sourceRow    = 8 - (int)char.GetNumericValue(MoveText[1]);
                int sourceColumn = (int)MoveText[0] - 65;
                int destRow      = 8 - (int)char.GetNumericValue(MoveText[3]);
                int destColumn   = (int)MoveText[2] - 65;

                // Check if move if legal, if so legalMove will be 1, if game is won it will be 2

                int legalMove = Board[sourceRow][sourceColumn].Piece.LegalMove(Board, sourceRow, sourceColumn, destRow, destColumn);


                if (legalMove == 1)
                {
                    // Move the piece to it's new location in the GUI
                    OnPropertyChanged(nameof(Board));
                    // After a valid move, switch who's turn it is
                    IsBlacksTurn = !IsBlacksTurn;
                    // Notifies GUI who's turn it is
                    OnPropertyChanged(nameof(WhoTurn));

                    // Adds move to list and updates it on GUI
                    MovesList.Insert(0, MoveText);
                    OnPropertyChanged(nameof(MovesList));
                    ResetMoveText("");
                }
                // LegalMove is 2 when a king is taken, so winning condition goes here
                if (legalMove == 2)
                {
                    // Unused wongame variable, maybe remove
                    WonGame = 1;
                    // Move the piece to it's new location in the GUI
                    OnPropertyChanged(nameof(Board));

                    // Adds move to list and updates it on GUI
                    MovesList.Insert(0, MoveText);
                    OnPropertyChanged(nameof(MovesList));

                    // Implement winning dialog HERE
                    // Implement winning dialog HERE
                    // Implement winning dialog HERE
                    MessageBox.Show("WINNER!");


                    ResetMoveText("");
                }
                // LegalMove is 3 when a pawn makes it to the other side & needs to be promoted
                if (legalMove == 3)
                {
                    PromoteRow    = destRow;
                    PromoteColumn = destColumn;
                    // IMPLEMENT PROMOTION HERE
                    // IMPLEMENT PROMOTION HERE
                    // IMPLEMENT PROMOTION HERE
                    PromotePiece();

                    // Move the piece to it's new location in the GUI
                    OnPropertyChanged(nameof(Board));

                    IsBlacksTurn = !IsBlacksTurn;
                    // Notifies GUI who's turn it is
                    OnPropertyChanged(nameof(WhoTurn));

                    // Adds move to list and updates it on GUI
                    MovesList.Insert(0, MoveText);
                    OnPropertyChanged(nameof(MovesList));

                    ResetMoveText("");
                }
            }

            if (MoveText.Length > 2)
            {
                MoveText = MoveText.Remove(2);
                OnPropertyChanged(nameof(MoveText));
            }
        }