private void tileClicked(GameButton tileID) { // if you click the selected piece it unselects itself if (isSelected) { isSelected = false; ownerBoard.clearMoveflags(); ownerBoard.selectedTile = null; return; } if (ownerBoard.selectedTile == null) { if (piece != null) { isSelected = true; highlight = true; ownerBoard.selectedTile = this; piece.pieceFunction(ownerBoard, this); } } else { if (_canMove) { ownerBoard.movePieceTo(this); } } }
private void exitFunction(GameButton btn) { tempBoard.clearMoveflags(); tempBoard.selectedTile = null; tempTile.isSelected = false; terminateWindow(); }
private void itemButtonClicked(GameButton btnClicked) { for (int i = 0; i < shopItems.Length; i++) { if (shopItems[i].button == btnClicked) { selectedItem = i; return; } } }
private static void changeTurn(GameButton btn) { turn++; if (turn % 2 == 0) { Console.WriteLine("Player1 turn"); } else { Console.WriteLine("Player0 turn"); } }
private void buyClicked(GameButton btnClicked) { // if have enough gold newTile = new Tile(-1, -1, 0, 0, tempBoard, new ButtonStyle()); tempBoard.selectedTile = newTile; newTile.piece = shopItems[selectedItem].item; newTile.imgPath = newTile.piece.imgPath; Pos pos = tempBoard.getCoord(tempTile); for (int i = 0; i < tempBoard.TILES_WIDE; i++) { Tile tmp = tempBoard.tileAt(i, pos.y); if (tmp.piece == null) { tmp.canMove = true; } } terminateWindow(); }
// Initalize the graphics resources static void initalize() { createFonts(); // Calculate the gameboard size int boardSzX = (int)(SCREEN_WIDTH / 2f); int boardSzY = (int)(SCREEN_WIDTH / 2f); // Create the gameboard boardX = SCREEN_WIDTH / 2 - boardSzX / 2; boardY = (int)(SCREEN_HEIGHT / 2.5) - boardSzY / 2; board = new GameBoard(boardX, boardY, boardSzX, boardSzY); // Calculate the region bounds boardRegion = new Region(boardX, boardY, boardX + boardSzX, boardY + boardSzY); topRegion = new Region(0, 0, SCREEN_WIDTH, boardRegion.top); bottomRegion = new Region(0, boardRegion.bottom, SCREEN_WIDTH, SCREEN_HEIGHT); leftRegion = new Region(0, topRegion.bottom, boardRegion.left, bottomRegion.top); rightRegion = new Region(boardRegion.right, topRegion.bottom, SCREEN_WIDTH, bottomRegion.top); int btnEndTurnSize = 100; btnEndTurn = new GameButton(bottomRegion.left, bottomRegion.top, btnEndTurnSize, btnEndTurnSize, "END TURN", changeTurn); WindowControls.Register(btnEndTurn); players[0] = new Player(100); currentPlayer = players[0]; players[1] = new Player(100); players[1].isAltPlayer = true; //plag set PieceShop playerShop0 = new PieceShop("res//shopE.png", 99, players[0], SCREEN_WIDTH, SCREEN_HEIGHT, new Pos(0, 0), 0xFFDDE000); PieceShop playerShop1 = new PieceShop("res//shop.png", 99, players[1], SCREEN_WIDTH, SCREEN_HEIGHT, new Pos(0, 0), 0xFFDDE000); players[0].addPiece(0, 0, playerShop0, board); players[1].addPiece(0, 0, playerShop1, board); players[0].addPiece(0, 5, new Piece("res//queenE.png", 10, players[0], Piece.MOVEMODE.QUEEN), board); }