Esempio n. 1
0
  private void parseGameSetupAndStart() {

    switch (mCurrentGameType) {
      case GAMETYPE_ALL_QUESTIONS:
        break;
      case GAMETYPE_CATEGORIES:
        break;
      case GAMETYPE_LEVELS:
        mCurrentGame =
            new ClassGameLevels(
                mCurrentGameType,
                3,
                10,
                10,
                mRestartLivesEachLevel,
                mTriviaDb,
                mTimeToAnswerQuestion);

        break;

      default:
        break;
    }

    mCurrentGame.setGameListener(this);
    // TODO: change this to start from certain level
    mCurrentGame.setupNewGame(0);
    textViewLivesLeftValue.setText(mCurrentGame.getCurrentLivesAsString());
    textViewGameScoreText.setText(mCurrentGame.getGameScoreAsString());
    showStartLevel();
  }
Esempio n. 2
0
  private void checkAnswer(int i, Button o_Button) {
    //
    mCurrentGame.questionClockStop();
    // this is implemented in order to prevent double click
    disableAnswerButtons();

    // checking if time is up
    if (i == -1) {
      startSoundFromSoundPool(mSoundAnswerWrong, 0);
      mCurrentGame.checkIsAnswerCorrect(i);

    } else if (i == -2) {
      // if pass question pressed
    } else {
      if (mCurrentGame.checkIsAnswerCorrect(i)) {

        setButtonGreen(o_Button);

        startSoundFromSoundPool(mSoundAnswerCorrect, 0);

        mTriviaDb.incUserCorrectCounter(mCurrentQuestion.getQuestionId());

        toastLastScore();
        setGameScoreText(mCurrentGame.getGameScoreAsString());
      } else {

        startSoundFromSoundPool(mSoundAnswerWrong, 0);

        setButtonRed(o_Button);
        mTriviaDb.incUserWrongCounter(mCurrentQuestion.getQuestionId());

        // checking if the user answer wrong and we need to show the
        // correct answer
        if (mShowCorrectAnswer) {
          setButtonGreen(mCurrentQuestion.getCorrectAnswerIndex());
        }
      }
    }

    textViewLivesLeftValue.setText(mCurrentGame.getCurrentLivesAsString());

    new StartNewQuestionAsync().execute(1000);
  }