Energy Drawable created + animation for Entity -> AnimatedEntity
A Scene will automatically update all AnimatedEntities LevelUpBounties no longer grant EP
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
package com.example.julian.endlessroll.entities;
|
||||
|
||||
import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.entities.textures.Texture;
|
||||
import com.example.julian.endlessroll.main.game.Timer;
|
||||
|
||||
/**
|
||||
* Created by Julian on 20.02.2017.
|
||||
*/
|
||||
|
||||
public class AnimatedEntity extends Entity {
|
||||
|
||||
protected Animation animation;
|
||||
|
||||
public AnimatedEntity(Texture texture, Vector position, float width, float height) {
|
||||
super(texture, position, width, height);
|
||||
animation = new Animation();
|
||||
}
|
||||
|
||||
public void update(Timer timer){
|
||||
animation.update(timer);
|
||||
super.setTextureAtlasIndex(animation.getCurrentTexIndex());
|
||||
}
|
||||
|
||||
}
|
@ -4,11 +4,13 @@ import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.entities.textures.Texture;
|
||||
import com.example.julian.endlessroll.levels.PositionData;
|
||||
|
||||
public class Energy extends Entity {
|
||||
public class Energy extends AnimatedEntity {
|
||||
|
||||
private final static float SIZE = 0.3f;
|
||||
|
||||
public Energy(Texture texture, PositionData data) {
|
||||
super(texture, new Vector(data.getX(), data.getY()), SIZE, SIZE);
|
||||
animation.setLooping(true);
|
||||
animation.setRequiredDelta(130);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class TexturePack {
|
||||
public final Texture playerArrow;
|
||||
public final Texture player;
|
||||
public final Texture star;
|
||||
public final Texture energy;
|
||||
|
||||
public TexturePack(Context context) {
|
||||
loader = new TextureLoader(context);
|
||||
@ -25,7 +26,8 @@ public class TexturePack {
|
||||
player = loadTexture(R.drawable.playershapes_ball);
|
||||
playerArrow = loadTexture(R.drawable.guis_playerarrow);
|
||||
|
||||
star = loadTexture(R.drawable.star);
|
||||
star = loadTexture(R.drawable.currency_star);
|
||||
energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2);
|
||||
|
||||
ToolType.loadAllToolTextures(this);
|
||||
Theme.loadAllSpecificTextures(this);
|
||||
|
@ -26,11 +26,6 @@ public class Magnet extends Tool {
|
||||
particleSource.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Timer timer) {
|
||||
super.update(timer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(DestroyEffect destroyEffect) {
|
||||
super.destroy(destroyEffect);
|
||||
|
@ -11,7 +11,6 @@ import com.example.julian.endlessroll.main.game.Timer;
|
||||
*/
|
||||
public class Ramp extends Tool {
|
||||
|
||||
|
||||
public Ramp(Vector position) {
|
||||
super(ToolType.RAMP, position, .4f, .35f, true, true);
|
||||
animation.setLooping(true);
|
||||
@ -32,11 +31,6 @@ public class Ramp extends Tool {
|
||||
return getBottomEdge() + super.getHeight() * ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Timer timer) {
|
||||
super.update(timer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCollision(Player player) {
|
||||
float necessaryY = calcNecessaryPlayerY(player);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.example.julian.endlessroll.entities.tools;
|
||||
|
||||
import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.entities.AnimatedEntity;
|
||||
import com.example.julian.endlessroll.entities.Animation;
|
||||
import com.example.julian.endlessroll.entities.Entity;
|
||||
import com.example.julian.endlessroll.entities.Player;
|
||||
@ -10,27 +11,20 @@ import com.example.julian.endlessroll.main.game.Timer;
|
||||
/**
|
||||
* Created by Julian on 04.01.2016.
|
||||
*/
|
||||
public abstract class Tool extends Entity {
|
||||
public abstract class Tool extends AnimatedEntity {
|
||||
|
||||
private boolean placedByRightEdge;
|
||||
private boolean updateBounds;
|
||||
private Geometry collisionBounds;
|
||||
protected Animation animation;
|
||||
private boolean floating = false;
|
||||
|
||||
public Tool(ToolType type, Vector position, float width, float height, boolean updateBounds, boolean placedByRightEdge) {
|
||||
super(type.getToolTexture(), position, width, height);
|
||||
this.updateBounds = updateBounds;
|
||||
this.placedByRightEdge = placedByRightEdge;
|
||||
animation = new Animation();
|
||||
collisionBounds = createCollisionBounds();
|
||||
}
|
||||
|
||||
public void update(Timer timer) {
|
||||
animation.update(timer);
|
||||
super.setTextureAtlasIndex(animation.getCurrentTexIndex());
|
||||
}
|
||||
|
||||
public abstract void onPlayerCollision(Player player);
|
||||
|
||||
protected abstract Geometry createCollisionBounds();
|
||||
|
@ -19,7 +19,9 @@ public class LevelUpBounties extends HashMap<Integer, LevelBounty> {
|
||||
super.put(2, new LevelBounty(5, 0, ToolType.SPRING, false));
|
||||
super.put(3, new LevelBounty(6, 0, ToolType.MAGNET, true));
|
||||
super.put(4, new LevelBounty(7, 0, ToolType.BOMB, true));
|
||||
super.put(5, new LevelBounty(8, 0, ToolType.NONE, false));
|
||||
super.put(5, new LevelBounty(8, 2, ToolType.NONE, false));
|
||||
super.put(6, new LevelBounty(8, 1, ToolType.NONE, false));
|
||||
super.put(7, new LevelBounty(8, 1, ToolType.NONE, false));
|
||||
loadAllForLevel(level);
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,13 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
|
||||
relativeLayout.addView(flipper);
|
||||
relativeLayout.addView(levelupMessage.getLayout());
|
||||
//TODO: add Tutorial
|
||||
//TODO: add Energy count on TopBar
|
||||
//TODO: show Energy on levelButton if collected
|
||||
//TODO: Scroll up
|
||||
//TODO: World button tick for completed levels
|
||||
//TODO: World/level button: energy
|
||||
//TODO: Goal animation!
|
||||
//TODO: Goal screen animation!
|
||||
setContentView(relativeLayout);
|
||||
} catch (Exception e) {
|
||||
onException(e);
|
||||
|
@ -229,12 +229,12 @@ public class Game extends Rendering<GameScene> {
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
if (collectedStars.contains(i)) {
|
||||
level.setStarCollected(i, true);
|
||||
user.increaseStarCount();
|
||||
user.onStarCollected();
|
||||
}
|
||||
}
|
||||
|
||||
level.setEnergyCollected(true);
|
||||
user.increaseEnergyCount();
|
||||
user.onEnergyCollected();
|
||||
|
||||
viewManager.showMessage(levelPack.isLastLevel(level), MessageType.WIN);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class GameScene extends Scene {
|
||||
private void tryToAddEnergy(Level level){
|
||||
PositionData data = level.getEnergyData();
|
||||
if(data != null && !level.isEnergyCollected()) {
|
||||
energy = new Energy(textures.player, data);
|
||||
energy = new Energy(textures.energy, data);
|
||||
super.add(energy);
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,6 @@ public class GameScene extends Scene {
|
||||
player.setSpeedByProgress(player.getProgress() / goalX);
|
||||
synchronized (tools) {
|
||||
for (Tool tool : tools) {
|
||||
tool.update(timer);
|
||||
if (tool instanceof Bomb) {
|
||||
Bomb bomb = (Bomb) tool;
|
||||
if (bomb.isExploding())
|
||||
|
@ -37,7 +37,6 @@ public class Physics {
|
||||
|
||||
public void applyGravity(GameScene scene, Timer timer) {
|
||||
float gravity = GRAVITY_FORCE * timer.getFrameTime();
|
||||
GameLog.i("FrameTime: " + timer.getFrameTime());
|
||||
|
||||
scene.getPlayer().getMovement().y -= gravity;
|
||||
synchronized (scene.getTools()) {
|
||||
@ -47,7 +46,6 @@ public class Physics {
|
||||
if (tool instanceof Bomb) {
|
||||
for (Obstacle obstacle : scene.getObstacles()) {
|
||||
if (detector.quadQuadCollision(obstacle, tool)) {
|
||||
GameLog.i("collision");
|
||||
tool.setFloating(true);
|
||||
tool.getMovement().y = 0;
|
||||
break;
|
||||
|
@ -2,6 +2,7 @@ package com.example.julian.endlessroll.main.game;
|
||||
|
||||
import com.example.julian.endlessroll.data.SynchronizedArrayList;
|
||||
import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.entities.AnimatedEntity;
|
||||
import com.example.julian.endlessroll.entities.Background;
|
||||
import com.example.julian.endlessroll.entities.Entity;
|
||||
import com.example.julian.endlessroll.entities.Obstacle;
|
||||
@ -50,6 +51,8 @@ public abstract class Scene extends SynchronizedArrayList<Entity> {
|
||||
Iterator<Entity> iterator = super.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = iterator.next();
|
||||
if(entity instanceof AnimatedEntity)
|
||||
((AnimatedEntity) entity).update(timer);
|
||||
Vector movement = entity.getMovement();
|
||||
Vector finalMovement = new Vector(movement).mul(timer.getFrameTime());
|
||||
entity.move(finalMovement);
|
||||
|
@ -3,6 +3,7 @@ package com.example.julian.endlessroll.main.game;
|
||||
import com.example.julian.endlessroll.entities.tools.ToolSlotSettings;
|
||||
import com.example.julian.endlessroll.levels.levelup.LevelBounty;
|
||||
import com.example.julian.endlessroll.levels.levelup.LevelUpBounties;
|
||||
import com.example.julian.endlessroll.main.GameLog;
|
||||
|
||||
/**
|
||||
* Created by Julian on 10.07.2016.
|
||||
@ -46,21 +47,23 @@ public class User {
|
||||
toolSlotSettings.reset();
|
||||
}
|
||||
|
||||
public void increaseStarCount() {
|
||||
increaseStarCount(1);
|
||||
public void onStarCollected() {
|
||||
increaseStarCount(1, true);
|
||||
}
|
||||
|
||||
public void increaseStarCount(int starCount) {
|
||||
public void increaseStarCount(int starCount, boolean gainEp) {
|
||||
this.starCount += starCount;
|
||||
if(gainEp)
|
||||
gainEp(STAR_EP * starCount);
|
||||
}
|
||||
|
||||
public void increaseEnergyCount() {
|
||||
increaseEnergyCount(1);
|
||||
public void onEnergyCollected() {
|
||||
increaseEnergyCount(1, true);
|
||||
}
|
||||
|
||||
public void increaseEnergyCount(int energyCount) {
|
||||
public void increaseEnergyCount(int energyCount, boolean gainEp) {
|
||||
this.energyCount += energyCount;
|
||||
if(gainEp)
|
||||
gainEp(ENERGY_EP * energyCount);
|
||||
}
|
||||
|
||||
@ -83,8 +86,8 @@ public class User {
|
||||
toolSlotSettings.unlockSlotsIfLevelReached(levelUpBounties);
|
||||
LevelBounty bounty = levelUpBounties.get(level);
|
||||
if (bounty != null) {
|
||||
increaseStarCount(bounty.getStarCount());
|
||||
increaseEnergyCount(bounty.getEnergyCount());
|
||||
increaseStarCount(bounty.getStarCount(), false);
|
||||
increaseEnergyCount(bounty.getEnergyCount(), false);
|
||||
}
|
||||
lvUpListener.onLvUp(level);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class ToolShopScreen extends Screen<RelativeLayout> implements View.OnCli
|
||||
} else if (v.equals(priceButton)) {
|
||||
int costs = selectedToolOfferSlot.getToolType().getCosts();
|
||||
topBar.showStarcountDecrease(-costs);
|
||||
user.increaseStarCount(-costs);
|
||||
user.increaseStarCount(-costs, false);
|
||||
selectedToolOfferSlot.buy();
|
||||
priceButton.setVisibility(View.INVISIBLE);
|
||||
topBar.update();
|
||||
|
@ -44,11 +44,11 @@ public class LevelButton extends RelativeLayout {
|
||||
|
||||
public void showCollectedStars(boolean[] stars) {
|
||||
if (stars[0])
|
||||
this.star1.setImageResource(R.drawable.star);
|
||||
this.star1.setImageResource(R.drawable.currency_star);
|
||||
if (stars[1])
|
||||
this.star2.setImageResource(R.drawable.star);
|
||||
this.star2.setImageResource(R.drawable.currency_star);
|
||||
if (stars[2])
|
||||
this.star3.setImageResource(R.drawable.star);
|
||||
this.star3.setImageResource(R.drawable.currency_star);
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.example.julian.endlessroll.views;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -11,6 +12,7 @@ import android.widget.TextView;
|
||||
import com.example.julian.endlessroll.R;
|
||||
import com.example.julian.endlessroll.levels.levelup.LevelBounty;
|
||||
import com.example.julian.endlessroll.main.GameActivity;
|
||||
import com.example.julian.endlessroll.main.GameLog;
|
||||
import com.example.julian.endlessroll.main.game.User;
|
||||
import com.example.julian.endlessroll.main.screens.Screen;
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class TopBar extends TopBarData implements View.OnClickListener {
|
||||
private TextView levelDisplay;
|
||||
private ProgressBar levelProgress;
|
||||
private TextView starCount;
|
||||
private TextView energyCount;
|
||||
private ToggleButton soundToggle;
|
||||
private Button toolshopButton;
|
||||
private Button resetButton;
|
||||
@ -41,6 +42,8 @@ public class TopBar extends TopBarData implements View.OnClickListener {
|
||||
levelProgress = (ProgressBar) layout.findViewById(R.id.topbar_levelprogress);
|
||||
starCount = (TextView) layout.findViewById(R.id.topbar_starcount);
|
||||
starCount.setTypeface(typeface);
|
||||
energyCount = (TextView) layout.findViewById(R.id.topbar_energycount);
|
||||
energyCount.setTypeface(typeface);
|
||||
soundToggle = (ToggleButton) layout.findViewById(R.id.topbar_soundtoggle);
|
||||
soundToggle.setTypeface(typeface);
|
||||
soundToggle.setOnClickListener(this);
|
||||
@ -52,6 +55,8 @@ public class TopBar extends TopBarData implements View.OnClickListener {
|
||||
resetButton = (Button) layout.findViewById(R.id.topbar_resetButton);
|
||||
resetButton.setTypeface(typeface);
|
||||
resetButton.setOnClickListener(this);
|
||||
if (parent == Screen.ScreenType.GAME)
|
||||
resetButton.setEnabled(false);
|
||||
starCountDecrease = (TextView) layout.findViewById(R.id.topbar_starcount_decrease);
|
||||
starCountDecrease.setTypeface(typeface);
|
||||
}
|
||||
@ -64,6 +69,7 @@ public class TopBar extends TopBarData implements View.OnClickListener {
|
||||
levelDisplay.setText("Level: " + user.getLevel());
|
||||
levelProgress.setProgress(user.getEp());
|
||||
starCount.setText(user.getStarCount() + "");
|
||||
energyCount.setText(user.getEnergyCount() + "");
|
||||
soundToggle.setChecked(soundManager.isSoundOn());
|
||||
}
|
||||
|
||||
@ -91,10 +97,6 @@ public class TopBar extends TopBarData implements View.OnClickListener {
|
||||
for (ToolType type : ToolType.values())
|
||||
type.setBought(false);
|
||||
dataStorageHandler.writeBoughtTools();
|
||||
user.gainLvFinishedEp();
|
||||
user.gainLvFinishedEp();
|
||||
user.gainLvFinishedEp();
|
||||
user.gainLvFinishedEp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/currency_energy.png
Normal file
BIN
app/src/main/res/drawable/currency_energy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/drawable/currency_energy_atlas.png
Normal file
BIN
app/src/main/res/drawable/currency_energy_atlas.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/topbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -40,14 +41,35 @@
|
||||
android:layout_height="40dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/topbar_levellayout"
|
||||
android:background="@drawable/star" />
|
||||
android:background="@drawable/currency_star" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/currency_energy"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@+id/topbar_starcount"
|
||||
android:layout_toEndOf="@+id/topbar_starcount"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:id="@+id/topbar_energyview" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/topbar_starcount"
|
||||
android:id="@+id/topbar_starcount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/topbar_starview"
|
||||
android:text="100"
|
||||
android:textColor="#000000"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/topbar_energycount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/topbar_starview"
|
||||
android:layout_toEndOf="@+id/topbar_energyview"
|
||||
android:text="100"
|
||||
android:textColor="#000000"
|
||||
android:textSize="25sp" />
|
||||
@ -74,15 +96,6 @@
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="Tool-Shop" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/topbar_resetButton"
|
||||
style="@style/customButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="Reset" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/topbar_starcount_decrease"
|
||||
android:layout_width="wrap_content"
|
||||
@ -94,5 +107,18 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignEnd="@+id/topbar_starcount" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/topbar_resetButton"
|
||||
style="@style/customButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Reset"
|
||||
android:layout_marginLeft="64dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_alignBaseline="@+id/topbar_soundtoggle"
|
||||
android:layout_alignBottom="@+id/topbar_soundtoggle"
|
||||
android:layout_toRightOf="@+id/topbar_energycount"
|
||||
android:layout_toEndOf="@+id/topbar_energycount" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
@ -76,7 +76,7 @@
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_toLeftOf="@+id/worldbutton_starcount"
|
||||
android:layout_toStartOf="@+id/worldbutton_starcount"
|
||||
android:src="@drawable/star"
|
||||
android:src="@drawable/currency_star"
|
||||
android:id="@+id/imageView2" />
|
||||
|
||||
<ImageView
|
||||
|
Reference in New Issue
Block a user