private void startGame(int start_score) { setState(STATE_RUNNING); // Set allowed time m_allowedTime = m_initial_allowedTime; m_allowedTime_millis = m_allowedTime * 1000; m_score = start_score; m_answers.clear(); m_Handler.removeCallbacks(mUpdateTimeTask); m_Handler.removeCallbacks(mBlinkTimeTask); if (mGameMode.equals("demo")) { mDemoState = 0; m_demo_word_i = 0; mBoardGameLogic.startGame("SABONETE"); m_playboard.setClickable(false); m_Handler.postDelayed(mDemoPlayTask, 1000); } else { mBoardGameLogic.startGame(getRandomWord()); m_Handler.postDelayed(mUpdateTimeTask, 1000); m_playboard.setClickable(true); m_word.setClickable(true); } mScoreText.setText(new Integer(m_score).toString()); m_text_status.setVisibility(View.INVISIBLE); m_start_button.setVisibility(View.INVISIBLE); m_word.setText(""); m_word.setEnabled(false); mPlayTime.setVisibility(View.VISIBLE); m_playboard.setKeepScreenOn(true); mStartTime = System.currentTimeMillis(); }
public void run() { switch (mDemoState) { case 0: showMessage( "Toque em letras adjacentes\n" + "procurando formar palavras\ncom pelo menos 4 letras.\n" + "Quando terminar uma palavra toque no botão.", 20); m_Handler.postDelayed(this, 5000); ++mDemoState; break; case 1: case 4: m_text_status.setVisibility(View.INVISIBLE); ArrayList<PlayBoard.Coordinate> word = mBoardGameLogic.getMasterWord(); PlayBoard.Coordinate pos; String current_word = ""; for (int i = 0; i < m_demo_word_i; ++i) { pos = word.get(i); m_playboard.setTile(PlayBoard.SELECTED, pos.x, pos.y); current_word += m_playboard.getTextAtPos(pos.x, pos.y); } pos = word.get(m_demo_word_i); current_word += m_playboard.getTextAtPos(pos.x, pos.y); m_playboard.setTile(PlayBoard.LAST_SELECTED, pos.x, pos.y); m_word.setText(current_word); int button_img = (current_word.length() > 3) ? R.drawable.question : R.drawable.check_button_blank; m_word.setCompoundDrawablesWithIntrinsicBounds(0, 0, button_img, 0); m_word.setEnabled(current_word.length() > 3); m_word.setClickable(false); m_playboard.invalidate(); m_Handler.postDelayed(this, 1000); if (++m_demo_word_i == word.size()) mDemoState++; break; case 2: showResult("SABONETE", "certa", 0xAA00FF00); m_Handler.postDelayed(this, 3000); mDemoState++; break; case 3: m_demo_word_i = 0; m_text_status.setVisibility(View.INVISIBLE); mBoardGameLogic.startGame("PORTUGAL"); m_playboard.invalidate(); m_Handler.postDelayed(this, 1000); mDemoState++; break; case 5: showResult("PORTUGAL", "errada", 0xAAFF0000); m_Handler.postDelayed(this, 2200); mDemoState++; break; case 6: showMessage("Não são aceites nomes próprios.", 20); m_Handler.postDelayed(this, 5000); mDemoState++; break; case 7: finish(); } }