LevelButton + WorldButton energy now shown

created drawable for empty_energy
redraw star drawable
tick for completed levels on worldButton
This commit is contained in:
=
2017-02-21 16:00:31 +01:00
parent f252bfd4bd
commit 5be4fc05cb
26 changed files with 484 additions and 382 deletions

View File

@ -64,6 +64,17 @@ public class LevelPack {
return levels.size() * 3;
}
public int getCollectedEnergyCount(){
int count = 0;
for(Level level : levels)
count += level.isEnergyCollected() ? 1 : 0;
return count;
}
public int getAvailableEnergy(){
return levels.size();
}
public void tryToUnlockFirstLevel() {
Level firstLevel = getLevel(0);
if (firstLevel != null)

View File

@ -85,11 +85,8 @@ 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);

View File

@ -226,7 +226,7 @@ public class Game extends Rendering<GameScene> {
user.gainLvFinishedEp();
level.setFinished(true);
for (int i = 1; i <= 3; i++) {
for (int i = 0; i <= 2; i++) {
if (collectedStars.contains(i)) {
level.setStarCollected(i, true);
user.onStarCollected();

View File

@ -54,7 +54,7 @@ public class LevelsScreen extends Screen<LinearLayout> implements View.OnClickLi
private void createButton(Context context, Level level, int levelCount) {
int levelNumber = level.getId();
LevelButton button = new LevelButton(context, typeface, this, levelNumber, level.isLocked());
button.showCollectedStars(level.getCollectedStars());
button.showCollectedCurrency(level.getCollectedStars(), level.isEnergyCollected());
levelButtons.put(levelNumber, button);
int halfLevelCount = levelCount / 2;
if (levelCount % 2 == 1)

View File

@ -18,6 +18,7 @@ public class LevelButton extends RelativeLayout {
private ImageView star1;
private ImageView star2;
private ImageView star3;
private ImageView energy;
private ImageView lockImage;
public LevelButton(Context context, Typeface typeface, OnClickListener clickListener, int level, boolean locked) {
@ -31,6 +32,7 @@ public class LevelButton extends RelativeLayout {
star1 = (ImageView) super.findViewById(R.id.levelbutton_star1);
star2 = (ImageView) super.findViewById(R.id.levelbutton_star2);
star3 = (ImageView) super.findViewById(R.id.levelbutton_star3);
energy = (ImageView) super.findViewById(R.id.levelbutton_energy);
lockImage = (ImageView) super.findViewById(R.id.levelbutton_lock);
setLockVisible(locked);
@ -42,13 +44,15 @@ public class LevelButton extends RelativeLayout {
lockImage.setVisibility(visibility);
}
public void showCollectedStars(boolean[] stars) {
public void showCollectedCurrency(boolean[] stars, boolean energy) {
if (stars[0])
this.star1.setImageResource(R.drawable.currency_star);
if (stars[1])
this.star2.setImageResource(R.drawable.currency_star);
if (stars[2])
this.star3.setImageResource(R.drawable.currency_star);
if(energy)
this.energy.setImageResource(R.drawable.currency_energy);
}
public boolean isLocked() {

View File

@ -25,6 +25,7 @@ public class WorldButton extends RelativeLayout {
private ImageView lockImage;
private TextView levelCount;
private TextView starCount;
private TextView energyCount;
public WorldButton(Context context, Typeface typeface, View.OnClickListener clickListener, LevelPack levelPack) {
super(context);
@ -43,6 +44,8 @@ public class WorldButton extends RelativeLayout {
levelCount.setTypeface(typeface);
starCount = (TextView) super.findViewById(R.id.worldbutton_starcount);
starCount.setTypeface(typeface);
energyCount = (TextView) super.findViewById(R.id.worldbutton_energycount);
energyCount.setTypeface(typeface);
updateInformation();
}
@ -52,6 +55,7 @@ public class WorldButton extends RelativeLayout {
previewImage.setImageDrawable(getContext().getResources().getDrawable(theme.getPreviewId()));
levelCount.setText(levelPack.getFinishedLevelCount() + "/" + levelPack.getLevels().size());
starCount.setText(levelPack.getCollectedStarCount() + "/" + levelPack.getAvailableStars());
energyCount.setText(levelPack.getCollectedEnergyCount() + "/" + levelPack.getAvailableEnergy());
setLockVisible(levelPack.isLocked());
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -6,8 +6,8 @@
<ImageView
android:id="@+id/game_pausebutton"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"

View File

@ -24,24 +24,31 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/star_empty"
android:src="@drawable/currency_star_empty"
android:id="@+id/levelbutton_star1"
android:layout_weight="1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/star_empty"
android:src="@drawable/currency_star_empty"
android:id="@+id/levelbutton_star2"
android:layout_weight="1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/star_empty"
android:src="@drawable/currency_star_empty"
android:id="@+id/levelbutton_star3"
android:layout_weight="1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/currency_energy_empty"
android:id="@+id/levelbutton_energy"
android:layout_weight="1" />
</LinearLayout>
<ImageView

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="220dp"
android:layout_width="260dp"
android:layout_height="match_parent"
android:background="@drawable/xml_worldbutton_background">
@ -17,76 +17,103 @@
<ImageView
android:id="@+id/worldbutton_preview"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@+id/worldbutton_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:src="@drawable/previews_grass" />
<ImageView
android:id="@+id/worldbutton_lock"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignBottom="@+id/worldbutton_preview"
android:layout_alignLeft="@+id/worldbutton_preview"
android:layout_alignStart="@+id/worldbutton_preview"
android:src="@drawable/lock_locked"
android:visibility="visible" />
android:src="@drawable/previews_grass"
android:layout_width="150dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="25dp"
android:layout_marginLeft="25dp">
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true">
<TextView
android:id="@+id/worldbutton_levelcount"
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9/35"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/imageView3"
android:layout_toEndOf="@+id/imageView3" />
android:layout_centerHorizontal="true">
<TextView
android:id="@+id/worldbutton_starcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="7/105"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/worldbutton_tickView"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_alignParentStart="true"
android:src="@drawable/tick" />
<ImageView
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_centerVertical="true"
android:layout_marginRight="4dp"
android:layout_toLeftOf="@+id/worldbutton_starcount"
android:layout_toStartOf="@+id/worldbutton_starcount"
android:src="@drawable/currency_star"
android:id="@+id/imageView2" />
<TextView
android:id="@+id/worldbutton_levelcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9/35"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/worldbutton_tickView"
android:layout_toEndOf="@+id/worldbutton_tickView"
android:layout_marginRight="10dp"/>
<ImageView
android:layout_width="30sp"
android:layout_height="30sp"
android:src="@drawable/lock_unlocked"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/imageView3" />
<ImageView
android:id="@+id/levelbutton_starView"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/worldbutton_levelcount"
android:layout_toEndOf="@+id/worldbutton_levelcount"
android:src="@drawable/currency_star" />
<TextView
android:id="@+id/worldbutton_starcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/levelbutton_starView"
android:layout_toRightOf="@+id/levelbutton_starView"
android:text="7/105"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginRight="10dp"/>
<TextView
android:id="@+id/worldbutton_energycount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/imageView4"
android:layout_toRightOf="@+id/imageView4"
android:text="9/35"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="30sp"
android:layout_height="30sp"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/worldbutton_starcount"
android:layout_toRightOf="@+id/worldbutton_starcount"
android:src="@drawable/currency_energy" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="@+id/worldbutton_lock"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/lock_locked"
android:visibility="visible"
android:layout_alignBottom="@+id/worldbutton_preview"
android:layout_alignLeft="@+id/worldbutton_preview"
android:layout_alignStart="@+id/worldbutton_preview" />
</RelativeLayout>