Beispiel #1
0
        void Awake()
        {
            GameObject manager = GameObject.Find("GameManager");

            boardInfo   = manager.GetComponent <BoardInformation>();
            pieceAction = manager.GetComponent <PieceAction>();
        }
Beispiel #2
0
        void Awake()
        {
            // Initialising the original and current positions of each piece
            originalXPosition = (int)transform.localPosition.x;
            originalZPosition = (int)transform.localPosition.z;

            CurrentXPosition = originalXPosition;
            CurrentZPosition = originalZPosition;
            currPos          = transform.position;

            manager         = GameObject.Find("GameManager");
            boardInfo       = manager.GetComponent <BoardInformation>();
            chessboard      = GameObject.Find("Chessboard");
            pieceAction     = manager.GetComponent <PieceAction>();
            ghostPickup     = GetComponent <GhostPickup>();
            chessboardLayer = boardInfo.GetChessboardLayer();

            pieceRigidBody = GetComponent <Rigidbody>();
        }
        void Start()
        {
            CanMove       = true;
            piecesOnBoard = new List <GameObject>();

            foreach (GameObject piece in GameObject.FindGameObjectsWithTag("pieces"))
            {
                PieceInformation info = piece.GetComponent <PieceInformation>();
                int x = info.CurrentXPosition;
                int z = info.CurrentZPosition;
                Board[z, x] = piece;

                // Initialise kings
                if (info.type == PieceInformation.Type.King)
                {
                    if (info.colour == PieceInformation.Colour.White)
                    {
                        whiteKing = piece;
                    }
                    else
                    {
                        blackKing = piece;
                    }
                }

                // Add piece to piecesOnBoard list to keep track of all pieces on board
                piecesOnBoard.Add(piece);
            }

            // Assign null for empty positions
            for (int i = 2; i <= 5; i++)
            {
                for (int j = 0; j <= 7; j++)
                {
                    Board[i, j] = null;
                }
            }

            // Initialise whose turn it is
            turn = Colours.White;

            // Initialise data structure
            pieceAction = GetComponent <PieceAction>();

            // Turn off collisions for all pieces if ghost animation is active
            if (ghostActive)
            {
                Physics.IgnoreLayerCollision(14, 14);
                Physics.IgnoreLayerCollision(15, 15);
                Physics.IgnoreLayerCollision(14, 15);
            }

            // Disable the result display
            EndGameResult.SetActive(false);
            pawnPromo.SetActive(false);

            blackArrowRenderer = blackArrow.GetComponent <Renderer>();
            whiteArrowRenderer = whiteArrow.GetComponent <Renderer>();

            blackPieces = LayerMask.NameToLayer("BlackPieces");
            whitePieces = LayerMask.NameToLayer("WhitePieces");

            whiteDisplayText = whiteText.GetComponent <Text>();
            blackDisplayText = blackText.GetComponent <Text>();
            leftDisplayText  = leftText.GetComponent <Text>();
            rightDisplayText = rightText.GetComponent <Text>();

            whiteForfeitText = boardMenuTileText.GetComponent <TextMeshPro>();
            blackForfeitText = boardMenuTileTextTwo.GetComponent <TextMeshPro>();
        }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     gameManager = GameObject.Find("GameManager");
     boardInfo   = gameManager.GetComponent <BoardInformation>();
     pieceAction = gameManager.GetComponent <PieceAction>();
 }