예제 #1
0
        /// <summary>
        /// Called when a move is made
        /// </summary>
        /// <param name="pieceEliminated"> True if the move eliminate's the opponent's piece </param>
        /// <param name="eliminatedObject"> Opponent's piece that has been eliminated, otherwise null </param>
        /// <param name="piece"> Piece that was moved </param>
        /// <param name="originalPos"> Original Position of the piece ("x z")</param>
        /// <param name="newPos"> New Position of the Piece ("x z")</param>
        public void Move(bool pieceEliminated, GameObject eliminatedObject, GameObject piece, string originalPos, string newPos)
        {
            Eliminated.Add(pieceEliminated);

            if (pieceEliminated)
            {
                EliminatedObjects.Add(eliminatedObject);
            }

            else
            {
                EliminatedObjects.Add(null);
            }

            PieceMoved.Add(piece);
            PreviousXPosition.Add((int)char.GetNumericValue(originalPos[0]));
            PreviousZPosition.Add((int)char.GetNumericValue(originalPos[2]));
            CurrentXPosition.Add((int)char.GetNumericValue(newPos[0]));
            CurrentZPosition.Add((int)char.GetNumericValue(newPos[2]));

            // by default, pawnPromoted = false
            PawnPromoted.Add(false);

            // by default, check = false
            Check.Add(false);

            Count++;
        }
예제 #2
0
        public ArrayList Undo()
        {
            ArrayList undo = new ArrayList();

            undo.Add(Eliminated[Index]);
            undo.Add(EliminatedObjects[Index]);
            undo.Add(PieceMoved[Index]);
            undo.Add(PreviousXPosition[Index]);
            undo.Add(PreviousZPosition[Index]);
            undo.Add(CurrentXPosition[Index]);
            undo.Add(CurrentZPosition[Index]);
            undo.Add(Check[Index]);
            undo.Add(PawnPromoted[Index]);

            Eliminated.RemoveAt(Index);
            EliminatedObjects.RemoveAt(Index);
            PieceMoved.RemoveAt(Index);
            PreviousXPosition.RemoveAt(Index);
            PreviousZPosition.RemoveAt(Index);
            CurrentXPosition.RemoveAt(Index);
            CurrentZPosition.RemoveAt(Index);
            Check.RemoveAt(Index);
            PawnPromoted.RemoveAt(Index);
            Count--;

            return(undo);
        }