Changed bomb completely

This commit is contained in:
= 2018-03-18 12:54:41 +01:00
parent 1417d98169
commit 7684692e53
22 changed files with 403 additions and 207 deletions

View File

@ -586,18 +586,18 @@ public final class R {
public static final int abc_search_dropdown_item_icons_2line = 0x7f0a0016;
public static final int abc_search_view = 0x7f0a0017;
public static final int abc_select_dialog_material = 0x7f0a0018;
public static final int notification_media_action = 0x7f0a0023;
public static final int notification_media_cancel_action = 0x7f0a0024;
public static final int notification_template_big_media = 0x7f0a0025;
public static final int notification_template_big_media_narrow = 0x7f0a0026;
public static final int notification_template_lines = 0x7f0a0027;
public static final int notification_template_media = 0x7f0a0028;
public static final int notification_template_part_chronometer = 0x7f0a0029;
public static final int notification_template_part_time = 0x7f0a002a;
public static final int select_dialog_item_material = 0x7f0a002d;
public static final int select_dialog_multichoice_material = 0x7f0a002e;
public static final int select_dialog_singlechoice_material = 0x7f0a002f;
public static final int support_simple_spinner_dropdown_item = 0x7f0a0037;
public static final int notification_media_action = 0x7f0a0024;
public static final int notification_media_cancel_action = 0x7f0a0025;
public static final int notification_template_big_media = 0x7f0a0026;
public static final int notification_template_big_media_narrow = 0x7f0a0027;
public static final int notification_template_lines = 0x7f0a0028;
public static final int notification_template_media = 0x7f0a0029;
public static final int notification_template_part_chronometer = 0x7f0a002a;
public static final int notification_template_part_time = 0x7f0a002b;
public static final int select_dialog_item_material = 0x7f0a002e;
public static final int select_dialog_multichoice_material = 0x7f0a002f;
public static final int select_dialog_singlechoice_material = 0x7f0a0030;
public static final int support_simple_spinner_dropdown_item = 0x7f0a0038;
}
public static final class string {
public static final int abc_action_bar_home_description = 0x7f0d0000;
@ -619,7 +619,7 @@ public final class R {
public static final int abc_shareactionprovider_share_with = 0x7f0d0010;
public static final int abc_shareactionprovider_share_with_application = 0x7f0d0011;
public static final int abc_toolbar_collapse_description = 0x7f0d0012;
public static final int status_bar_notification_info_overflow = 0x7f0d0058;
public static final int status_bar_notification_info_overflow = 0x7f0d0059;
}
public static final class style {
public static final int AlertDialog_AppCompat = 0x7f0e0000;

File diff suppressed because one or more lines are too long

View File

@ -12,13 +12,14 @@ int anim countdown 0x7f01000a
int anim decrease 0x7f01000b
int anim fade_in 0x7f01000c
int anim fade_out 0x7f01000d
int anim pulse 0x7f01000e
int anim rotate 0x7f01000f
int anim scale_up 0x7f010010
int anim shape_button_rotation 0x7f010011
int anim slide_in_left 0x7f010012
int anim slide_in_right 0x7f010013
int anim slide_in_top 0x7f010014
int anim fade_out_accelerating 0x7f01000e
int anim pulse 0x7f01000f
int anim rotate 0x7f010010
int anim scale_up 0x7f010011
int anim shape_button_rotation 0x7f010012
int anim slide_in_left 0x7f010013
int anim slide_in_right 0x7f010014
int anim slide_in_top 0x7f010015
int array world_names 0x7f020000
int attr actionBarDivider 0x7f030000
int attr actionBarItemBackground 0x7f030001
@ -820,49 +821,50 @@ int layout abc_screen_toolbar 0x7f0a0015
int layout abc_search_dropdown_item_icons_2line 0x7f0a0016
int layout abc_search_view 0x7f0a0017
int layout abc_select_dialog_material 0x7f0a0018
int layout confirm_dialog 0x7f0a0019
int layout credits_dialog 0x7f0a001a
int layout game 0x7f0a001b
int layout game_over_message 0x7f0a001c
int layout gl_test_screen 0x7f0a001d
int layout goal_message 0x7f0a001e
int layout goal_message_levelbutton 0x7f0a001f
int layout levelbutton 0x7f0a0020
int layout levels 0x7f0a0021
int layout levelup_message 0x7f0a0022
int layout notification_media_action 0x7f0a0023
int layout notification_media_cancel_action 0x7f0a0024
int layout notification_template_big_media 0x7f0a0025
int layout notification_template_big_media_narrow 0x7f0a0026
int layout notification_template_lines 0x7f0a0027
int layout notification_template_media 0x7f0a0028
int layout notification_template_part_chronometer 0x7f0a0029
int layout notification_template_part_time 0x7f0a002a
int layout pre_start_screen 0x7f0a002b
int layout price_button 0x7f0a002c
int layout select_dialog_item_material 0x7f0a002d
int layout select_dialog_multichoice_material 0x7f0a002e
int layout select_dialog_singlechoice_material 0x7f0a002f
int layout settings 0x7f0a0030
int layout shape_button 0x7f0a0031
int layout shape_inspector 0x7f0a0032
int layout shape_inspector_check_box 0x7f0a0033
int layout shape_shop 0x7f0a0034
int layout short_menu 0x7f0a0035
int layout start_screen 0x7f0a0036
int layout support_simple_spinner_dropdown_item 0x7f0a0037
int layout task_completed_message 0x7f0a0038
int layout tool_inspector 0x7f0a0039
int layout tool_offer_slot 0x7f0a003a
int layout tool_slot 0x7f0a003b
int layout toolbutton 0x7f0a003c
int layout toolbuttonbar 0x7f0a003d
int layout toolshop 0x7f0a003e
int layout topbar 0x7f0a003f
int layout tutorial 0x7f0a0040
int layout unlock_message 0x7f0a0041
int layout world_button 0x7f0a0042
int layout worlds 0x7f0a0043
int layout bomb_error_message 0x7f0a0019
int layout confirm_dialog 0x7f0a001a
int layout credits_dialog 0x7f0a001b
int layout game 0x7f0a001c
int layout game_over_message 0x7f0a001d
int layout gl_test_screen 0x7f0a001e
int layout goal_message 0x7f0a001f
int layout goal_message_levelbutton 0x7f0a0020
int layout levelbutton 0x7f0a0021
int layout levels 0x7f0a0022
int layout levelup_message 0x7f0a0023
int layout notification_media_action 0x7f0a0024
int layout notification_media_cancel_action 0x7f0a0025
int layout notification_template_big_media 0x7f0a0026
int layout notification_template_big_media_narrow 0x7f0a0027
int layout notification_template_lines 0x7f0a0028
int layout notification_template_media 0x7f0a0029
int layout notification_template_part_chronometer 0x7f0a002a
int layout notification_template_part_time 0x7f0a002b
int layout pre_start_screen 0x7f0a002c
int layout price_button 0x7f0a002d
int layout select_dialog_item_material 0x7f0a002e
int layout select_dialog_multichoice_material 0x7f0a002f
int layout select_dialog_singlechoice_material 0x7f0a0030
int layout settings 0x7f0a0031
int layout shape_button 0x7f0a0032
int layout shape_inspector 0x7f0a0033
int layout shape_inspector_check_box 0x7f0a0034
int layout shape_shop 0x7f0a0035
int layout short_menu 0x7f0a0036
int layout start_screen 0x7f0a0037
int layout support_simple_spinner_dropdown_item 0x7f0a0038
int layout task_completed_message 0x7f0a0039
int layout tool_inspector 0x7f0a003a
int layout tool_offer_slot 0x7f0a003b
int layout tool_slot 0x7f0a003c
int layout toolbutton 0x7f0a003d
int layout toolbuttonbar 0x7f0a003e
int layout toolshop 0x7f0a003f
int layout topbar 0x7f0a0040
int layout tutorial 0x7f0a0041
int layout unlock_message 0x7f0a0042
int layout world_button 0x7f0a0043
int layout worlds 0x7f0a0044
int mipmap ic_launcher 0x7f0b0000
int raw music_game_1 0x7f0c0000
int raw music_game_2 0x7f0c0001
@ -918,95 +920,96 @@ int string credits_sounds_title 0x7f0d0022
int string credits_testers 0x7f0d0023
int string credits_testers_title 0x7f0d0024
int string credits_title 0x7f0d0025
int string game_countdown_placeholder 0x7f0d0026
int string game_fps_format_d 0x7f0d0027
int string game_fps_placeholder 0x7f0d0028
int string game_playerprogress_format_f 0x7f0d0029
int string game_playerprogress_placeholder 0x7f0d002a
int string game_playerspeed_format_f 0x7f0d002b
int string game_playerspeed_placeholder 0x7f0d002c
int string goal_message_next_level_format_d 0x7f0d002d
int string goal_message_next_world_format_s 0x7f0d002e
int string goal_message_restart_format_d 0x7f0d002f
int string level_button_format_d 0x7f0d0030
int string levelup 0x7f0d0031
int string message_game_over 0x7f0d0032
int string message_level_finished 0x7f0d0033
int string message_restart 0x7f0d0034
int string message_to_menu 0x7f0d0035
int string message_try_again 0x7f0d0036
int string placeholder_button 0x7f0d0037
int string placeholder_number 0x7f0d0038
int string placeholder_textview 0x7f0d0039
int string playershape_description_ball 0x7f0d003a
int string playershape_description_clock 0x7f0d003b
int string playershape_description_hypno_spiral 0x7f0d003c
int string playershape_description_locked 0x7f0d003d
int string playershape_description_pacman 0x7f0d003e
int string playershape_description_smiley 0x7f0d003f
int string playershape_description_sun 0x7f0d0040
int string playershape_description_wheel 0x7f0d0041
int string playershape_name_ball 0x7f0d0042
int string playershape_name_clock 0x7f0d0043
int string playershape_name_hypno_spiral 0x7f0d0044
int string playershape_name_locked 0x7f0d0045
int string playershape_name_pacman 0x7f0d0046
int string playershape_name_smiley 0x7f0d0047
int string playershape_name_sun 0x7f0d0048
int string playershape_name_wheel 0x7f0d0049
int string pre_start_screen_loading 0x7f0d004a
int string price_button_buy 0x7f0d004b
int string price_button_upgrade 0x7f0d004c
int string settings_credits 0x7f0d004d
int string settings_music 0x7f0d004e
int string settings_reset 0x7f0d004f
int string settings_sounds 0x7f0d0050
int string short_menu_continue 0x7f0d0051
int string short_menu_exit 0x7f0d0052
int string start_screen_finish_world_1 0x7f0d0053
int string start_screen_gain_90_ep 0x7f0d0054
int string start_screen_play 0x7f0d0055
int string start_screen_to_gl_test_screen 0x7f0d0056
int string start_screen_unlock_all_levels 0x7f0d0057
int string status_bar_notification_info_overflow 0x7f0d0058
int string task_collect_energy_format_d 0x7f0d0059
int string task_collect_energy_progress_format_ddd 0x7f0d005a
int string task_collect_stars_format_d 0x7f0d005b
int string task_collect_stars_progress_format_ddd 0x7f0d005c
int string task_complete_world_format_d 0x7f0d005d
int string task_empty 0x7f0d005e
int string tool_description_bomb 0x7f0d005f
int string tool_description_locked_format_d 0x7f0d0060
int string tool_description_magnet 0x7f0d0061
int string tool_description_power_mushroom 0x7f0d0062
int string tool_description_ramp 0x7f0d0063
int string tool_description_spring 0x7f0d0064
int string tool_description_stasis 0x7f0d0065
int string tool_level_format_d 0x7f0d0066
int string tool_name_bomb 0x7f0d0067
int string tool_name_locked 0x7f0d0068
int string tool_name_magnet 0x7f0d0069
int string tool_name_power_mushroom 0x7f0d006a
int string tool_name_ramp 0x7f0d006b
int string tool_name_spring 0x7f0d006c
int string tool_name_stasis 0x7f0d006d
int string topbar_level_format_d 0x7f0d006e
int string topbar_level_placeholder 0x7f0d006f
int string tutorial_leveled_up_to_toolshop 0x7f0d0070
int string tutorial_place_ramp_air 0x7f0d0071
int string tutorial_place_ramp_air_2 0x7f0d0072
int string tutorial_place_ramp_gap 0x7f0d0073
int string tutorial_place_ramp_obstacle 0x7f0d0074
int string tutorial_place_tools 0x7f0d0075
int string tutorial_placeholder 0x7f0d0076
int string tutorial_spring_equipped 0x7f0d0077
int string tutorial_switch_tools_switch 0x7f0d0078
int string tutorial_switch_tools_two_neccessary 0x7f0d0079
int string tutorial_welcome 0x7f0d007a
int string unlock_message_placeholder 0x7f0d007b
int string world_button_count_format_dd 0x7f0d007c
int string world_button_progress_placeholder 0x7f0d007d
int string world_button_title_placeholder 0x7f0d007e
int string game_bomb_error_message 0x7f0d0026
int string game_countdown_placeholder 0x7f0d0027
int string game_fps_format_d 0x7f0d0028
int string game_fps_placeholder 0x7f0d0029
int string game_playerprogress_format_f 0x7f0d002a
int string game_playerprogress_placeholder 0x7f0d002b
int string game_playerspeed_format_f 0x7f0d002c
int string game_playerspeed_placeholder 0x7f0d002d
int string goal_message_next_level_format_d 0x7f0d002e
int string goal_message_next_world_format_s 0x7f0d002f
int string goal_message_restart_format_d 0x7f0d0030
int string level_button_format_d 0x7f0d0031
int string levelup 0x7f0d0032
int string message_game_over 0x7f0d0033
int string message_level_finished 0x7f0d0034
int string message_restart 0x7f0d0035
int string message_to_menu 0x7f0d0036
int string message_try_again 0x7f0d0037
int string placeholder_button 0x7f0d0038
int string placeholder_number 0x7f0d0039
int string placeholder_textview 0x7f0d003a
int string playershape_description_ball 0x7f0d003b
int string playershape_description_clock 0x7f0d003c
int string playershape_description_hypno_spiral 0x7f0d003d
int string playershape_description_locked 0x7f0d003e
int string playershape_description_pacman 0x7f0d003f
int string playershape_description_smiley 0x7f0d0040
int string playershape_description_sun 0x7f0d0041
int string playershape_description_wheel 0x7f0d0042
int string playershape_name_ball 0x7f0d0043
int string playershape_name_clock 0x7f0d0044
int string playershape_name_hypno_spiral 0x7f0d0045
int string playershape_name_locked 0x7f0d0046
int string playershape_name_pacman 0x7f0d0047
int string playershape_name_smiley 0x7f0d0048
int string playershape_name_sun 0x7f0d0049
int string playershape_name_wheel 0x7f0d004a
int string pre_start_screen_loading 0x7f0d004b
int string price_button_buy 0x7f0d004c
int string price_button_upgrade 0x7f0d004d
int string settings_credits 0x7f0d004e
int string settings_music 0x7f0d004f
int string settings_reset 0x7f0d0050
int string settings_sounds 0x7f0d0051
int string short_menu_continue 0x7f0d0052
int string short_menu_exit 0x7f0d0053
int string start_screen_finish_world_1 0x7f0d0054
int string start_screen_gain_90_ep 0x7f0d0055
int string start_screen_play 0x7f0d0056
int string start_screen_to_gl_test_screen 0x7f0d0057
int string start_screen_unlock_all_levels 0x7f0d0058
int string status_bar_notification_info_overflow 0x7f0d0059
int string task_collect_energy_format_d 0x7f0d005a
int string task_collect_energy_progress_format_ddd 0x7f0d005b
int string task_collect_stars_format_d 0x7f0d005c
int string task_collect_stars_progress_format_ddd 0x7f0d005d
int string task_complete_world_format_d 0x7f0d005e
int string task_empty 0x7f0d005f
int string tool_description_bomb 0x7f0d0060
int string tool_description_locked_format_d 0x7f0d0061
int string tool_description_magnet 0x7f0d0062
int string tool_description_power_mushroom 0x7f0d0063
int string tool_description_ramp 0x7f0d0064
int string tool_description_spring 0x7f0d0065
int string tool_description_stasis 0x7f0d0066
int string tool_level_format_d 0x7f0d0067
int string tool_name_bomb 0x7f0d0068
int string tool_name_locked 0x7f0d0069
int string tool_name_magnet 0x7f0d006a
int string tool_name_power_mushroom 0x7f0d006b
int string tool_name_ramp 0x7f0d006c
int string tool_name_spring 0x7f0d006d
int string tool_name_stasis 0x7f0d006e
int string topbar_level_format_d 0x7f0d006f
int string topbar_level_placeholder 0x7f0d0070
int string tutorial_leveled_up_to_toolshop 0x7f0d0071
int string tutorial_place_ramp_air 0x7f0d0072
int string tutorial_place_ramp_air_2 0x7f0d0073
int string tutorial_place_ramp_gap 0x7f0d0074
int string tutorial_place_ramp_obstacle 0x7f0d0075
int string tutorial_place_tools 0x7f0d0076
int string tutorial_placeholder 0x7f0d0077
int string tutorial_spring_equipped 0x7f0d0078
int string tutorial_switch_tools_switch 0x7f0d0079
int string tutorial_switch_tools_two_neccessary 0x7f0d007a
int string tutorial_welcome 0x7f0d007b
int string unlock_message_placeholder 0x7f0d007c
int string world_button_count_format_dd 0x7f0d007d
int string world_button_progress_placeholder 0x7f0d007e
int string world_button_title_placeholder 0x7f0d007f
int style AlertDialog_AppCompat 0x7f0e0000
int style AlertDialog_AppCompat_Light 0x7f0e0001
int style Animation_AppCompat_Dialog 0x7f0e0002

View File

@ -6,6 +6,8 @@ uniform vec2 texAtlasSize;
uniform vec2 gridSize;
uniform float deadly;
uniform float floating;
uniform float bombSelected;
uniform float bombExplosionState;
varying vec2 pass_TexCoords;
@ -59,6 +61,13 @@ void main() {
gl_FragColor.a = min(gl_FragColor.a, alpha);
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
if(bombSelected == 1.0 || bombExplosionState >= 0.0){
vec3 red = vec3(1.0, 0.0, 0.0);
float mixValue = 0.4;
gl_FragColor.r += 0.2 * bombExplosionState;
gl_FragColor.rgb = mix(gl_FragColor.rgb, red, mixValue);
}
}
float itermod(in float x, in float y){

View File

@ -21,6 +21,8 @@ public class Obstacle extends Entity {
private float moveProgress;
private float moveDirection;
private int bombExplosionState = -1;
public Obstacle(World world, ObstacleData data, float terrainEdge, Player player) {
super(world.getObstacleTexture(), new Vector(data.getX(), data.getY()), data.getWidth(),
data.getHeight());
@ -98,4 +100,11 @@ public class Obstacle extends Entity {
return gridSize;
}
public int getBombExplosionState() {
return bombExplosionState;
}
public void setBombExplosionState(int bombExplosionState) {
this.bombExplosionState = bombExplosionState;
}
}

View File

@ -19,6 +19,15 @@ public class CollisionDetector {
triangleDetector = new CircleTriangleCollisionDetector();
}
public boolean isPointQuadCollision(Vector point, Quad quad) {
if (point.getX() >= quad.getLeftEdge() && point.getX() <= quad.getRightEdge()) {
if (point.getY() >= quad.getBottomEdge() && point.getY() <= quad.getTopEdge()) {
return true;
}
}
return false;
}
public boolean isCircleCircleCollision(Circle c1, Circle c2) {
float distance = Math.abs(c1.getCenter().vectorTo(c2.getCenter()).length());
float radiusSum = c1.getRadius() + c2.getRadius();

View File

@ -1,14 +1,11 @@
package de.frajul.endlessroll.entities.tools;
import java.util.List;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.DestroyEffect;
import de.frajul.endlessroll.entities.Obstacle;
import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collision.CollisionDetector;
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.entities.collision.geometry.Quad;
import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.main.game.Timer;
/**
@ -16,29 +13,36 @@ import de.frajul.endlessroll.main.game.Timer;
*/
public class Bomb extends Tool {
public final float RANGE = 1;
private float delta;
private boolean exploding = false;
private Obstacle attachedObstacle;
private Vector offsetToObstaclePosition = new Vector();
public Bomb(Vector position) {
super(ToolType.BOMB, position, .29f, .29f, false, false);
super(ToolType.BOMB, position, .2f, .2f, false, false);
animation.setIndexSequence(new int[]{0, 1, 2});
animation.setLooping(false);
animation.setRequiredDelta(
(int) (ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION) / 3));
(int) (ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION) / 3f));
}
@Override
public void update(Timer timer) {
super.update(timer);
float explosionDuration = ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION);
delta += timer.getFrameTimeSeconds();
if (delta >= ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION))
int currentExplosionState = Math.min((int) (delta / (explosionDuration / 3f)), 3);
if (attachedObstacle != null) {
if(attachedObstacle.isMoving())
super.setPosition(new Vector(attachedObstacle.getPosition()).translate(offsetToObstaclePosition));
attachedObstacle.setBombExplosionState(currentExplosionState);
}
if (delta >= explosionDuration)
exploding = true;
}
@Override
public void onPlayerCollision(Player player, Timer timer) {
}
@Override
@ -51,17 +55,19 @@ public class Bomb extends Tool {
return this;
}
public void setAttachedObstacle(Obstacle attachedObstacle) {
this.attachedObstacle = attachedObstacle;
offsetToObstaclePosition = attachedObstacle.getPosition().vectorTo(super.getPosition());
attachedObstacle.setBombExplosionState(0);
}
public boolean isExploding() {
return exploding;
}
public void explode(List<Obstacle> obstacles, CollisionDetector detector) {
float range = RANGE * ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.RANGE) / 100;
Quad explosionRange = new Quad(new Vector(super.getPosition()), range, range);
for (Obstacle obstacle : obstacles) {
if (detector.isQuadQuadCollision(obstacle, explosionRange))
obstacle.destroy(DestroyEffect.EXPLOSION);
}
public void explode() {
if (attachedObstacle != null)
attachedObstacle.destroy(DestroyEffect.EXPLOSION);
super.destroy(DestroyEffect.EXPLOSION);
}
}

View File

@ -24,9 +24,8 @@ public enum ToolType {
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 4000, 2000)),
BOMB(R.string.tool_name_bomb, R.string.tool_description_bomb, R.drawable.tools_bomb,
R.drawable.tools_bomb_button, 12, 4, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000),
new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 400),
new ToolUpgrade(ToolUpgradeType.RANGE, 100, 200)),
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 2000),
new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 500)),
MAGNET(R.string.tool_name_magnet, R.string.tool_description_magnet, R.drawable.tools_magnet,
R.drawable.tools_magnet_button, 10, 2, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 3000),

View File

@ -6,6 +6,6 @@ package de.frajul.endlessroll.entities.tools;
public enum ToolUpgradeType {
COOLDOWN, DURATION, FORCE, RANGE, SIZE;
COOLDOWN, DURATION, FORCE, SIZE;
}

View File

@ -8,6 +8,7 @@ import java.util.List;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.DestroyEffect;
import de.frajul.endlessroll.entities.Obstacle;
import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collectables.Energy;
import de.frajul.endlessroll.entities.collectables.Star;
@ -15,6 +16,8 @@ import de.frajul.endlessroll.entities.collision.CollisionManager;
import de.frajul.endlessroll.entities.particles.Firework;
import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.entities.tools.Bomb;
import de.frajul.endlessroll.entities.tools.Tool;
import de.frajul.endlessroll.entities.tools.ToolType;
import de.frajul.endlessroll.levels.Level;
import de.frajul.endlessroll.levels.LevelPack;
@ -100,7 +103,7 @@ public class Game extends Rendering<GameScene> {
gameActivity.getUser().getCurrentPlayerShape());
player = scene.getPlayer();
viewManager.resetViews(gameActivity.getUser());
currentTool = viewManager.toolButtonBar.getActiveButton().getToolType();
setCurrentTool(viewManager.toolButtonBar.getActiveButton().getToolType(), true);
viewManager.startCountdown();
}
} catch (Exception e) {
@ -161,6 +164,27 @@ public class Game extends Rendering<GameScene> {
ToolButton button = bar.getByToolType(currentTool);
if (button != null && button.finishedLoading()) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (currentTool == ToolType.BOMB) {
try {
Vector touchPoint = scene
.calcWorldFromScreenCoords(event.getX(), event.getY());
Obstacle selectedObstacle = scene.getObstacleAtPoint(touchPoint);
if (selectedObstacle == null) {
viewManager.showBombErrorMessage(event.getX(), event.getY());
return true;
} else {
button.setProgress(0);
scene.getBombSelected().set(false);
Tool tool = addTool(event.getX(), event.getY());
if (tool != null && tool instanceof Bomb)
((Bomb) tool).setAttachedObstacle(selectedObstacle);
return true;
}
} catch (Exception e) {
onException(e);
return true;
}
}
button.setProgress(0);
addTool(event.getX(), event.getY());
}
@ -193,12 +217,18 @@ public class Game extends Rendering<GameScene> {
handler.toScreen(Screen.ScreenType.LEVELS);
}
public void toToolShop() {
handler.toScreen(Screen.ScreenType.TOOL_SHOP);
public void onToolButtonFinishedLoading(ToolType toolType){
if(currentTool == ToolType.BOMB && toolType == ToolType.BOMB)
scene.getBombSelected().set(true);
}
public void setCurrentTool(ToolType toolType) {
public void setCurrentTool(ToolType toolType, boolean toolButtonFinishedLoading) {
currentTool = toolType;
if (currentTool == ToolType.BOMB && toolButtonFinishedLoading) {
scene.getBombSelected().set(true);
} else {
scene.getBombSelected().set(false);
}
}
public void pauseWithoutMenu() {
@ -224,13 +254,14 @@ public class Game extends Rendering<GameScene> {
gameState = GameState.RUNNING;
}
private void addTool(float x, float y) {
private Tool addTool(float x, float y) {
try {
gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().placeToolSound);
scene.addTool(currentTool, x, y, physics);
return scene.addTool(currentTool, x, y, physics);
} catch (Exception e) {
onException(e);
}
return null;
}
public void onGameOver(boolean playerExplode) {
@ -271,8 +302,6 @@ public class Game extends Rendering<GameScene> {
firework.start();
gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().fireworkSound);
//viewManager.showGameOverMessage(levelPack.isLastLevel(level), MessageType.WIN);
//TODO: fadeInWithDelay something
viewManager.showGoalMessage(levelPack, level);
MyDatabase database = gameActivity.getDataStorageHandler().getDatabase();

View File

@ -81,7 +81,7 @@ public class GameScene extends Scene {
obstacles.add(obstacle);
}
public void addTool(ToolType type, float screenX, float screenY, Physics physics) throws Exception {
public Tool addTool(ToolType type, float screenX, float screenY, Physics physics) throws Exception {
Vector position = calcWorldFromScreenCoords(screenX, screenY);
Tool tool = type.newInstance(position, particleSystem, gameActivity.getSoundManager());
physics.checkSingleToolCollision(tool, this);
@ -90,8 +90,18 @@ public class GameScene extends Scene {
throw new Exception(
"Current ToolType(" + type + ") returns null at method newInstance()");
tools.add(tool);
return tool;
}
public Obstacle getObstacleAtPoint(Vector point) {
synchronized (obstacles) {
for (Obstacle obstacle : obstacles) {
if (collisionDetector.isPointQuadCollision(point, obstacle))
return obstacle;
}
}
return null;
}
public void update(Timer timer) {
player.setSpeedByProgress(player.getProgress() / goalX);
@ -125,12 +135,11 @@ public class GameScene extends Scene {
if (tool instanceof Bomb) {
Bomb bomb = (Bomb) tool;
if (bomb.isExploding())
bomb.explode(obstacles, collisionDetector);
}
else if (tool instanceof Stasis) {
bomb.explode();
} else if (tool instanceof Stasis) {
Stasis stasis = (Stasis) tool;
stasis.updateSoundVolume(player);
} else if(tool instanceof Magnet){
} else if (tool instanceof Magnet) {
Magnet magnet = (Magnet) tool;
magnet.updateSoundVolume(player);
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.AnimatedEntity;
@ -43,11 +44,12 @@ public abstract class Scene {
protected Ceiling ceiling;
protected Player player;
protected ParticleSource enviromentParticles;
protected AtomicBoolean bombSelected;
protected List<Entity> uncategorizedEntities = Collections
protected final List<Entity> uncategorizedEntities = Collections
.synchronizedList(new ArrayList<Entity>());
protected List<Obstacle> obstacles = Collections.synchronizedList(new ArrayList<Obstacle>());
protected List<Tool> tools = Collections.synchronizedList(new ArrayList<Tool>());
protected final List<Obstacle> obstacles = Collections.synchronizedList(new ArrayList<Obstacle>());
protected final List<Tool> tools = Collections.synchronizedList(new ArrayList<Tool>());
protected Collectables collectables = new Collectables();
public Scene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
@ -60,6 +62,7 @@ public abstract class Scene {
terrain = new Terrain(World.GRASSLANDS.getTerrainTexture());
ceiling = new Ceiling(World.GRASSLANDS.getTerrainTexture());
player = new Player();
bombSelected = new AtomicBoolean(false);
}
public void setTexturePack(TexturePack texturePack) {
@ -204,4 +207,8 @@ public abstract class Scene {
public Camera getCamera() {
return camera;
}
public synchronized AtomicBoolean getBombSelected() {
return bombSelected;
}
}

View File

@ -138,6 +138,7 @@ public class GameRenderer implements GLSurfaceView.Renderer {
List<Obstacle> obstacles = scene.getObstacles();
obstacleShader.start();
obstacleShader.loadMVPMatrix(matrixCreator, scene.getCamera());
obstacleShader.loadBombSelected(scene.getBombSelected().get());
synchronized (obstacles) {
for (Obstacle obstacle : obstacles)
renderObstacle(gl, obstacle);
@ -155,6 +156,7 @@ public class GameRenderer implements GLSurfaceView.Renderer {
obstacleShader.loadGridSize(obstacle.getGridSize());
obstacleShader.loadDeadly(obstacle.isDeadly());
obstacleShader.loadFloating(obstacle.isFloating());
obstacleShader.loadBombExplosionState(obstacle.getBombExplosionState());
quad.draw();
}

View File

@ -21,6 +21,8 @@ public class ObstacleShader extends ShaderProgram {
private int location_gridSize;
private int location_deadly;
private int location_floating;
private int location_bombSelected;
private int location_bombExplosionState;
public ObstacleShader(Context context) throws Exception {
super(context, "shader/entityVertexShader.glsl", "shader/obstacleFragmentShader.glsl");
@ -35,6 +37,8 @@ public class ObstacleShader extends ShaderProgram {
location_gridSize = super.getUniformLocation("gridSize");
location_deadly = super.getUniformLocation("deadly");
location_floating = super.getUniformLocation("floating");
location_bombSelected = super.getUniformLocation("bombSelected");
location_bombExplosionState = super.getUniformLocation("bombExplosionState");
}
public void loadMVPMatrix(MatrixCreator matrixCreator, Camera camera) {
@ -68,4 +72,12 @@ public class ObstacleShader extends ShaderProgram {
GLES20.glUniform1f(location_floating, floating ? 1 : 0);
}
public void loadBombSelected(boolean bombSelected){
GLES20.glUniform1f(location_bombSelected, bombSelected ? 1 : 0);
}
public void loadBombExplosionState(int explosionState){
GLES20.glUniform1f(location_bombExplosionState, explosionState);
}
}

View File

@ -0,0 +1,56 @@
package de.frajul.endlessroll.views;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;
/**
* Created by Julian on 18.03.2018.
*/
public class BombErrorMessage implements Animation.AnimationListener{
private TextView view;
private Animation animation;
private boolean animationRunning = false;
public BombErrorMessage(GameActivity gameActivity){
LayoutInflater inflater = LayoutInflater.from(gameActivity);
view = (TextView) inflater.inflate(R.layout.bomb_error_message, null);
view.setTypeface(gameActivity.getTypeface());
animation = AnimationUtils.loadAnimation(gameActivity, R.anim.fade_out_accelerating);
animation.setAnimationListener(this);
}
public void show(float xPos, float yPos){
animationRunning = true;
view.setX(xPos - (float) view.getWidth() / 2);
view.setY(yPos);
view.startAnimation(animation);
}
@Override
public void onAnimationEnd(Animation animation) {
animationRunning = false;
}
public TextView getView() {
return view;
}
public boolean isAnimationRunning() {
return animationRunning;
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
}

View File

@ -13,12 +13,14 @@ import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.tools.ToolSlot;
import de.frajul.endlessroll.entities.tools.ToolType;
import de.frajul.endlessroll.entities.tools.ToolUpgradeType;
import de.frajul.endlessroll.main.game.Game;
/**
* Created by Julian on 15.01.2016.
*/
public class ToolButton {
private Game game;
private boolean locked;
private ToolType toolType;
private Context context;
@ -31,8 +33,9 @@ public class ToolButton {
private ImageView animationView;
private Animation scaleAnimation;
public ToolButton(ToolSlot slot, Context context, RelativeLayout layout) {
public ToolButton(ToolSlot slot, Game game, Context context, RelativeLayout layout) {
this.context = context;
this.game = game;
this.layout = layout;
progressBar = (ProgressBar) layout.findViewById(R.id.tool_button_progress_bar);
@ -80,9 +83,10 @@ public class ToolButton {
progressBar.setProgress(100 - (int) progress);
if (!locked && toolType != null) {
if (active) {
if (progress == 100)
if (progress == 100) {
game.onToolButtonFinishedLoading(toolType);
setColor(R.color.toolbuttonActiveReady);
else
}else
setColor(R.color.toolbuttonActiveNotReady);
} else {
if (progress == 100)

View File

@ -59,10 +59,10 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL
button3.setOnClickListener(this);
button4 = (RelativeLayout) layout1.findViewById(R.id.toolbutton_4);
button4.setOnClickListener(this);
buttons.add(new ToolButton(toolSlotSettings.get(0), context, button1));
buttons.add(new ToolButton(toolSlotSettings.get(1), context, button2));
buttons.add(new ToolButton(toolSlotSettings.get(2), context, button3));
buttons.add(new ToolButton(toolSlotSettings.get(3), context, button4));
buttons.add(new ToolButton(toolSlotSettings.get(0), game, context, button1));
buttons.add(new ToolButton(toolSlotSettings.get(1), game, context, button2));
buttons.add(new ToolButton(toolSlotSettings.get(2), game, context, button3));
buttons.add(new ToolButton(toolSlotSettings.get(3), game, context, button4));
}
public void setTopPrimary() {
@ -130,19 +130,19 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL
@Override
public void onClick(View v) {
if (game.getGameState() == GameState.RUNNING) {
ToolType clickedType = null;
ToolButton clickedButton = null;
if (v.equals(button1) && !buttons.get(0).isLocked()) {
clickedType = buttons.get(0).getToolType();
clickedButton = buttons.get(0);
} else if (v.equals(button2) && !buttons.get(1).isLocked()) {
clickedType = buttons.get(1).getToolType();
clickedButton = buttons.get(1);
} else if (v.equals(button3) && !buttons.get(2).isLocked()) {
clickedType = buttons.get(2).getToolType();
clickedButton = buttons.get(2);
} else if (v.equals(button4) && !buttons.get(3).isLocked()) {
clickedType = buttons.get(3).getToolType();
clickedButton = buttons.get(3);
}
if (clickedType != null) {
game.setCurrentTool(clickedType);
setActive(clickedType);
if (clickedButton != null) {
game.setCurrentTool(clickedButton.getToolType(), clickedButton.finishedLoading());
setActive(clickedButton.getToolType());
}
}
}

View File

@ -6,6 +6,9 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.levels.Level;
import de.frajul.endlessroll.levels.LevelPack;
@ -23,6 +26,7 @@ public class ViewManager implements View.OnClickListener {
private GameHandler gameViewHandler;
private Game game;
private GameActivity gameActivity;
private TextView fpsView;
private TextView playerProgress;
@ -34,11 +38,14 @@ public class ViewManager implements View.OnClickListener {
public ShortMenu shortMenu;
private Countdown countdown;
private List<BombErrorMessage> bombErrorMessages = new ArrayList<>();
private String fpsFormat, playerProgressFormat, playerSpeedFormat;
public ViewManager(final Game game, final GameScreen gameScreen, final GameHandler gameViewHandler, final GameActivity gameActivity) {
this.game = game;
this.gameViewHandler = gameViewHandler;
this.gameActivity = gameActivity;
final RelativeLayout layout = gameViewHandler.getRootLayout();
gameViewHandler.startInUiThread(new Runnable() {
@ -61,8 +68,11 @@ public class ViewManager implements View.OnClickListener {
pauseButton = (ImageView) layout.findViewById(R.id.game_pausebutton);
pauseButton.setOnClickListener(this);
playerProgress = (TextView) layout.findViewById(R.id.game_playerprogress);
playerProgress.setTypeface(gameActivity.getTypeface());
playerSpeed = (TextView) layout.findViewById(R.id.game_playerspeed);
playerSpeed.setTypeface(gameActivity.getTypeface());
fpsView = (TextView) layout.findViewById(R.id.game_fps);
fpsView.setTypeface(gameActivity.getTypeface());
fpsFormat = game.getContext().getString(R.string.game_fps_format_d);
playerProgressFormat = game.getContext().getString(R.string.game_playerprogress_format_f);
@ -78,6 +88,19 @@ public class ViewManager implements View.OnClickListener {
goalMessage.prepareToBeShown();
}
public void showBombErrorMessage(float xPos, float yPos) {
for (BombErrorMessage bombErrorMessage : bombErrorMessages) {
if (!bombErrorMessage.isAnimationRunning()) {
bombErrorMessage.show(xPos, yPos);
return;
}
}
BombErrorMessage bombErrorMessage = new BombErrorMessage(gameActivity);
bombErrorMessage.show(xPos, yPos);
gameViewHandler.getRootLayout().addView(bombErrorMessage.getView());
bombErrorMessages.add(bombErrorMessage);
}
@Override
public void onClick(View v) {
game.tryToPause();

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha
android:duration="1000"
android:fromAlpha="1"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="0" />
</set>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/game_bomb_error_message"
android:textColor="@color/red"
android:textSize="20sp"
android:visibility="invisible"/>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="game_bomb_error_message">Setze die Bombe auf ein Hindernis</string>
<string name="placeholder_button">Drück mich!</string>
<string name="placeholder_textview">Ich bin ein Text!</string>
<string name="message_level_finished">ZIEL ERREICHT</string>

View File

@ -4,6 +4,7 @@
<string name="placeholder_textview">I\'m a text!</string>
<string name="placeholder_number" translatable="false">997.5</string>
<string name="game_bomb_error_message">Set the bomb on an obstacle</string>
<string name="game_playerprogress_placeholder" translatable="false">0.0m</string>
<string name="game_playerprogress_format_f" translatable="false">%.1fm</string>
<string name="game_playerspeed_placeholder" translatable="false">0.0m/s</string>
@ -110,7 +111,7 @@
<string name="credits_testers_title">TESTERS</string>
<string name="credits_testers" translatable="false">Tester1\nTester2\nTester3\nTester4</string>
<string name="credits_sounds_title" translatable="false">SOUNDS</string>
<string name="credits_sounds" translatable="false">www.noiseforfun.com</string>
<string name="credits_sounds" translatable="false">„Fruit-collected“, „Glocken-good“, „Carillon-02-a“, „Carillon-02-b“,„Fireball-02“, „Fruit-appearance“, „Voltage-hum“ (noiseforfun.com)</string>
<string name="credits_music_title">MUSIC</string>
<string name="credits_music" translatable="false">\"Balloon Game\", \"Bit Shift\", \"Digital Lemonade\"\nKevin MacLeod (incompetech.com)\nLicensed under Creative Commons: By Attribution 3.0\nhttp://creativecommons.org/licenses/by/3.0/</string>
</resources>