//Comportamiento del Board en STATE_NORMAL public void tokenSelection() { if (CMouse.firstPress(0)) { int[] mousePos = getMouseTile(); if (mousePos[0] != -1 & secondSelect[0] == -1) { firstSelect[0] = mousePos[0]; firstSelect[1] = mousePos[1]; matrixBoard[firstSelect[0]][firstSelect[1]].select(); } } if (CMouse.pressed(0)) { int[] mousePos = getMouseTile(); if (mousePos[0] != firstSelect[0] | mousePos[1] != firstSelect[1]) { if (mousePos[0] == -1 & firstSelect[0] != -1) { matrixBoard[firstSelect[0]][firstSelect[1]].deselect(); firstSelect[0] = -1; firstSelect[1] = -1; } if (mousePos[0] != -1 & firstSelect[0] != -1) { secondSelect[0] = mousePos[0]; secondSelect[1] = mousePos[1]; matrixBoard[secondSelect[0]][secondSelect[1]].select(); if (contiguousTiles(firstSelect[0], firstSelect[1], secondSelect[0], secondSelect[1])) { switchTokens(firstSelect[0], firstSelect[1], secondSelect[0], secondSelect[1]); current_state = STATE_CHANGING; matrixBoard[firstSelect[0]][firstSelect[1]].deselect(); matrixBoard[secondSelect[0]][secondSelect[1]].deselect(); } else { matrixBoard[firstSelect[0]][firstSelect[1]].deselect(); matrixBoard[secondSelect[0]][secondSelect[1]].deselect(); firstSelect[0] = -1; firstSelect[1] = -1; secondSelect[0] = -1; secondSelect[1] = -1; } } } } if (CMouse.release(0) & firstSelect[0] != -1) { matrixBoard[firstSelect[0]][firstSelect[1]].deselect(); } }
public bool clicked() { Vector3 mousePos = CMouse.getPos(); if (CMouse.release()) { if (CMath.pointInRect(mousePos.x, mousePos.y, getX() - getWidth() / 2, getY() - getHeight() / 2, getWidth(), getHeight())) { return(true); } } return(false); }