Example #1
0
        private CheckerPieceTs piece;        //will be null without piece, or have a piece if occupied

        // constructor
        // every board cell should recieve a position
        // Some boardcells will have non null pieces; isOccupied will be true and p will be a piece
        // otherwise, empty cells will be false and p will be null
        public void BoardCellConstruct(int[] pos, bool Occupied, CheckerPieceTs cp)
        {
            position[0] = pos[0];
            position[1] = pos[1];
            isOccupied  = Occupied;
            piece       = cp;
        }
Example #2
0
        public void rayAction(string pieceName, Ray ray)
        {
            //ray shoots out from camera toward click and hits box collider
            if (Physics.Raycast(ray, out RaycastHit hit, LayerMask.GetMask("PieceLayer")) && (playerBlack == isBlacksTurn))
            {
                if (forceCapture)
                {
                    CheckerPieceTs hitPiece = hit.transform.gameObject.GetComponent <CheckerPieceTs>();

                    scanCaptureForcePieces();

                    for (int i = 0; i < forcePieces.Count; i++)
                    {
                        if (hitPiece == forcePieces[i])
                        {
                            forceSquare = true;
                            movePiece(pieceName, hit);
                        }
                    }

                    // ForceSquare is true when player hits the piece that must attack.
                    // Forces player to not be able to hit any other tiles besides the square he must attack.
                    if (forceSquare)
                    {
                        GameObject hitCell = hit.transform.gameObject;
                        for (int i = 0; i < globalValid.Count; i++)
                        {
                            if (hitCell == globalValid[i])
                            {
                                forceSquare  = false;
                                forceCapture = false;
                                movePiece(pieceName, hit);
                            }
                        }
                    }
                }

                // Regular move action
                else if (forceCapture == false && forceSquare == false)
                {
                    movePiece(pieceName, hit);
                }
            }
        }
Example #3
0
 //code to set the peice on board cell
 public void setPiece(CheckerPieceTs cp)
 {
     this.isOccupied = true;
     this.piece      = cp;
 }
Example #4
0
 //code to make the space unoccupied
 public void clearSpace()
 {
     this.isOccupied = false;
     this.piece      = null;
 }