Finished toolshop updates (Tool upgrades and more)

This commit is contained in:
= 2017-10-28 16:09:54 +02:00
parent 5467c1dd97
commit 8cc9353c3b
8 changed files with 41 additions and 114 deletions

File diff suppressed because one or more lines are too long

View File

@ -876,7 +876,7 @@ int string start_screen_to_gl_test_screen 0x7f0d003b
int string start_screen_unlock_all_levels 0x7f0d003c
int string status_bar_notification_info_overflow 0x7f0d003d
int string tool_description_bomb 0x7f0d003e
int string tool_description_locked 0x7f0d003f
int string tool_description_locked_format_d 0x7f0d003f
int string tool_description_magnet 0x7f0d0040
int string tool_description_power_mushroom 0x7f0d0041
int string tool_description_ramp 0x7f0d0042

View File

@ -13,13 +13,14 @@ import de.frajul.endlessroll.main.game.Timer;
public class PowerMushroom extends Tool {
public PowerMushroom(Vector position) {
super(ToolType.POWER_MUSHROOM, position, true, true);
super(ToolType.POWER_MUSHROOM, position, .35f, .3f, true, true);
animation.disable();
}
@Override
public void onPlayerCollision(Player player, Timer timer) {
player.startSuperPower(timer.getCurrentTime());
player.startSuperPower(timer.getCurrentTime(),
(long) ToolType.POWER_MUSHROOM.getCurrentUpgradeValue(ToolUpgradeType.DURATION));
super.destroy(DestroyEffect.ENERGY_COLLECT);
}

View File

@ -1,24 +0,0 @@
package de.frajul.endlessroll.entities.tools;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.Entity;
/**
* Created by Julian on 22.09.2017.
*/
public class ToolPreview extends Entity {
public ToolPreview() {
super(null, new Vector(), 0, 0);
super.setAlpha(0.5f);
super.setVisible(false);
}
public void showTool(ToolType toolType) {
super.setVisible(true);
super.setTexture(toolType.getToolTexture());
super.setWidth(toolType.getWidth());
super.setHeight(toolType.getHeight());
}
}

View File

@ -7,45 +7,21 @@ package de.frajul.endlessroll.entities.tools;
public class ToolUpgrade {
private ToolUpgradeType type;
private float first, step;
private int price;
private float first, last;
private int maxLevel;
private int currentLevel = 1;
public ToolUpgrade(ToolUpgradeType type, float first, float last, float step, int price) {
public ToolUpgrade(ToolUpgradeType type, float first, float last) {
this.type = type;
this.first = first;
this.step = step;
this.price = price;
maxLevel = (int) Math.abs((first - last) / step) + 1;
this.last = last;
}
public ToolUpgradeType getType() {
return type;
}
public float getValueAtLevel(int level) {
return first + step * (level - 1);
public float getValueAtLevel(int level, int maxLevel) {
float step = (last - first) / ((float) maxLevel - 1);
return first + level * step;
}
public float getValueAtCurrentLevel() {
return getValueAtLevel(currentLevel);
}
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

@ -1,42 +1,11 @@
package de.frajul.endlessroll.entities.tools;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import de.frajul.endlessroll.R;
/**
* Created by Julian on 07.06.2017.
* Created by Julian on 28.10.2017.
*/
public enum ToolUpgradeType {
NONE(R.string.tool_upgrade_none, "", R.drawable.tools_ramp_button), TIME(R.string.tool_upgrade_time, "s", R.drawable.guis_clock), RADIUS(
R.string.tool_upgrade_radius, "%", R.drawable.guis_radius), FORCE(R.string.tool_upgrade_force, "%", R.drawable.guis_magnet_field);
COOLDOWN, DURATION, FORCE, RANGE;
@StringRes
private int name;
private String unit;
@DrawableRes
private int drawable;
ToolUpgradeType(@StringRes int name, String unit, @DrawableRes int drawable) {
this.name = name;
this.unit = unit;
this.drawable = drawable;
}
@StringRes
public int getName() {
return name;
}
public String getUnit() {
return unit;
}
@DrawableRes
public int getDrawable() {
return drawable;
}
}

View File

@ -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());
}
}
}

View File

@ -50,12 +50,12 @@
<string name="playershape_name_wheel">Wheel</string>
<string name="playershape_name_sun">Sun</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_locked_format_d">You will unlock this mysterious tool at level %d</string>
<string name="tool_description_ramp">Roll up the ramp to gain height</string>
<string name="tool_description_spring">Shoots you in the air</string>
<string name="tool_description_magnet">Difficult to handle, but if you master it you can do anything</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_description_power_mushroom">This will give you super-powers for a few seconds</string>
<string name="tool_name_locked">\?\?\?</string>
<string name="tool_name_ramp">Ramp</string>
<string name="tool_name_spring">Spring</string>