First implementation of innovations in Tool Shop
This commit is contained in:
@ -33,10 +33,6 @@ public class ToolUpgrade {
|
||||
return getValueAtLevel(currentLevel);
|
||||
}
|
||||
|
||||
public float getValueAtNextLevel() {
|
||||
return getValueAtLevel(currentLevel + 1);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
@ -20,11 +20,10 @@ public class ToolInspector implements View.OnClickListener {
|
||||
private ToolShopScreen toolShopScreen;
|
||||
|
||||
private TextView title;
|
||||
private TextView levelView;
|
||||
private ImageView imageView;
|
||||
private PriceButton priceButton;
|
||||
|
||||
private ToolUpgradeView toolUpgradeView0;
|
||||
private ToolUpgradeView toolUpgradeView1;
|
||||
private TextView description;
|
||||
|
||||
private ToolType toolType;
|
||||
private boolean locked;
|
||||
@ -35,47 +34,54 @@ public class ToolInspector implements View.OnClickListener {
|
||||
Typeface typeface = gameActivity.getTypeface();
|
||||
title = (TextView) layout.findViewById(R.id.tool_inspector_title);
|
||||
title.setTypeface(typeface);
|
||||
levelView = (TextView) layout.findViewById(R.id.tool_inspector_level_view);
|
||||
levelView.setTypeface(typeface);
|
||||
imageView = (ImageView) layout.findViewById(R.id.tool_inspector_imageview);
|
||||
priceButton = new PriceButton(gameActivity, typeface,
|
||||
layout.findViewById(R.id.tool_inspector_pricebutton), this);
|
||||
toolUpgradeView0 = new ToolUpgradeView(this, gameActivity, typeface,
|
||||
layout.findViewById(R.id.tool_inspector_toolupgrade0));
|
||||
toolUpgradeView1 = new ToolUpgradeView(this, gameActivity, typeface,
|
||||
layout.findViewById(R.id.tool_inspector_toolupgrade1));
|
||||
description = (TextView) layout.findViewById(R.id.tool_inspector_description);
|
||||
description.setTypeface(typeface);
|
||||
}
|
||||
|
||||
public void update(ToolType toolType, boolean locked) {
|
||||
this.toolType = toolType;
|
||||
this.locked = locked;
|
||||
this.title.setText(locked ? R.string.tool_name_unknown : toolType.getName());
|
||||
this.imageView.setImageDrawable(gameActivity.getResources().getDrawable(
|
||||
title.setText(locked ? R.string.tool_name_locked : toolType.getName());
|
||||
levelView.setText(gameActivity.getString(R.string.tool_level_format_d, toolType.getUpgrade().getCurrentLevel()));
|
||||
levelView.setVisibility(locked ? View.INVISIBLE : View.VISIBLE);
|
||||
imageView.setImageDrawable(gameActivity.getResources().getDrawable(
|
||||
locked ? R.drawable.tools_button_locked : toolType.getButtonDrawable()));
|
||||
priceButton.init(R.string.price_button_buy, toolType.getPrice(), R.drawable.currency_star);
|
||||
priceButton.setLayoutVisible(toolType.isBought() || locked ? View.GONE : View.VISIBLE);
|
||||
priceButton.setLayoutEnabled(toolType.getPrice() <= gameActivity.getUser().getStarCount());
|
||||
description.setText(locked ? R.string.tool_description_locked : toolType.getDescription());
|
||||
|
||||
toolUpgradeView0.update(toolType.getUpgrades()[0], toolType.isBought(),
|
||||
gameActivity.getUser().getEnergyCount());
|
||||
toolUpgradeView0.setLayoutVisiblity(locked ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (toolType.getUpgrades().length <= 1 || locked)
|
||||
toolUpgradeView1.setLayoutVisiblity(View.GONE);
|
||||
else {
|
||||
toolUpgradeView1.setLayoutVisiblity(View.VISIBLE);
|
||||
toolUpgradeView1.update(toolType.getUpgrades()[1], toolType.isBought(),
|
||||
gameActivity.getUser().getEnergyCount());
|
||||
if (!toolType.isBought()) {
|
||||
priceButton
|
||||
.init(R.string.price_button_buy, toolType.getPrice(), 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());
|
||||
}
|
||||
}
|
||||
|
||||
public void onToolUpgraded(int price) {
|
||||
private void onToolUpgraded(int price) {
|
||||
toolType.getUpgrade().setCurrentLevel(toolType.getUpgrade().getCurrentLevel()+1);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,84 +0,0 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.entities.tools.ToolUpgrade;
|
||||
|
||||
/**
|
||||
* Created by Julian on 01.08.2016.
|
||||
*/
|
||||
public class ToolUpgradeView implements View.OnClickListener {
|
||||
|
||||
private ToolInspector toolInspector;
|
||||
private Context context;
|
||||
|
||||
private View layout;
|
||||
private TextView title;
|
||||
private ImageView imageView;
|
||||
private TextView valueOld;
|
||||
private TextView valueNew;
|
||||
private PriceButton priceButton;
|
||||
|
||||
private ToolUpgrade upgrade;
|
||||
private boolean toolBought;
|
||||
private int availableEnergy;
|
||||
|
||||
public ToolUpgradeView(ToolInspector toolInspector, Context context, Typeface typeface, View layout) {
|
||||
this.toolInspector = toolInspector;
|
||||
this.context = context;
|
||||
this.layout = layout;
|
||||
|
||||
title = (TextView) layout.findViewById(R.id.tool_upgrade_title);
|
||||
title.setTypeface(typeface);
|
||||
imageView = (ImageView) layout.findViewById(R.id.tool_upgrade_imageview);
|
||||
valueOld = (TextView) layout.findViewById(R.id.tool_upgrade_value_old);
|
||||
valueOld.setTypeface(typeface);
|
||||
valueNew = (TextView) layout.findViewById(R.id.tool_upgrade_value_new);
|
||||
valueNew.setTypeface(typeface);
|
||||
priceButton = new PriceButton(context, typeface,
|
||||
layout.findViewById(R.id.tool_upgrade_pricebutton), this);
|
||||
}
|
||||
|
||||
public void update(ToolUpgrade toolUpgrade, boolean toolBought, int availableEnergy) {
|
||||
this.upgrade = toolUpgrade;
|
||||
this.toolBought = toolBought;
|
||||
this.availableEnergy = availableEnergy;
|
||||
this.title.setText(context.getString(R.string.tool_upgrade_title_format_sd,
|
||||
context.getString(toolUpgrade.getType().getName()), toolUpgrade.getCurrentLevel()));
|
||||
this.imageView.setImageDrawable(
|
||||
context.getResources().getDrawable(toolUpgrade.getType().getDrawable()));
|
||||
updateValueViews();
|
||||
priceButton.init(R.string.price_button_upgrade, toolUpgrade.getPrice(),
|
||||
R.drawable.currency_energy);
|
||||
priceButton.setLayoutVisible(isAtMaxLevel() ? View.GONE : View.VISIBLE);
|
||||
priceButton.setLayoutEnabled(toolBought && toolUpgrade.getPrice() <= availableEnergy);
|
||||
}
|
||||
|
||||
public void setLayoutVisiblity(int visiblity) {
|
||||
layout.setVisibility(visiblity);
|
||||
}
|
||||
|
||||
private void updateValueViews() {
|
||||
String unit = upgrade.getType().getUnit();
|
||||
valueOld.setText(upgrade.getValueAtCurrentLevel() + unit);
|
||||
valueNew.setText(upgrade.getValueAtNextLevel() + unit);
|
||||
if (isAtMaxLevel())
|
||||
valueNew.setText(R.string.tool_upgrade_value_max);
|
||||
}
|
||||
|
||||
private boolean isAtMaxLevel() {
|
||||
return upgrade.getCurrentLevel() >= upgrade.getMaxLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
upgrade.setCurrentLevel(upgrade.getCurrentLevel() + 1);
|
||||
update(upgrade, toolBought, availableEnergy);
|
||||
toolInspector.onToolUpgraded(upgrade.getPrice());
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
android:id="@+id/levelbutton_textview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_placeholder"
|
||||
android:text="@string/placeholder_button"
|
||||
android:textSize="30sp"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textColor="#ffae00"
|
||||
android:textSize="60sp"
|
||||
android:textStyle="bold"
|
||||
|
@ -13,7 +13,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/button_placeholder"
|
||||
android:text="@string/placeholder_button"
|
||||
android:textSize="13sp"/>
|
||||
|
||||
<LinearLayout
|
||||
@ -27,7 +27,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="2dp"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textSize="15sp"/>
|
||||
|
||||
<ImageView
|
||||
|
@ -9,7 +9,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/button_placeholder"
|
||||
android:text="@string/placeholder_button"
|
||||
android:textSize="30sp"/>
|
||||
|
||||
<Button
|
||||
|
@ -1,25 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/tool_inspector_width"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#e6ffc936">
|
||||
android:background="#e6ffc936"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tool_inspector_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/textview_placeholder"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/placeholder_textview"
|
||||
android:textAlignment="center"
|
||||
android:textSize="28sp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tool_inspector_title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
@ -40,34 +39,25 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
<TextView
|
||||
android:id="@+id/tool_inspector_level_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/linearLayout3"
|
||||
android:layout_centerInParent="true">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/placeholder_textview"
|
||||
android:textSize="22sp"/>
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tool_inspector_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/tool_inspector_toolupgrade0"
|
||||
layout="@layout/tool_upgrade"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/tool_inspector_toolupgrade1"
|
||||
layout="@layout/tool_upgrade"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:text="A simple tool which will get you in the air"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -8,7 +8,7 @@
|
||||
android:id="@+id/toolofferslot_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/textview_placeholder"
|
||||
android:text="@string/placeholder_textview"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textSize="25sp"/>
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
android:id="@+id/tool_upgrade_value_old"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/percent_placeholder"
|
||||
android:text="@string/placeholder_percent"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<ImageView
|
||||
@ -60,7 +60,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/percent_placeholder"
|
||||
android:text="@string/placeholder_percent"
|
||||
android:textSize="16sp"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
||||
<include
|
||||
android:id="@+id/toolshop_toolinspector"
|
||||
layout="@layout/tool_inspector"
|
||||
android:layout_width="170dp"
|
||||
android:layout_width="@dimen/tool_inspector_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"/>
|
||||
</RelativeLayout>
|
||||
|
@ -58,7 +58,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/topbar_starview"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textSize="25sp"/>
|
||||
|
||||
<TextView
|
||||
@ -67,7 +67,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/topbar_energyview"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textSize="25sp"/>
|
||||
|
||||
<Button
|
||||
@ -75,7 +75,7 @@
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/xml_selector_settingsbutton"/>
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
android:layout_height="40dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/topbar_settings"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="@drawable/xml_selector_toolshopbutton"/>
|
||||
|
||||
<Button
|
||||
@ -96,7 +96,7 @@
|
||||
android:layout_height="40dp"
|
||||
android:layout_toLeftOf="@+id/topbar_toolshop"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="@drawable/xml_selector_shapeshopbutton"/>
|
||||
|
||||
<TextView
|
||||
@ -105,7 +105,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/topbar_starcount"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textSize="20sp"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
@ -115,7 +115,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/topbar_energycount"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/number_placeholder"
|
||||
android:text="@string/placeholder_number"
|
||||
android:textSize="20sp"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
|
4
app/src/main/res/values/dimen.xml
Normal file
4
app/src/main/res/values/dimen.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="tool_inspector_width">170dp</dimen>
|
||||
</resources>
|
@ -1,9 +1,9 @@
|
||||
<resources>
|
||||
<string name="app_name">Endless Roll</string>
|
||||
<string name="button_placeholder">Click me!</string>
|
||||
<string name="textview_placeholder">I\'m a text!</string>
|
||||
<string name="number_placeholder">997.5</string>
|
||||
<string name="percent_placeholder">85.1%</string>
|
||||
<string name="placeholder_button">Click me!</string>
|
||||
<string name="placeholder_textview">I\'m a text!</string>
|
||||
<string name="placeholder_number">997.5</string>
|
||||
<string name="placeholder_percent">85.1%</string>
|
||||
|
||||
<string name="game_playerprogress_placeholder">0.0m</string>
|
||||
<string name="game_playerprogress_format_f">%.1fm</string>
|
||||
@ -50,12 +50,19 @@
|
||||
<string name="playershape_name_wheel">Wheel</string>
|
||||
<string name="playershape_name_sun">Sun</string>
|
||||
|
||||
<string name="tool_name_unknown">\?\?\?</string>
|
||||
<string name="tool_description_locked">You will unlock this mysterious tool later</string>
|
||||
<string name="tool_description_ramp">A simple tool that will get you in the air</string>
|
||||
<string name="tool_description_spring">It will get you way higher than the Ramp</string>
|
||||
<string name="tool_description_magnet">Difficult to handle, but if you master it...</string>
|
||||
<string name="tool_description_bomb">Blow up all obstacles near the bomb</string>
|
||||
<string name="tool_description_power_mushroom">This will give you super-powers for 5 seconds</string>
|
||||
<string name="tool_name_locked">\?\?\?</string>
|
||||
<string name="tool_name_ramp">Ramp</string>
|
||||
<string name="tool_name_spring">Spring</string>
|
||||
<string name="tool_name_magnet">Magnet</string>
|
||||
<string name="tool_name_bomb">Bomb</string>
|
||||
<string name="tool_name_power_mushroom">Power Mushroom</string>
|
||||
<string name="tool_level_format_d">Level: %d</string>
|
||||
<string name="tool_upgrade_title_format_sd">%1$s (Lv%2$d)</string>
|
||||
<string name="tool_upgrade_none">None</string>
|
||||
<string name="tool_upgrade_time">Time</string>
|
||||
|
Reference in New Issue
Block a user