private void itemSetup(Activity aIn) { listMainScreen = new ArrayList<AbstractElement>(); listClueScreen = new ArrayList<AbstractElement>(); listMissionScreen = new ArrayList<AbstractElement>(); listMenuScreen = new ArrayList<AbstractElement>(); missionTitles = aIn.getResources().getStringArray(R.array.mission_titles_array); missionClues = aIn.getResources().getStringArray(R.array.mission_clues_array); missionIntroductions = aIn.getResources().getStringArray(R.array.mission_introductions_array); mainImageClue = new ImageObject(R.drawable.clue1, aIn, Globals.newId(), false); mainImageClue.alignToTop(); mainImageClue .getElement() .setPaddingRelative( 0, Globals.screenDimensions.y / 100, 0, Globals.screenDimensions.y / 100); mainImageClue.setAbsScaleY((int) (Globals.screenDimensions.y / 2.5f)); mainTextStatus = new TextObject("Mission status text box with long words everywhere", aIn, Globals.newId()); mainTextStatus.addRule(RelativeLayout.BELOW, mainImageClue.getId()); mainTextStatus .getElement() .setWidth(Globals.screenDimensions.x - (Globals.screenDimensions.x / 10)); mainTextStatus.getElement().setTextSize(Globals.getTextSize() * 0.9f); mainTextStatus.getElement().setGravity(Gravity.CENTER); mainTextStatus.getElement().setTypeface(Globals.Fonts.ExoRegular()); mainButtonMenu = new ButtonObject("Menu", aIn, Globals.newId()); mainButtonMenu.addRule(RelativeLayout.ALIGN_PARENT_TOP); mainButtonMenu.addRule(RelativeLayout.ALIGN_PARENT_LEFT); mainButtonMenu .getLayoutParams() .setMargins( (Globals.screenDimensions.x / 60), Globals.screenDimensions.y / 40, 0, Globals.screenDimensions.y / 20); mainButtonMenu.getElement().setTextColor(Colour.FromRGB(10, 0, 10)); mainButtonMenu.getElement().setBackgroundColor(Colour.Transparent); mainButtonMenu.getElement().setTypeface(Globals.Fonts.MajorShift()); mainButtonMenu.getElement().setTextSize(Globals.getTextSize() * 1.6f); mainDebug = new ButtonObject("Debug", aIn, Globals.newId()); mainDebug.addRule(RelativeLayout.ALIGN_PARENT_TOP); mainDebug.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); mainDebug .getLayoutParams() .setMargins(0, 0, (Globals.screenDimensions.x / 12), Globals.screenDimensions.y / 20); // mainDebug.getElement().setEnabled(false); // mainDebug.setVisibility(View.GONE); mainToggleClue = new ButtonObject("Toggle Clue", aIn, Globals.newId()); mainToggleClue.addRule(RelativeLayout.ALIGN_TOP, mainTextStatus.getId()); mainToggleClue.getLayoutParams().setMargins(0, Globals.screenDimensions.y / 14, 0, 0); mainToggleClue.getElement().setTextSize(Globals.getTextSize()); mainToggleClue.setWidth(Globals.screenDimensions.x / 4); mainImageTransportation = new ImageObject(R.drawable.transportation_crawler_green, aIn, Globals.newId(), true); mainImageTransportation.setBackgroundColour(Color.TRANSPARENT); mainImageTransportation.addRule(RelativeLayout.BELOW, mainToggleClue.getId()); mainImageTransportation.getLayoutParams().setMargins(0, Globals.screenDimensions.y / 20, 0, 0); mainImageTransportation.setAbsScaleY(Globals.screenDimensions.y / 4); mainImagePressMe = new ImageObject(R.drawable.press_me, aIn, Globals.newId(), false); mainImagePressMe.setAbsScaleX(Globals.screenDimensions.x / 4); mainImagePressMe.addRule(RelativeLayout.RIGHT_OF, mainImageTransportation.getId()); mainImagePressMe.addRule(RelativeLayout.ALIGN_TOP, mainImageTransportation.getId()); mainHealthBar = new ProgressBarObject(aIn, Globals.newId(), true); mainHealthBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mainHealthBar.getLayoutParams().setMargins(0, 0, 0, Globals.screenDimensions.y / 40); mainHealthBar.setWidth(mainImageTransportation.getWidth()); mainHealthBar.setValue(50); mainElapsedTime = new TextObject("Current elapsed time: 0:00", aIn, Globals.newId()); mainElapsedTime.addRule(RelativeLayout.ALIGN_TOP, mainToggleClue.getId()); mainElapsedTime.addRule(RelativeLayout.ALIGN_PARENT_LEFT); mainElapsedTime.getLayoutParams().setMargins(Globals.screenDimensions.x / 12, 0, 0, 0); mainElapsedTime.getElement().setGravity(Gravity.CENTER); mainElapsedTime.getElement().setTypeface(Globals.Fonts.ExoRegular()); mainElapsedTime.getElement().setTextSize(Globals.getTextSize() * 0.8f); mainTextClue = new TextObject( "This is the clue text it is clue text that contains a clue of varying length.", aIn, Globals.newId()); mainTextClue.addRule(RelativeLayout.ALIGN_TOP, mainToggleClue.getId()); mainTextClue.getElement().setTextSize(Globals.getTextSize() * 1.1f); mainTextClue.setWidth(Globals.screenDimensions.x / 2.2f); mainTextClue.getLayoutParams().setMargins(0, Globals.screenDimensions.y / 10, 0, 0); mainTextClue.getElement().setGravity(Gravity.CENTER); mainTextClue.getElement().setTypeface(Globals.Fonts.ExoRegular()); missionGivenStatus = new TextObject("", aIn, Globals.newId()); missionGivenStatus.addRule(RelativeLayout.ALIGN_PARENT_TOP); missionGivenStatus .getLayoutParams() .setMargins(0, Globals.screenDimensions.y / 20, 0, Globals.screenDimensions.y / 20); missionGivenStatus.getElement().setTextSize(Globals.getTextSize() * 1.1f); missionGivenStatus.getElement().setTypeface(Globals.Fonts.ChunkFive()); missionGivenStatus.setTextColour(Colour.FromRGB(255, 20, 20)); missionText = new TextObject("Teashdas", aIn, Globals.newId()); missionText.getElement().setTextSize(Globals.getTextSize()); missionText.addRule(RelativeLayout.BELOW, missionGivenStatus.getId()); missionText .getLayoutParams() .setMargins(Globals.screenDimensions.x / 10, 0, Globals.screenDimensions.x / 10, 0); missionText.getElement().setTypeface(Globals.Fonts.ExoRegular()); missionBackground = new ImageObject(R.drawable.background, aIn, Globals.newId(), false); missionBackground.setScale( Globals.screenDimensions.x - (Globals.screenDimensions.x / 10), Globals.screenDimensions.y - (Globals.screenDimensions.y / 10)); missionButtonNext = new ButtonObject("Continue", aIn, Globals.newId()); missionButtonNext.getLayoutParams().setMargins(0, 0, 0, Globals.screenDimensions.y / 15); missionButtonNext.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); missionCrosshair = new ImageObject(R.drawable.crosshair_red, aIn, Globals.newId(), false); missionCrosshair.setAbsScaleX(Globals.screenDimensions.x / 6); missionCrosshair.addRule(RelativeLayout.ABOVE, missionButtonNext.getId()); crosshairIndicator = new ImageObject(R.drawable.crosshair_red, aIn, Globals.newId(), false); crosshairIndicator.alignToTop(); crosshairIndicator.alignToLeft(); crosshairIndicator.setAbsScaleX(Globals.screenDimensions.x / 26); menuGallery = new ButtonObject("Gallery", aIn, Globals.newId()); menuFactsLoco = new ImageObject(R.drawable.factsheet_loco_locked, aIn, Globals.newId(), true); menuFactsTank = new ImageObject(R.drawable.factsheet_tank_locked, aIn, Globals.newId(), true); menuFactsFieldGun = new ImageObject(R.drawable.factsheet_fieldgun_locked, aIn, Globals.newId(), true); menuFactsSylvie = new ImageObject(R.drawable.factsheet_sylvie_locked, aIn, Globals.newId(), true); menuFactsPlanePropellers = new ImageObject(R.drawable.factsheet_plane_locked, aIn, Globals.newId(), true); menuFactsCrawler = new ImageObject(R.drawable.factsheet_crawler_locked, aIn, Globals.newId(), true); menuFactsLoco.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsTank.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsFieldGun.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsSylvie.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsPlanePropellers.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsCrawler.setAbsScaleY(Globals.screenDimensions.y / 6); menuFactsheets[0] = menuFactsLoco; menuFactsheets[1] = menuFactsTank; menuFactsheets[2] = menuFactsFieldGun; menuFactsheets[3] = menuFactsSylvie; menuFactsheets[4] = menuFactsPlanePropellers; menuFactsheets[5] = menuFactsCrawler; missionFactsheetImages[0] = R.drawable.factsheet_loco_unlocked; missionFactsheetImages[1] = R.drawable.factsheet_tank_unlocked; missionFactsheetImages[2] = R.drawable.factsheet_fieldgun_unlocked; missionFactsheetImages[3] = R.drawable.factsheet_sylvie_unlocked; missionFactsheetImages[4] = R.drawable.factsheet_plane_unlocked; missionFactsheetImages[5] = R.drawable.factsheet_crawler_unlocked; }
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"); }