Пример #1
0
  @Override
  public boolean onSingleTapUp(MotionEvent e) {

    if (myConnectFour != null) {
      //			Log.d("turn", "" + myConnectFour.getTurn());

      if (myConnectFour.getTurn()) {
        myConnectFour.update();
        if (myConnectFour.touch(e.getX(), e.getY())) {
          connect2.sendMsg("" + myConnectFour.getLastX());
          connect2.sendMsg("" + myConnectFour.getLastY());

          if (gameover = myConnectFour.getGameOver()) {
            if (myConnectFour.getWinner() == ConnectFourView.RED)
              myConnectFour.setText("Game Over: You win");
            else if (myConnectFour.getWinner() == ConnectFourView.GREEN)
              myConnectFour.setText("Game Over: You lose");
          }

          mRefreshHandler.sleep(50);
        }
      }
    }

    return true;
  }
Пример #2
0
  private void checkInput() {
    if (gameStart && !myConnectFour.getTurn() && !gameover) {
      String input = "";

      if (connect2 != null) {
        input = connect2.getMsg();
        if ((input != null) && !input.equals(" ")) {

          test(input);
          myConnectFour.setTurn(true);
          myConnectFour.setText("Your move.");
          if (gameover = myConnectFour.getGameOver()) {
            if (myConnectFour.getWinner() == ConnectFourView.RED)
              myConnectFour.setText("Game Over: You win");
            else if (myConnectFour.getWinner() == ConnectFourView.GREEN)
              myConnectFour.setText("Game Over: You lose");
          }
        }
      }
    }
    mRefreshHandler.sleep(50);
  }
Пример #3
0
  public void test(String input) {
    if (gameStart) {
      if (input != null) {
        int x = Integer.parseInt(input);
        String yString = " ";
        while (yString.equals(" ")) yString = connect2.getMsg();

        int y = Integer.parseInt(yString);

        if (!myConnectFour.checkTile(x, y)) {
          myConnectFour.setTileMarked(ConnectFourView.GREEN, x, y);
          myConnectFour.setText("Your move.");
        }
      }
    }
  }