Added toolinspector -> tool-upgrades can be bought (not saved yet)

only the time upgrade is used
This commit is contained in:
=
2017-06-10 13:19:34 +02:00
parent 504e2383fa
commit 4b4d81d8c7
46 changed files with 2940 additions and 5907 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,55 @@
package de.frajul.endlessroll.entities.tools;
/**
* Created by Julian on 09.06.2017.
*/
public class ToolUpgrade {
private ToolUpgradeType type;
private float first, step;
private int price;
private int maxLevel;
private int currentLevel = 1;
public ToolUpgrade(ToolUpgradeType type, float first, float last, float step, int price) {
this.type = type;
this.first = first;
this.step = step;
this.price = price;
maxLevel = (int) Math.abs((first - last) / step) + 1;
}
public ToolUpgradeType getType() {
return type;
}
public float getValueAtLevel(int level) {
return first + step * (level - 1);
}
public float getValueAtCurrentLevel() {
return getValueAtLevel(currentLevel);
}
public float getValueAtNextLevel() {
return getValueAtLevel(currentLevel + 1);
}
public int getMaxLevel() {
return maxLevel;
}
public int getPrice() {
return price;
}
public int getCurrentLevel() {
return currentLevel;
}
public void setCurrentLevel(int currentLevel) {
this.currentLevel = currentLevel;
}
}

View File

@ -0,0 +1,39 @@
package de.frajul.endlessroll.entities.tools;
import android.support.annotation.DrawableRes;
import de.frajul.endlessroll.R;
/**
* Created by Julian on 07.06.2017.
*/
public enum ToolUpgradeType {
NONE("None", "", R.drawable.tools_rampbutton), TIME("Time", "s", R.drawable.clock), RADIUS(
"Radius", "%", R.drawable.radius), FORCE("Force", "%", R.drawable.magnet_field);
private String name;
private String unit;
@DrawableRes
private int drawable;
ToolUpgradeType(String name, String unit, @DrawableRes int drawable) {
this.name = name;
this.unit = unit;
this.drawable = drawable;
}
public String getName() {
return name;
}
public String getUnit() {
return unit;
}
@DrawableRes
public int getDrawable() {
return drawable;
}
}

View File

@ -0,0 +1,51 @@
package de.frajul.endlessroll.views;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.DrawableRes;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import de.frajul.endlessroll.R;
/**
* Created by Julian on 01.08.2016.
*/
public class PriceButton {
private Context context;
private View layout;
private TextView title;
private TextView price;
private ImageView currencyView;
public PriceButton(Context context, Typeface typeface, View layout, View.OnClickListener onClickListener) {
this.context = context;
this.layout = layout;
layout.setOnClickListener(onClickListener);
title = (TextView) layout.findViewById(R.id.price_button_title);
title.setTypeface(typeface);
price = (TextView) layout.findViewById(R.id.price_button_price);
price.setTypeface(typeface);
currencyView = (ImageView) layout.findViewById(R.id.price_button_currency);
}
public void init(String title, int price, @DrawableRes int currencyDrawable) {
this.title.setText(title);
this.price.setText(price + "");
this.currencyView.setImageDrawable(context.getResources().getDrawable(currencyDrawable));
}
public void setLayoutEnabled(boolean enabled){
layout.setEnabled(enabled);
}
public void setLayoutVisible(int visibility){
layout.setVisibility(visibility);
}
}

View File

@ -0,0 +1,83 @@
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.ToolType;
import de.frajul.endlessroll.main.screens.ToolShopScreen;
import de.frajul.endlessroll.user.User;
/**
* Created by Julian on 03.06.2017.
*/
public class ToolInspector implements View.OnClickListener {
private ToolShopScreen toolShopScreen;
private User user;
private Context context;
private TextView title;
private ImageView imageView;
private PriceButton priceButton;
private ToolUpgradeView toolUpgradeView0;
private ToolUpgradeView toolUpgradeView1;
private ToolType toolType;
private boolean locked;
public ToolInspector(ToolShopScreen toolShopScreen, User user, Context context, Typeface typeface, View layout) {
this.toolShopScreen = toolShopScreen;
this.user = user;
this.context = context;
title = (TextView) layout.findViewById(R.id.tool_inspector_title);
title.setTypeface(typeface);
imageView = (ImageView) layout.findViewById(R.id.tool_inspector_imageview);
priceButton = new PriceButton(context, typeface,
layout.findViewById(R.id.tool_inspector_pricebutton), this);
toolUpgradeView0 = new ToolUpgradeView(this, context, typeface,
layout.findViewById(R.id.tool_inspector_toolupgrade0));
toolUpgradeView1 = new ToolUpgradeView(this, context, typeface,
layout.findViewById(R.id.tool_inspector_toolupgrade1));
}
public void update(ToolType toolType, boolean locked) {
this.toolType = toolType;
this.locked = locked;
this.title.setText(locked ? "???" : toolType.getName());
this.imageView.setImageDrawable(context.getResources().getDrawable(
locked ? R.drawable.tools_lockedbutton : toolType.getButtonDrawable()));
priceButton.init("Buy", toolType.getPrice(), R.drawable.currency_star);
priceButton.setLayoutVisible(toolType.isBought() || locked ? View.GONE : View.VISIBLE);
priceButton.setLayoutEnabled(toolType.getPrice() <= user.getStarCount());
toolUpgradeView0
.update(toolType.getUpgrades()[0], toolType.isBought(), user.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(), user.getEnergyCount());
}
}
public void onToolUpgraded(int price) {
toolShopScreen.onToolUpgraded(price);
update(toolType, locked);
}
@Override
public void onClick(View v) {
toolType.setBought(true);
update(toolType, locked);
toolShopScreen.onToolBought(toolType.getPrice());
}
}

View File

@ -0,0 +1,83 @@
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(
toolUpgrade.getType().getName() + " (Lv" + toolUpgrade.getCurrentLevel() + ")");
this.imageView.setImageDrawable(
context.getResources().getDrawable(toolUpgrade.getType().getDrawable()));
updateValueViews();
priceButton.init("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("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());
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding
android:bottom="15dp"
android:left="15dp"
android:right="15dp"
android:top="15dp" />
<stroke
android:width="1dp"
android:color="#d8000000" />
<solid
android:color="#ffffff"/>
</shape>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" tools:context=".main.GameActivity">
<item android:state_pressed="true" android:state_enabled="true">
<shape>
<corners android:radius="2dp" />
<stroke android:width="1dp" android:color="#e44b4b" />
<solid android:color="#ecb599" />
</shape>
</item>
<item android:state_pressed="false" android:state_enabled="true">
<shape>
<corners android:radius="2dp" />
<stroke android:width="1dp" android:color="#e44b4b" />
<solid android:color="#f76d4b" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:radius="2dp" />
<stroke android:width="1dp" android:color="#bf5757" />
<solid android:color="#c6a9a9" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/xml_selector_pricebutton"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/price_button_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Upgrade"
android:textSize="13sp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/price_button_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="1000"
android:textSize="15sp"/>
<ImageView
android:id="@+id/price_button_currency"
android:layout_width="15sp"
android:layout_height="15sp"
android:layout_gravity="center_vertical"
android:src="@drawable/currency_star"/>
</LinearLayout>
</LinearLayout>

View File

@ -21,7 +21,7 @@
android:id="@+id/startscreen_play"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_marginTop="40dp"
android:layout_marginTop="38dp"
android:background="@drawable/playershapes_ball"
android:text="Play"
android:textSize="25sp"

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#e6ffc936">
<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="Ramp"
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:orientation="horizontal">
<ImageView
android:id="@+id/tool_inspector_imageview"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginEnd="10dp"
android:src="@drawable/tools_rampbutton"/>
<include
android:id="@+id/tool_inspector_pricebutton"
layout="@layout/price_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/linearLayout3"
android:layout_centerInParent="true">
<LinearLayout
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>
</RelativeLayout>
</RelativeLayout>

View File

@ -20,11 +20,4 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
<Button
android:id="@+id/toolofferslot_pricebutton"
style="@style/PriceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-10dp"/>
</LinearLayout>

View File

@ -9,6 +9,6 @@
android:layout_height="70dp"
android:layout_gravity="center"
android:background="@drawable/xml_background_toolslot"
android:src="@drawable/rampbutton"/>
android:src="@drawable/tools_rampbutton"/>
</FrameLayout>

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/xml_background_toolupgrade"
android:orientation="vertical"
android:padding="2dp">
<TextView
android:id="@+id/tool_upgrade_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Time (Lv12)"
android:textSize="17sp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/tool_upgrade_imageview"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:src="@drawable/tools_rampbutton"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tool_upgrade_value_old"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="80%"
android:textSize="16sp"/>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="@drawable/arrow_green"/>
<TextView
android:id="@+id/tool_upgrade_value_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="90%"
android:textSize="16sp"/>
</LinearLayout>
<include
android:id="@+id/tool_upgrade_pricebutton"
layout="@layout/price_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -8,13 +8,13 @@
android:layout_width="70dp"
android:layout_height="60dp"
android:layout_centerInParent="true"
android:src="@drawable/rampbutton"/>
android:src="@drawable/tools_rampbutton"/>
<ImageView
android:id="@+id/toolProgressButtonAnimation"
android:layout_width="70dp"
android:layout_height="60dp"
android:src="@drawable/rampbutton"
android:src="@drawable/tools_rampbutton"
android:visibility="invisible"/>
<ProgressBar

View File

@ -10,61 +10,82 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolshop_topbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolshop_topbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/toolshop_toolinspector"
android:layout_toStartOf="@+id/toolshop_toolinspector">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:id="@+id/linearLayout4">
<include
android:id="@+id/toolshop_slot1"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot2"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot3"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot4"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:id="@+id/toolshop_tool_offer_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<include
android:id="@+id/toolshop_slot1"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot2"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot3"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<include
android:id="@+id/toolshop_slot4"
layout="@layout/tool_slot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp">
<LinearLayout
android:id="@+id/toolshop_tool_offer_layout"
android:layout_width="wrap_content"
android:layout_marginBottom="2dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
android:id="@+id/toolshop_toolinspector"
layout="@layout/tool_inspector"
android:layout_width="170dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -106,6 +106,17 @@
android:layout_centerVertical="true"
android:layout_alignEnd="@+id/topbar_starcount"/>
<TextView
android:id="@+id/topbar_energycount_decrease"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-200"
android:visibility="invisible"
android:textColor="#000000"
android:textSize="20sp"
android:layout_centerVertical="true"
android:layout_alignEnd="@+id/topbar_energycount"/>
<Button
android:id="@+id/topbar_resetButton"
style="@style/GameButton"

View File

@ -9,7 +9,7 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/unlockmessage_toolimage"
android:src="@drawable/rampbutton"
android:src="@drawable/tools_rampbutton"
android:layout_gravity="center_vertical"/>
<TextView

View File

@ -1,6 +1,9 @@
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:buttonStyle">@style/GameButton</item>
<item name="android:textColor">#000000</item>
</style>
<style name="GameButton">
<item name="android:background">@drawable/xml_selector_gamebutton</item>
@ -12,10 +15,6 @@
<item name="android:shadowRadius">2</item>
</style>
<style name="PriceButton" parent="GameButton">
<item name="android:drawableLeft">@drawable/star_icon</item>
</style>
<style name="TutorialTextView">
<item name="android:background">@drawable/xml_background_tutorialtextview</item>
<item name="android:textColor">#000000</item>