First implementation of Shape shop

This commit is contained in:
=
2017-10-22 18:48:00 +02:00
parent 33275f9046
commit 757c13c31c
52 changed files with 2237 additions and 1788 deletions

View File

@ -637,34 +637,34 @@
<obstacleData floating="true" moving="false" deadly="false" leftEdge="13.700025" rightEdge="14.400025" height="0.3" y="-0.39333323">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="12.750364" rightEdge="13.056364" height="0.293" y="0.7799998">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="12.637027" rightEdge="12.943027" height="0.293" y="0.8466664">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="11.745692" rightEdge="12.127692" height="0.318" y="0.50666654">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="11.585686" rightEdge="11.967686" height="0.318" y="0.58666646">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.248859" rightEdge="13.4778595" height="0.268" y="0.693333">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.128856" rightEdge="13.357856" height="0.268" y="0.75999963">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.559376" rightEdge="13.967375" height="0.242" y="0.34666654">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.506041" rightEdge="13.91404" height="0.242" y="0.45333314">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.174693" rightEdge="14.378694" height="0.28" y="0.22666667">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.101356" rightEdge="14.305356" height="0.28" y="0.23333333">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.083701" rightEdge="14.389701" height="0.28" y="0.6533332">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.083701" rightEdge="14.389701" height="0.28" y="0.65999985">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.643702" rightEdge="13.949701" height="0.344" y="0.7866666">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.650369" rightEdge="13.956368" height="0.344" y="0.8466665">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="12.344684" rightEdge="12.548684" height="0.382" y="0.7533331">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="12.198009" rightEdge="12.402009" height="0.382" y="0.84666634">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.568863" rightEdge="14.797863" height="0.204" y="0.37999982">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.522194" rightEdge="14.751194" height="0.204" y="0.39333314">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.922533" rightEdge="15.177532" height="0.42" y="0.14000005">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.922533" rightEdge="15.177532" height="0.42" y="0.106666714">
<moveComponent width="0.0" height="0.0" x="0.0" y="0.0" speed="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="true" leftEdge="20.66682" rightEdge="21.09982" height="0.293" y="-0.45350003">

View File

@ -34,7 +34,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
spawnShape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0

View File

@ -38,7 +38,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
spawnShape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0

View File

@ -44,7 +44,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: square
spawnShape: square
- Spawn Width -
lowMin: 200.0
lowMax: 200.0

View File

@ -46,7 +46,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
spawnShape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0

View File

@ -34,7 +34,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
spawnShape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0

View File

@ -38,7 +38,7 @@ active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
spawnShape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0

View File

@ -0,0 +1,57 @@
package de.frajul.endlessroll.entities.shapes;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack;
/**
* Created by Julian on 22.10.2017.
*/
public enum PlayerShape {
BALL(R.string.playershape_name_ball, R.drawable.playershapes_ball), CLOCK(R.string.playershape_name_clock,
R.drawable.playershapes_clock), HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
R.drawable.playershapes_hypno_spiral), PACMAN(R.string.playershape_name_pacman,
R.drawable.playershapes_pacman), SMILEY(R.string.playershape_name_smiley,
R.drawable.playershapes_smiley);
@StringRes
private int nameId;
@DrawableRes
private int drawableId;
private Texture texture;
PlayerShape(@StringRes int nameId, @DrawableRes int drawableId) {
this.nameId = nameId;
this.drawableId = drawableId;
}
public static void loadAllTextures(TexturePack texturePack) {
for (PlayerShape playerShape : values())
playerShape.loadTexture(texturePack);
}
private void loadTexture(TexturePack texturePack) {
if (drawableId == -1)
return;
texture = texturePack.loadTexture(drawableId);
}
@StringRes
public int getNameId() {
return nameId;
}
@DrawableRes
public int getDrawableId() {
return drawableId;
}
public Texture getTexture() {
return texture;
}
}

View File

@ -0,0 +1,13 @@
package de.frajul.endlessroll.entities.shapes;
import de.frajul.endlessroll.views.PlayerShapeButton;
/**
* Created by Julian on 22.10.2017.
*/
public interface PlayerShapeButtonOnClickListener {
public void onClick(PlayerShapeButton button);
}

View File

@ -0,0 +1,70 @@
package de.frajul.endlessroll.main.screens;
import android.widget.LinearLayout;
import android.widget.TableRow;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.shapes.PlayerShapeButtonOnClickListener;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.views.PlayerShapeButton;
import de.frajul.endlessroll.views.TopBar;
/**
* Created by Julian on 08.07.2016.
*/
public class PlayerShapeShopScreen extends Screen<LinearLayout> implements PlayerShapeButtonOnClickListener {
private PlayerShapeButton activeButton;
private TopBar topBar;
private TableRow topRow;
private TableRow bottomRow;
public PlayerShapeShopScreen(GameActivity gameActivity) {
super(ScreenType.SHAPE_SHOP, gameActivity, R.layout.shape_shop);
topBar = super.createTopBar(R.id.shape_shop_topbar);
topRow = (TableRow) layout.findViewById(R.id.shape_shop_topRow);
bottomRow = (TableRow) layout.findViewById(R.id.shape_shop_bottomRow);
}
private void createViews() {
topRow.removeAllViews();
bottomRow.removeAllViews();
int i = 0;
int totalShapes = PlayerShape.values().length;
for (PlayerShape playerShape : PlayerShape.values()) {
PlayerShapeButton button = new PlayerShapeButton(gameActivity, playerShape, this);
if (i < totalShapes / 2)
topRow.addView(button.getView());
else
bottomRow.addView(button.getView());
if (playerShape.equals(gameActivity.getUser().getCurrentPlayerShape())) {
this.activeButton = button;
button.startRotating();
}
i++;
}
}
@Override
public void prepareToBeShown() {
createViews();
topBar.update();
}
@Override
public void onBackKeyDown() {
flipToCaller();
}
@Override
public void onClick(PlayerShapeButton button) {
activeButton.stopRotating();
activeButton = button;
activeButton.startRotating();
gameActivity.getUser().setCurrentPlayerShape(button.getPlayerShape());
}
}

View File

@ -0,0 +1,63 @@
package de.frajul.endlessroll.views;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.shapes.PlayerShapeButtonOnClickListener;
import de.frajul.endlessroll.main.GameLog;
/**
* Created by Julian on 22.10.2017.
*/
public class PlayerShapeButton implements View.OnClickListener {
private PlayerShape playerShape;
private PlayerShapeButtonOnClickListener clickListener;
private View view;
private TextView textView;
private Button button;
private Animation rotation;
public PlayerShapeButton(Context context, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener) {
this.clickListener = clickListener;
this.playerShape = playerShape;
view = LayoutInflater.from(context).inflate(R.layout.shape_button, null);
textView = (TextView) view.findViewById(R.id.shape_button_textview);
textView.setText(playerShape.getNameId());
button = (Button) view.findViewById(R.id.shape_button_button);
button.setBackgroundDrawable(context.getResources().getDrawable(playerShape.getDrawableId()));
button.setOnClickListener(this);
rotation = AnimationUtils.loadAnimation(context, R.anim.shape_button_rotation);
}
public void startRotating() {
button.startAnimation(rotation);
}
public void stopRotating() {
button.clearAnimation();
}
@Override
public void onClick(View v) {
clickListener.onClick(this);
}
public View getView() {
return view;
}
public PlayerShape getPlayerShape() {
return playerShape;
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:repeatMode="restart"
android:interpolator="@android:anim/linear_interpolator">
<rotate
android:duration="2500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360" />
</set>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".main.GameActivity">
<item android:state_enabled="true">
<bitmap android:src="@drawable/guis_shape_shop_enabled"/>
</item>
<item android:state_enabled="false">
<bitmap android:src="@drawable/guis_shape_shop_disabled"/>
</item>
</selector>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".main.GameActivity">
<item android:state_enabled="true">
<bitmap android:src="@drawable/guis_shop_enabled"/>
<bitmap android:src="@drawable/guis_tool_shop_enabled"/>
</item>
<item android:state_enabled="false">
<bitmap android:src="@drawable/guis_shop_disabled"/>
<bitmap android:src="@drawable/guis_tool_shop_disabled"/>
</item>
</selector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/shape_button_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/button_placeholder"
android:textSize="25sp"/>
<Button
android:id="@+id/shape_button_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/playershapes_ball"/>
</LinearLayout>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backgrounds_menu_grass"
android:orientation="vertical">
<include
android:id="@+id/shape_shop_topbar"
layout="@layout/topbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginBottom="5dp"/>
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:id="@+id/shape_shop_topRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<!--Will be removed before content is added. Just there because android 7.0 doesn't like empty tableRows ;-) -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="@+id/shape_shop_bottomRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<!--Will be removed before content is added. Just there because android 7.0 doesn't like empty tableRows ;-) -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</HorizontalScrollView>
</LinearLayout>

View File

@ -75,9 +75,8 @@
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/topbar_toolshop"
android:layout_toStartOf="@+id/topbar_toolshop"
android:layout_marginRight="5dp"
android:layout_alignParentEnd="true"
android:background="@drawable/xml_selector_settingsbutton"/>
<Button
@ -85,10 +84,20 @@
style="@style/GameButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="@drawable/xml_selector_shopbutton"/>
android:layout_toLeftOf="@+id/topbar_settings"
android:layout_marginRight="10dp"
android:background="@drawable/xml_selector_toolshopbutton"/>
<Button
android:id="@+id/topbar_shapeshop"
style="@style/GameButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toLeftOf="@+id/topbar_toolshop"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@drawable/xml_selector_shapeshopbutton"/>
<TextView
android:id="@+id/topbar_starcount_decrease"

View File

@ -42,6 +42,12 @@
<string name="level_button_format_d">Level: %d</string>
<string name="price_button_buy">Buy</string>
<string name="price_button_upgrade">Upgrade</string>
<string name="playershape_name_ball">Ball</string>
<string name="playershape_name_clock">Clock</string>
<string name="playershape_name_hypno_spiral">Hypno</string>
<string name="playershape_name_pacman">Pacman</string>
<string name="playershape_name_smiley">Smiley</string>
<string name="tool_name_unknown">\?\?\?</string>
<string name="tool_name_ramp">Ramp</string>
<string name="tool_name_spring">Spring</string>