Changed GoalScreen to GoalMessage

Reduced firework
Changed taskCompletedMessageLook
This commit is contained in:
=
2017-11-22 11:38:54 +01:00
parent 8d4caeaf69
commit 9a2353b01c
18 changed files with 730 additions and 594 deletions

View File

@ -3,9 +3,6 @@ package de.frajul.endlessroll.entities.particles;
import java.util.Random;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.particles.Particle;
import de.frajul.endlessroll.entities.particles.ParticleEffect;
import de.frajul.endlessroll.entities.particles.ParticleSource;
import de.frajul.endlessroll.main.game.Camera;
/**
@ -18,36 +15,29 @@ public class Firework {
private Camera camera;
private Random random;
public Firework(ParticleEffect effect, Camera camera){
public Firework(ParticleEffect effect, Camera camera) {
this.effect = effect;
this.camera = camera;
this.random = new Random();
}
public void start(){
public void start() {
randomExplosion(0);
randomExplosion(500);
randomExplosion(1000);
randomExplosion(2000);
randomExplosion(3500);
randomExplosion(3590);
randomExplosion(4800);
randomExplosion(5600);
randomExplosion(6900);
randomExplosion(7000);
randomExplosion(700);
}
private void randomExplosion(float delay){
private void randomExplosion(float delay) {
ParticleSource explosion = new ParticleSource(randomPosition(), effect);
explosion.setDelayMS(delay);
explosion.start();
}
private Vector randomPosition(){
private Vector randomPosition() {
float x = camera.getX() + (random.nextFloat() - 0.5f) * 2.5f;
float y = camera.getY() + (random.nextFloat() * 0.5f) - 1f;
return new Vector(x, y);
}
}

View File

@ -1,60 +0,0 @@
package de.frajul.endlessroll.main.screens;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.HashMap;
import java.util.Map;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.levels.Level;
import de.frajul.endlessroll.levels.LevelPack;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.views.LevelButton;
import de.frajul.endlessroll.views.LevelButtonOnClickListener;
import de.frajul.endlessroll.views.TopBar;
/**
* Created by Julian on 23.04.2016.
*/
public class GoalScreen extends Screen<LinearLayout> implements LevelButtonOnClickListener {
private LevelPack levelPack;
private TopBar topBar;
private TextView title;
private LevelButton restart;
private LevelButton nextLevel;
public GoalScreen(GameActivity gameActivity) {
super(ScreenType.GOAL, gameActivity, R.layout.goal_screen);
topBar = super.createTopBar(R.id.goal_screen_topbar);
title = (TextView) layout.findViewById(R.id.goal_screen_title);
title.setTypeface(gameActivity.getTypeface());
restart = new LevelButton(gameActivity, this, layout.findViewById(R.id.goal_screen_restart));
nextLevel = new LevelButton(gameActivity, this, layout.findViewById(R.id.goal_screen_next_level));
}
public void onLevelFinished(LevelPack levelPack, Level level){
this.levelPack = levelPack;
restart.init(level);
nextLevel.init(levelPack.getNextLevel(level));
}
@Override
public void prepareToBeShown() {
topBar.update();
}
@Override
public void onBackKeyDown() {
flipTo(ScreenType.LEVELS);
}
@Override
public void onClick(LevelButton levelButton) {
gameActivity.startGame(levelPack, levelButton.getLevel());
}
}

View File

@ -0,0 +1,84 @@
package de.frajul.endlessroll.views;
import android.graphics.Typeface;
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.levels.Level;
import de.frajul.endlessroll.levels.LevelPack;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.main.screens.Screen;
/**
* Created by Julian on 23.04.2016.
*/
public class GoalMessage implements GoalMessageLevelButtonOnClickListener, View.OnClickListener {
private Game game;
private GameActivity gameActivity;
private LevelPack levelPack;
private Animation fadeIn;
private View layout;
private TopBar topBar;
private GoalMessageLevelButton restart;
private GoalMessageLevelButton nextLevel;
private Button toMenu;
public GoalMessage(Game game, GameActivity gameActivity, View layout) {
this.game = game;
this.gameActivity = gameActivity;
this.layout = layout;
Typeface typeface = gameActivity.getTypeface();
fadeIn = AnimationUtils.loadAnimation(gameActivity, R.anim.fade_in);
topBar = new TopBar(gameActivity, Screen.ScreenType.GAME,
layout.findViewById(R.id.goal_message_topbar));
TextView title = (TextView) layout.findViewById(R.id.goal_message_title);
title.setTypeface(typeface);
restart = new GoalMessageLevelButton(gameActivity, this,
layout.findViewById(R.id.goal_message_restart));
nextLevel = new GoalMessageLevelButton(gameActivity, this,
layout.findViewById(R.id.goal_message_next_level));
toMenu = (Button) layout.findViewById(R.id.goal_message_to_menu);
toMenu.setTypeface(typeface);
toMenu.setOnClickListener(this);
}
public void fadeIn(LevelPack levelPack, Level level) {
this.levelPack = levelPack;
topBar.update();
restart.init(R.string.goal_message_restart_format_d, level);
boolean nextLevelVisible = !levelPack.isLastLevel(level);
nextLevel.setVisible(nextLevelVisible);
if (nextLevelVisible)
nextLevel
.init(R.string.goal_message_next_level_format_d, levelPack.getNextLevel(level));
layout.startAnimation(fadeIn);
}
private void hide() {
layout.clearAnimation();
layout.setVisibility(View.GONE);
}
@Override
public void onClick(View v) {
if (v.equals(toMenu)) {
hide();
game.toLevelsScreen();
}
}
@Override
public void onClick(GoalMessageLevelButton goalMessageLevelButton) {
hide();
gameActivity.startGame(levelPack, goalMessageLevelButton.getLevel());
}
}

View File

@ -0,0 +1,80 @@
package de.frajul.endlessroll.views;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.levels.Level;
import de.frajul.endlessroll.main.GameActivity;
/**
* Created by Julian on 23.04.2016.
*/
public class GoalMessageLevelButton implements View.OnClickListener {
private GameActivity gameActivity;
private GoalMessageLevelButtonOnClickListener clickListener;
private Level level;
private View layout;
private TextView text;
private ImageView star1;
private ImageView star2;
private ImageView star3;
private ImageView energy;
public GoalMessageLevelButton(GameActivity gameActivity, GoalMessageLevelButtonOnClickListener clickListener, View layout) {
this.gameActivity = gameActivity;
this.clickListener = clickListener;
this.layout = layout;
layout.setOnClickListener(this);
findViews(layout);
}
private void findViews(View layout) {
text = (TextView) layout.findViewById(R.id.goal_message_levelbutton_textview);
text.setTypeface(gameActivity.getTypeface());
star1 = (ImageView) layout.findViewById(R.id.goal_message_levelbutton_star1);
star2 = (ImageView) layout.findViewById(R.id.goal_message_levelbutton_star2);
star3 = (ImageView) layout.findViewById(R.id.goal_message_levelbutton_star3);
energy = (ImageView) layout.findViewById(R.id.goal_message_levelbutton_energy);
}
public void setVisible(boolean visible){
layout.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
public void init(@StringRes int textId, Level level) {
this.level = level;
text.setText(gameActivity.getString(textId, level.getId()));
showCollectedCurrency(level.getCollectedStars(), level.isEnergyCollected());
}
private 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 Level getLevel() {
return level;
}
public View getView(){
return layout;
}
@Override
public void onClick(View v) {
clickListener.onClick(this);
}
}

View File

@ -0,0 +1,11 @@
package de.frajul.endlessroll.views;
/**
* Created by Julian on 04.11.2017.
*/
public interface GoalMessageLevelButtonOnClickListener {
public void onClick(GoalMessageLevelButton goalMessageLevelButton);
}

View File

@ -1,24 +1,15 @@
package de.frajul.endlessroll.views;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.main.screens.Screen;
/**
@ -27,51 +18,40 @@ import de.frajul.endlessroll.main.screens.Screen;
public class TaskCompletedMessage implements View.OnClickListener, BountyMessage.ScreenSwitchCaller {
private GameActivity gameActivity;
private FrameLayout layout;
private View layout;
private TextView textView;
private LinearLayout messagesLayout;
private List<PlayerShape> unlockedShapes = new ArrayList<>();
public TaskCompletedMessage(GameActivity gameActivity) {
this.gameActivity = gameActivity;
Typeface typeface = gameActivity.getTypeface();
LayoutInflater inflater = LayoutInflater.from(gameActivity);
layout = (FrameLayout) inflater.inflate(R.layout.task_completed_message, null);
layout = inflater.inflate(R.layout.task_completed_message, null);
layout.setOnClickListener(this);
layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
layout.setVisibility(View.GONE);
textView = (TextView) layout.findViewById(R.id.task_completed_text);
textView.setTypeface(typeface);
TextView title = (TextView) layout.findViewById(R.id.task_completed_title);
title.setTypeface(typeface);
messagesLayout = (LinearLayout) layout.findViewById(R.id.task_completed_unlock_list);
}
public void show(List<PlayerShape> shapes) {
unlockedShapes.clear();
unlockedShapes.addAll(shapes);
showNextShape();
}
private void showNextShape() {
messagesLayout.removeAllViews();
PlayerShape shape = unlockedShapes.remove(0);
textView.setText(
shape.getUnlockTask().toString(gameActivity, gameActivity.getLevelManager()));
BountyMessage message = createBountyMessage(shape);
messagesLayout.addView(message.getLayout());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 8, 0, 8);
for (PlayerShape shape : shapes)
addShapeMessage(shape, params);
layout.setVisibility(View.VISIBLE);
}
private void addShapeMessage(PlayerShape shape, LinearLayout.LayoutParams params) {
BountyMessage message = createBountyMessage(shape);
messagesLayout.addView(message.getLayout(), params);
}
private BountyMessage createBountyMessage(PlayerShape shape) {
return new BountyMessage(gameActivity, BountyMessage.MessageType.SHAPE_UNLOCKED, null, this,
BountyMessage bountyMessage = new BountyMessage(gameActivity, BountyMessage.MessageType.SHAPE_UNLOCKED, null, this,
shape.getDrawableId());
return bountyMessage;
}
private void hide() {
@ -79,19 +59,15 @@ public class TaskCompletedMessage implements View.OnClickListener, BountyMessage
messagesLayout.removeAllViews();
}
public FrameLayout getLayout() {
public View getLayout() {
return layout;
}
@Override
public void onClick(View v) {
if (unlockedShapes.isEmpty())
hide();
else
showNextShape();
hide();
}
@Override
public void switchScreen(Screen.ScreenType screenType) {
gameActivity.flipToScreen(screenType);

View File

@ -4,13 +4,14 @@
<shape android:shape="rectangle">
<corners android:radius="10dp"/>
<padding android:bottom="0dp" android:left="5dp" android:right="5dp" android:top="0dp"/>
<solid android:color="#96ffffff"/> </shape>
<solid android:color="#3cffffff"/>
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="10dp"/>
<padding android:bottom="0dp" android:left="5dp" android:right="5dp" android:top="0dp"/>
<solid android:color="#96a7a7a7"/> </shape>
<solid android:color="#3ca7a7a7"/>
</shape>
</item>
</selector>

View File

@ -72,6 +72,15 @@
android:layout_centerVertical="true"
android:visibility="invisible"/>
<include
android:id="@+id/game_goal_message"
layout="@layout/goal_message"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible"/>
<TextView
android:id="@+id/game_countdown"
android:layout_width="wrap_content"

View File

@ -2,11 +2,11 @@
<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:background="@color/background_levelup_message"
android:orientation="vertical">
<include
android:id="@+id/goal_screen_topbar"
android:id="@+id/goal_message_topbar"
layout="@layout/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
@ -18,40 +18,55 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/goal_screen_bottom_layout">
android:layout_above="@id/goal_message_mid_layout">
<Button
android:id="@+id/goal_message_to_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/message_to_menu"
android:textColor="@color/message_views"
android:background="@drawable/xml_background_game_over_message_button"
android:textSize="40sp"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/goal_message_mid_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="@+id/goal_screen_title"
android:id="@+id/goal_message_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/message_level_finished"
android:textColor="@color/level_finished"
android:textSize="55sp"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/goal_screen_bottom_layout"
android:id="@+id/goal_message_bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
android:layout_alignParentBottom="true"
android:layout_margin="5dp">
<include
android:id="@+id/goal_screen_restart"
layout="@layout/levelbutton"
android:id="@+id/goal_message_restart"
layout="@layout/goal_message_levelbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_margin="5dp"/>
android:layout_alignParentStart="true"/>
<include
android:id="@+id/goal_screen_next_level"
layout="@layout/levelbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/goal_message_next_level"
layout="@layout/goal_message_levelbutton"
android:layout_alignParentEnd="true"
android:layout_margin="5dp"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -0,0 +1,54 @@
<?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:background="@drawable/xml_background_game_over_message_button"
android:orientation="vertical">
<TextView
android:id="@+id/goal_message_levelbutton_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/placeholder_textview"
android:textSize="30sp"
android:textColor="@color/message_views"
android:layout_gravity="center_horizontal"
android:textAlignment="center"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/currency_star_empty"
android:id="@+id/goal_message_levelbutton_star1"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/currency_star_empty"
android:id="@+id/goal_message_levelbutton_star2"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/currency_star_empty"
android:id="@+id/goal_message_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/goal_message_levelbutton_energy"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>

View File

@ -2,7 +2,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/xml_background_levelbutton"
android:layout_margin="10dp">

View File

@ -1,45 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_short_menu">
android:background="@color/background_short_menu"
android:orientation="vertical">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/shortmenu_topbar"
layout="@layout/topbar"
android:layout_gravity="center_horizontal"
android:id="@+id/shortmenu_topbar"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal">
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/short_menu_continue"
android:textSize="40sp"
android:textColor="@color/level_finished"
android:id="@+id/shortmenu_continue"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/message_restart"
android:textSize="40sp"
android:textColor="@color/level_finished"
android:id="@+id/shortmenu_restart"/>
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/short_menu_exit"
android:textSize="40sp"
android:textColor="@color/level_finished"
android:id="@+id/shortmenu_exit"/>
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/shortmenu_continue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/short_menu_continue"
android:textColor="@color/level_finished"
android:textSize="40sp"/>
<TextView
android:id="@+id/shortmenu_restart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/message_restart"
android:textColor="@color/level_finished"
android:textSize="40sp"/>
<TextView
android:id="@+id/shortmenu_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/short_menu_exit"
android:textColor="@color/level_finished"
android:textSize="40sp"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@ -1,56 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/background_levelup_message">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/task_completed_unlock_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
android:layout_centerInParent="true"
android:orientation="vertical"/>
<TextView
android:id="@+id/task_completed_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/task_completed"
android:textColor="#ffae00"
android:textSize="45sp"
android:textStyle="bold"
android:layout_marginBottom="-10dp"/>
<TextView
android:id="@+id/task_completed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/placeholder_textview"
android:textColor="#ffe100"
android:textSize="35sp"
android:textStyle="bold"/>
<ImageView
android:layout_width="400dp"
android:layout_height="10dp"
android:id="@+id/imageView"
android:layout_gravity="center_horizontal"
android:src="@drawable/guis_splitter"
android:layout_marginTop="10dp"/>
<LinearLayout
android:id="@+id/task_completed_unlock_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp">
</LinearLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>

View File

@ -21,6 +21,8 @@
<string name="message_try_again">Try again</string>
<string name="message_restart">Restart</string>
<string name="message_next_level">Next level</string>
<string name="goal_message_restart_format_d">Restart Level %d</string>
<string name="goal_message_next_level_format_d">Next Level: %d</string>
<string name="pre_start_screen_loading">LOADING...</string>
<string name="short_menu_continue">Continue</string>
<string name="short_menu_restart">Restart</string>