コード例 #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);
  }