Example #1
0
  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));
  }
Example #2
0
  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;
  }