// Line Collision private void checkLineQuestionColision() { // Coord Lines init if (currentLineXcoord == question.getXNumber() && currentLineYcoord == question.getYNumber()) { initQuestion(); } }
@Override public void onCollisionDetected(NewNumberPanel v, int getDigit, int answerPanelPosition) { Log.i( "apDigit", Integer.toString(arrayAnswerPanelView.get(answerPanelPosition).getCurrentDigit())); // Number Panel init if (arrayAnswerPanelView.get(0).getCurrentDigit() == question.getXNumber() && arrayAnswerPanelView.get(1).getCurrentDigit() == question.getYNumber()) { for (int i = 0; i < apAmmount; i++) { arrayAnswerPanelView .get(i) .getCurrentNumberPanel() .resetNumberPanelPosition(arrayAnswerPanelView.get(i).getCurrentNumberPanel()); arrayAnswerPanelView.get(i).getCurrentNumberPanel().setInAnswerPannel(false); arrayAnswerPanelView.get(i).unloadAnswerPanel(); } initQuestion(); } }
// ************************* Initialize Question ********************************* private void initQuestion() { Log.i("fullCClassName", className); if (numberOfQuestionsRemaining < 1) { Intent intent = new Intent(NegativeCoordActivity.this, ResultActivity.class); intent.putExtra("Score", scoreTotal); intent.putExtra("ClassName", className); intent.putExtra("Level", 3); startActivity(intent); finish(); } else { if (firstQuestion == false) { numberOfQuestionsRemaining--; Random randScore = new Random(); int low = 0; int high = 0; if (seconds <= 5) { low = 40; high = 50; } if (seconds > 5 && seconds <= 7) { low = 30; high = 40; } if (seconds > 7) { low = 10; high = 30; } score = randScore.nextInt(high - low + 1) + low; scoreTotal = scoreTotal + score; scoreText.setText(Integer.toString(score)); scoreText.startAnimation(scoreTextAnimmation); timerHandler.removeCallbacks(timerRunnable); } firstQuestion = false; seconds = 0; timerHandler.postDelayed(timerRunnable, 0); ProgressBarAnimation anim = new ProgressBarAnimation(scoreBar, scoreBar.getProgress(), scoreTotal); anim.setDuration(300); scoreBar.startAnimation(anim); if (STAR_ONE_ENABLED == 0) { if (scoreBar.getProgress() >= (scoreBar.getMax() / 2)) { StarView star1 = new StarView( this, scoreLayout, new RelativeLayout.LayoutParams(starOne.getWidth(), starOne.getHeight()), starOne); scoreLayout.addView(star1); star1.translateAndShine(new ImageView(this)); STAR_ONE_ENABLED = 1; } } if (STAR_TWO_ENABLED == 0) { if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.7) - scoreBar.getMax())) { StarView star2 = new StarView( this, scoreLayout, new RelativeLayout.LayoutParams(starTwo.getWidth(), starTwo.getHeight()), starTwo); scoreLayout.addView(star2); star2.translateAndShine(new ImageView(this)); STAR_TWO_ENABLED = 1; } } if (STAR_THREE_ENABLED == 0) { if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.8) - scoreBar.getMax())) { StarView star3 = new StarView( this, scoreLayout, new RelativeLayout.LayoutParams(starThree.getWidth(), starThree.getHeight()), starThree); scoreLayout.addView(star3); star3.translateAndShine(new ImageView(this)); STAR_THREE_ENABLED = 1; } } // ***** Type of Question ***** // Init question Random random = new Random(); int randomCoordX = random.nextInt(8) - 4; int randomCoordY = random.nextInt(8) - 4; question = new QuestionCoord(randomCoordX, randomCoordY); // Move Lines if (numberOfQuestionsRemaining > (numberOfQuestions / 2)) { marker.setVisibility(View.INVISIBLE); // Positive questionCoordX.setText(question.getxString()); questionCoordY.setText(question.getyString()); currentLineXcoord = 0; currentLineYcoord = 0; setLinePositions(glv); coordNumbersX.setText("x"); coordNumbersY.setText("y"); } // Drag Number Panels Positive else { if (numberOfQuestionsRemaining == (numberOfQuestions / 2)) { gridLayout.removeView(lineX); gridLayout.removeView(lineY); questionCoordX.setText("x"); questionCoordY.setText("y"); initNumberPadAndAnswePanel(); initSwitches(); } marker.setVisibility(View.INVISIBLE); // Match x&y to question x&y AxisX x = null; AxisY y = null; for (int i = 0; i < glv.getAxisXlines().size(); i++) { if (glv.getAxisXlines().get(i).xNumber == question.getXNumber()) { x = glv.getAxisXlines().get(i); } if (glv.getAxisYlines().get(i).yNumber == question.getYNumber()) { y = glv.getAxisYlines().get(i); } } marker.setX(((int) x.x) - marker.getWidth() / 2); marker.setY(((int) y.y) - marker.getHeight() / 2); scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f); scaleIn.setDuration(300); scaleIn.setStartOffset(200); scaleIn.setInterpolator(new OvershootInterpolator()); scaleIn.setFillAfter(true); scaleIn.setAnimationListener( new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) {} @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationStart(Animation animation) { marker.setVisibility(View.VISIBLE); } }); marker.startAnimation(scaleIn); coordNumbersX.setText("x"); coordNumbersY.setText("y"); } } }