@Override public void onBackPressed() { if (screenState == ScreenState.MAIN) System.exit(0); else if (screenState == ScreenState.CLUE) setScene(ScreenState.MAIN); else if (screenState == ScreenState.MENU) { if (!allMissionsCompleted) { if (health > 0) setScene(ScreenState.MAIN); else setScene(ScreenState.MISSION); } } }
private void gameplay() { float y = 0; if (missionType == MissionType.VERTICAL) y = AccelerometerManager.getZ() - 3.f; else y = AccelerometerManager.getY(); // Health effects if (Math.abs(AccelerometerManager.getX()) > 2 || Math.abs(y) > 2.3) { health -= Math.max(Math.abs(AccelerometerManager.getX()), Math.abs(y)); } else if (health < 100) health++; if (health < 0) { health = 0; missionGivenStatus.setText("You failed! Try again!"); if (screenState == ScreenState.MAIN || screenState == ScreenState.CLUE) setScene(ScreenState.MISSION); return; } mainHealthBar.setValue(health); float rotVal = 0; if (missionType == MissionType.VERTICAL) rotVal = -(AccelerometerManager.getX() * 4.5f); else if (missionType == MissionType.HORIZONTAL) rotVal = -(AccelerometerManager.getY() * 4.5f); mainImageTransportation.rotate(rotVal); rotVal = Math.abs(rotVal); mainImageTransportation .getElement() .setColorFilter( Colour.FromRGB( (int) (102 + (rotVal * 2.5f)), (int) (123 - (rotVal * 2.5f)), (int) (42 - (rotVal))), PorterDuff.Mode.MULTIPLY); long millis = System.currentTimeMillis() - startTime; int seconds = (int) (millis / 1000); int minutes = seconds / 60; seconds = seconds % 60; mainElapsedTime.setText(String.format("Current elapsed \ntime: %d:%02d", minutes, seconds)); }
public void onLoad() { ((GameActivity) activity).getLayout().get().setBackgroundResource(R.drawable.background_newtoo); setScene(screenState); if (startTime == 0) startTime = System.currentTimeMillis(); }
private void missionSetup() { playing = false; if (currentMission >= 0) { missionCompletionTimes[currentMission] = System.currentTimeMillis(); menuFactsheets[currentMission].setImage(missionFactsheetImages[currentMission]); menuFactsheets[currentMission].setAbsScaleY(Globals.screenDimensions.y / 6); missionGivenStatus.setText( missionTitles[currentMission] + " mission complete!\nFactsheet unlocked in menu!"); missionCompletion[currentMission] = true; } boolean allComplete = true; for (boolean x : missionCompletion) if (!x) { allComplete = false; break; } if (allComplete) { allMissionsCompleted = true; currentMission = missionCompletion.length + 1; missionText.setText("All missions complete!\n\n"); menuContinue.setText("All missions complete!"); for (int i = 0; i < 6; i++) { long millis = missionCompletionTimes[i] - missionStartTimes[i]; int seconds = (int) (millis / 1000); int minutes = seconds / 60; seconds = seconds % 60; missionText .getElement() .append(missionTitles[i] + String.format(": %d:%02d\n", minutes, seconds)); } missionText .getElement() .append("\nClick the button to go back to menu and view your factsheets!"); missionCrosshair.setVisibility(View.GONE); crosshairIndicator.setVisibility(View.GONE); return; } do { currentMission = random.nextInt(6); } while (missionCompletion[currentMission] == true); if (currentMission == 0 || currentMission == 3 || currentMission == 5) { missionType = MissionType.VERTICAL; if (missionTitles[currentMission] == "Sylvie") mainImageTransportation.setImage(R.drawable.transportation_sylvie); else mainImageTransportation.setImage(R.drawable.transportation_crawler_green); } else { missionType = MissionType.HORIZONTAL; mainImageTransportation.setImage(R.drawable.transportation_horizontal_green); } mainImageTransportation.setAbsScaleY(Globals.screenDimensions.y / 4); mainTextClue.setText(missionClues[currentMission]); crosshairIndicator.setVisibility(View.VISIBLE); startTime = System.currentTimeMillis(); missionStartTimes[currentMission] = startTime; missionText.setText(missionIntroductions[currentMission] + "\n\n"); }