refactor: some manual changes
This commit is contained in:
@@ -57,15 +57,15 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
|
||||
|
||||
// Info text
|
||||
this.infoText = this.add.text(
|
||||
BOARD_OFFSET.x + (BOARD_SIZE * CELL_SIZE) / 2,
|
||||
BOARD_OFFSET.y + BOARD_SIZE * CELL_SIZE + 30,
|
||||
20,
|
||||
BOARD_OFFSET.y,
|
||||
'',
|
||||
{
|
||||
fontSize: '20px',
|
||||
fontSize: '15px',
|
||||
fontFamily: 'Arial',
|
||||
color: '#4b5563',
|
||||
}
|
||||
).setOrigin(0.5);
|
||||
);
|
||||
|
||||
// Update info text when UI state changes
|
||||
this.addEffect(() => {
|
||||
@@ -80,12 +80,13 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
|
||||
const boardLeft = BOARD_OFFSET.x;
|
||||
const boardTop = BOARD_OFFSET.y;
|
||||
const boardRight = BOARD_OFFSET.x + BOARD_SIZE * CELL_SIZE;
|
||||
const boardBottom = BOARD_OFFSET.y + BOARD_SIZE * CELL_SIZE;
|
||||
|
||||
// Red cards label
|
||||
// Red cards label - 棋盘下方
|
||||
const redLabel = this.add.text(
|
||||
boardLeft - CARD_WIDTH - 60 + CARD_WIDTH / 2,
|
||||
boardTop + 50 + 2 * (CARD_HEIGHT + 15) + 10,
|
||||
"RED's Cards",
|
||||
boardLeft + (BOARD_SIZE * CELL_SIZE) / 2,
|
||||
boardBottom + 10,
|
||||
"RED",
|
||||
{
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Arial',
|
||||
@@ -94,47 +95,27 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
|
||||
).setOrigin(0.5, 0);
|
||||
this.cardLabelContainers.set('red', redLabel);
|
||||
|
||||
// Black cards label
|
||||
// Black cards label - 棋盘上方
|
||||
const blackLabel = this.add.text(
|
||||
boardRight + 60 + CARD_WIDTH / 2,
|
||||
boardTop + 50 + 2 * (CARD_HEIGHT + 15) + 10,
|
||||
"BLACK's Cards",
|
||||
boardLeft + (BOARD_SIZE * CELL_SIZE) / 2,
|
||||
boardTop - 10,
|
||||
"BLACK",
|
||||
{
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Arial',
|
||||
color: '#3b82f6',
|
||||
}
|
||||
).setOrigin(0.5, 0);
|
||||
).setOrigin(0.5, 1);
|
||||
this.cardLabelContainers.set('black', blackLabel);
|
||||
|
||||
// Spare card label
|
||||
const boardCenterX = boardLeft + (BOARD_SIZE * CELL_SIZE) / 2;
|
||||
const spareLabel = this.add.text(
|
||||
boardCenterX,
|
||||
boardTop - 50,
|
||||
'Spare Card',
|
||||
{
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Arial',
|
||||
color: '#6b7280',
|
||||
}
|
||||
).setOrigin(0.5, 0);
|
||||
this.cardLabelContainers.set('spare', spareLabel);
|
||||
}
|
||||
|
||||
private updateInfoText(): void {
|
||||
const currentPlayer = this.state.currentPlayer;
|
||||
const selectedCard = this.uiState.value.selectedCard;
|
||||
const selectedPiece = this.uiState.value.selectedPiece;
|
||||
|
||||
if (this.state.winner) {
|
||||
this.infoText.setText(`${this.state.winner} wins!`);
|
||||
} else if (!selectedCard) {
|
||||
this.infoText.setText(`${currentPlayer}'s turn - Select a card first`);
|
||||
} else if (!selectedPiece) {
|
||||
this.infoText.setText(`Card: ${selectedCard} - Select a piece to move`);
|
||||
} else {
|
||||
this.infoText.setText(`${currentPlayer}'s turn (Turn ${this.state.turn + 1})`);
|
||||
this.infoText.setText(`Turn ${this.state.turn + 1}\n\n${currentPlayer}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,15 +141,15 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
|
||||
g.strokePath();
|
||||
|
||||
this.add.text(
|
||||
BOARD_OFFSET.x + (BOARD_SIZE * CELL_SIZE) / 2,
|
||||
BOARD_OFFSET.y - 40,
|
||||
20,
|
||||
20,
|
||||
'Onitama',
|
||||
{
|
||||
fontSize: '28px',
|
||||
fontFamily: 'Arial',
|
||||
color: '#1f2937',
|
||||
}
|
||||
).setOrigin(0.5);
|
||||
);
|
||||
}
|
||||
|
||||
private setupInput(): void {
|
||||
|
||||
Reference in New Issue
Block a user