Finished toolshop updates (Tool upgrades and more)
This commit is contained in:
@ -9,6 +9,7 @@ import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.entities.tools.ToolType;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.screens.ToolShopScreen;
|
||||
import de.frajul.endlessroll.user.LevelUpBounties;
|
||||
|
||||
/**
|
||||
* Created by Julian on 03.06.2017.
|
||||
@ -47,41 +48,45 @@ public class ToolInspector implements View.OnClickListener {
|
||||
this.toolType = toolType;
|
||||
this.locked = locked;
|
||||
title.setText(locked ? R.string.tool_name_locked : toolType.getName());
|
||||
levelView.setText(gameActivity.getString(R.string.tool_level_format_d, toolType.getUpgrade().getCurrentLevel()));
|
||||
levelView.setText(gameActivity
|
||||
.getString(R.string.tool_level_format_d, toolType.getCurrentUpgradeLevel()));
|
||||
levelView.setVisibility(locked ? View.INVISIBLE : View.VISIBLE);
|
||||
imageView.setImageDrawable(gameActivity.getResources().getDrawable(
|
||||
locked ? R.drawable.tools_button_locked : toolType.getButtonDrawable()));
|
||||
description.setText(locked ? R.string.tool_description_locked : toolType.getDescription());
|
||||
|
||||
String descriptionLocked = gameActivity.getString(R.string.tool_description_locked_format_d, gameActivity.getUser().getLevelUpBounties().getLevelToolIsUnlocked(toolType));
|
||||
String toolDescription = gameActivity.getString(toolType.getDescription());
|
||||
description.setText(locked ? descriptionLocked : toolDescription);
|
||||
|
||||
if (!toolType.isBought()) {
|
||||
priceButton
|
||||
.init(R.string.price_button_buy, toolType.getPrice(), R.drawable.currency_star);
|
||||
priceButton.init(R.string.price_button_buy, toolType.getBuyPrice(),
|
||||
R.drawable.currency_star);
|
||||
priceButton.setLayoutVisible(locked ? View.GONE : View.VISIBLE);
|
||||
priceButton
|
||||
.setLayoutEnabled(toolType.getPrice() <= gameActivity.getUser().getStarCount());
|
||||
} else {
|
||||
priceButton.init(R.string.price_button_upgrade, toolType.getUpgrade().getPrice(),
|
||||
R.drawable.currency_energy);
|
||||
priceButton.setLayoutVisible(toolType.getUpgrade().getCurrentLevel() == toolType.getUpgrade().getMaxLevel() ? View.GONE : View.VISIBLE);
|
||||
priceButton.setLayoutEnabled(
|
||||
toolType.getUpgrade().getPrice() <= gameActivity.getUser().getEnergyCount());
|
||||
toolType.getBuyPrice() <= gameActivity.getUser().getStarCount());
|
||||
} else {
|
||||
priceButton.init(R.string.price_button_upgrade, toolType.getUpgradePrice(),
|
||||
R.drawable.currency_energy);
|
||||
priceButton.setLayoutVisible(toolType.isAtMaxUpgradeLevel() ? View.GONE : View.VISIBLE);
|
||||
priceButton.setLayoutEnabled(
|
||||
toolType.getUpgradePrice() <= gameActivity.getUser().getEnergyCount());
|
||||
}
|
||||
}
|
||||
|
||||
private void onToolUpgraded(int price) {
|
||||
toolType.getUpgrade().setCurrentLevel(toolType.getUpgrade().getCurrentLevel()+1);
|
||||
toolType.upgrade();
|
||||
toolShopScreen.onToolUpgraded(price);
|
||||
update(toolType, locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(!toolType.isBought()){
|
||||
toolType.setBought(true);
|
||||
update(toolType, locked);
|
||||
toolShopScreen.onToolBought(toolType.getPrice(), toolType);
|
||||
}else{
|
||||
onToolUpgraded(toolType.getUpgrade().getPrice());
|
||||
if (!toolType.isBought()) {
|
||||
toolType.setBought(true);
|
||||
update(toolType, locked);
|
||||
toolShopScreen.onToolBought(toolType.getBuyPrice(), toolType);
|
||||
} else {
|
||||
onToolUpgraded(toolType.getUpgradePrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user