Пример #1
0
  public void update() {
    // textClue.setText("aaaa" + p++);

    textBeaconList.setText("--------------------------------------------------\n");
    String s = "";

    // beaconList = EstimoteManager.getBeaconList();

    for (Entry<String, MyBeacon> entry : EstimoteManager.getBeaconList().entrySet()) {
      // entry.getValue().updateDistance();
      String name = entry.getValue().getName(); // entry.getValue().getName();
      String distance = String.format(Locale.UK, "%.2f", entry.getValue().getDistance());
      s += name + " - " + distance + "\n";
    }

    textBeaconList.getElement().append(s);

    textBeaconList
        .getElement()
        .append(
            "\n"
                + "AccX: "
                + AccelerometerManager.getX()
                + "\n"
                + "AccY: "
                + AccelerometerManager.getY()
                + "\n"
                + "AccZ: "
                + AccelerometerManager.getZ()
                + "\n\n"
                + "Text size: "
                + Globals.getTextSize());

    textBeaconList.getElement().append("\n--------------------------------------------------");
  }
Пример #2
0
  public void sceneInit(Activity aIn, boolean visible) {
    textBeaconList = new TextObject("", aIn, Globals.newId());
    textBeaconList.getElement().setTextSize(Globals.getTextSize() * 1.8f);
    addElementToView(textBeaconList);

    super.sceneInit(aIn, visible);

    handler.postDelayed(runnable, 100);
  }
Пример #3
0
  @Override
  public void sceneInit(Activity aIn, boolean visible) {
    itemSetup(aIn);
    Bitmap b = Bitmap.createBitmap(Colour.ArrFromRGB(0, 0, 0, 180), 1, 1, Bitmap.Config.ARGB_8888);
    menuOverlay = new ImageObject(b, aIn, Globals.newId(), false);
    menuOverlay.setLayoutParams(
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
    menuOverlay.getElement().setScaleType(ScaleType.FIT_XY);
    menuOverlay.getElement().setClickable(false);
    menuOverlay.setVisibility(View.GONE);

    int marginWidth = (int) (Globals.screenDimensions.x / 2 - (menuFactsSylvie.getWidth() * 1.3f));

    menuFactsFieldGun.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    menuFactsFieldGun.getLayoutParams().setMargins(marginWidth, 0, 0, 0);

    menuFactsSylvie.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    menuFactsSylvie.getLayoutParams().setMargins(0, 0, marginWidth, 0);

    menuFactsLoco.getLayoutParams().setMargins(marginWidth, 0, 0, 0);
    menuFactsLoco.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    menuFactsLoco.addRule(RelativeLayout.ABOVE, menuFactsFieldGun.getId());

    menuFactsTank.getLayoutParams().setMargins(0, 0, marginWidth, 0);
    menuFactsTank.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    menuFactsTank.addRule(RelativeLayout.ABOVE, menuFactsSylvie.getId());

    menuFactsPlanePropellers.getLayoutParams().setMargins(marginWidth, 0, 0, 0);
    menuFactsPlanePropellers.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    menuFactsPlanePropellers.addRule(RelativeLayout.BELOW, menuFactsFieldGun.getId());

    menuFactsCrawler.getLayoutParams().setMargins(0, 0, marginWidth, 0);
    menuFactsCrawler.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    menuFactsCrawler.addRule(RelativeLayout.BELOW, menuFactsSylvie.getId());

    menuContinue = new ButtonObject("CONTINUE\nPLAYING", aIn, Globals.newId());
    menuContinue.getElement().setTypeface(Globals.Fonts.MajorShift());
    menuContinue.getLayoutParams().setMargins(0, Globals.screenDimensions.y / 36, 0, 0);
    menuContinue.getElement().setTextSize(Globals.getTextSize() * 1.4f);
    menuContinue.getElement().setBackgroundColor(android.graphics.Color.TRANSPARENT);
    menuContinue.addRule(RelativeLayout.BELOW, menuFactsPlanePropellers.getId());

    menuGallery = new ButtonObject("VIEW\nGALLERY", aIn, Globals.newId());
    menuGallery.getElement().setTypeface(Globals.Fonts.MajorShift());
    menuGallery.getLayoutParams().setMargins(0, 0, 0, Globals.screenDimensions.y / 36);
    menuGallery.getElement().setTextSize(Globals.getTextSize() * 1.8f);
    menuGallery.getElement().setBackgroundColor(android.graphics.Color.TRANSPARENT);
    menuGallery.addRule(RelativeLayout.ABOVE, menuFactsLoco.getId());

    listMenuScreen.add(menuOverlay);
    listMenuScreen.add(menuGallery);

    for (int i = 0; i < 6; i++) listMenuScreen.add(menuFactsheets[i]);

    listMenuScreen.add(menuContinue);

    listMainScreen.add(mainImageClue);
    listMainScreen.add(mainTextStatus);
    listMainScreen.add(mainImageTransportation);
    listMainScreen.add(mainImagePressMe);
    listMainScreen.add(mainHealthBar);
    listMainScreen.add(mainButtonMenu);
    // listMainScreen.add(mainDebug);
    listMainScreen.add(mainToggleClue);
    listMainScreen.add(mainElapsedTime);

    listMissionScreen.add(missionBackground);
    listMissionScreen.add(missionButtonNext);
    listMissionScreen.add(missionText);
    listMissionScreen.add(missionCrosshair);
    listMissionScreen.add(crosshairIndicator);
    listMissionScreen.add(missionGivenStatus);

    listClueScreen.add(mainImageClue);
    listClueScreen.add(mainTextStatus);
    listClueScreen.add(mainButtonMenu);
    // listClueScreen.add(mainDebug);
    listClueScreen.add(mainToggleClue);
    listClueScreen.add(mainElapsedTime);
    listClueScreen.add(mainTextClue);
    listClueScreen.add(mainHealthBar);

    for (AbstractElement a : listMainScreen) addElementToView(a);

    for (AbstractElement a : listClueScreen) addElementToView(a);

    for (AbstractElement a : listMenuScreen) addElementToView(a);

    for (AbstractElement a : listMissionScreen) addElementToView(a);

    listMainScreen.add(crosshairIndicator);
    addElementToView(crosshairIndicator);

    setClickEvents();
    setScene(ScreenState.MAIN);

    super.sceneInit(aIn, visible);

    Arrays.fill(missionCompletionTimes, 0);
    Arrays.fill(missionCompletion, false);

    screenState = ScreenState.MISSION;
    missionSetup();

    crosshairOffsetX = missionCrosshair.getHeight() / 2;
    crosshairOffsetX -= crosshairIndicator.getHeight() / 2;

    crosshairOffsetY = missionCrosshair.getWidth() / 2;
    crosshairOffsetY -= crosshairIndicator.getWidth() / 2;

    transportOffsetX = mainImageTransportation.getHeight() / 2;
    transportOffsetX -= crosshairIndicator.getHeight() / 2;

    transportOffsetY = mainImageTransportation.getWidth() / 2;

    handler.postDelayed(runnable, 100);
  }
Пример #4
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;
  }