BVG.Board.AddPlayerToken C# (CSharp) Method

AddPlayerToken() public method

Adds a player token of a given colour to the given coordinates.
public AddPlayerToken ( bool isRed, IntVector2 boardPosition ) : void
isRed bool If set to true is red.
boardPosition IntVector2 The position on the board to add a player token to.
return void
		public void AddPlayerToken(bool isRed, IntVector2 boardPosition) {
			if (! IsValidBoardPosition(boardPosition)) {
				Debug.LogErrorFormat("Invalid coordinates to add a {0} token to the board: {1}", isRed ? "red" : "black", boardPosition);
				return;
			}
			
			// create the token
			GameObject tokenPrefab = isRed ? redPiecePrefab : blackPiecePrefab;
			GameObject token = Instantiate<GameObject>(tokenPrefab);

			// add to the scene
			GameObject tile = board[boardPosition.x, boardPosition.y];
			token.transform.SetParent(tile.transform, false);

			// update board state
			boardStates[boardPosition.x, boardPosition.y] = isRed ? BoardState.RED : BoardState.BLACK;
		}