Exemple #1
0
  public void update() {
    // Dave the powerups when they change
    Bundle saveGameData = new Bundle();
    saveGameData.putSerializable(Constants.POWERUPS, powerUps);
    new GameSaver().savePowerUps(this, saveGameData);

    hints.setText(powerUps.getHintsAsString());
    skips.setText(powerUps.getSkipsAsString());
    coins.setText(powerUps.getPointsAsString());
  }
Exemple #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shop_menu_activity);
    Intent previousActivity = getIntent();

    // Get powerups from previous Activity
    powerUps = (PowerUps) previousActivity.getSerializableExtra(Constants.POWERUPS);

    // Skips button
    buy_skips = (LinearLayout) findViewById(R.id.shop_buy_skips_btn);

    // Text views for numbers
    hints = (TextView) findViewById(R.id.hints_count_text);
    skips = (TextView) findViewById(R.id.skips_count_text);
    coins = (TextView) findViewById(R.id.coins_count_text);

    // Set up buy hints button
    TextView hint_text = (TextView) findViewById(R.id.shop_button_text);
    TextView hint_subtext = (TextView) findViewById(R.id.shop_button_subtext);
    ImageView hint_image = (ImageView) findViewById(R.id.shop_button_image);

    hint_text.setText(getResources().getString(R.string.buy_hints));
    String hintSubtext =
        "(" + powerUps.getHintsCost() + " " + getResources().getString(R.string.points) + ")";
    hint_subtext.setText(hintSubtext);
    hint_image.setImageResource(R.drawable.hint_icon);

    buy_hints = (LinearLayout) findViewById(R.id.shop_buy_hints_btn);

    // Set listeners for the buttons
    Bundle hintsBundle = new Bundle();
    hintsBundle.putString(Constants.MESSAGE, Constants.HINTS);
    hintsBundle.putSerializable(Constants.POWERUPS, powerUps);
    buy_hints.setOnClickListener(new ShopButtonListener(this, hintsBundle));

    Bundle skipsBundle = new Bundle();
    skipsBundle.putString(Constants.MESSAGE, Constants.SKIPS);
    skipsBundle.putSerializable(Constants.POWERUPS, powerUps);
    buy_skips.setOnClickListener(new ShopButtonListener(this, skipsBundle));

    update(); // Update method sets the contents of the text views
  }