implemented all sounds and music

This commit is contained in:
= 2018-01-19 17:41:05 +01:00
parent 53b9b6bb14
commit 2c19e3dcb5
52 changed files with 686 additions and 379 deletions

View File

@ -456,7 +456,7 @@ public final class R {
public static final int abc_textfield_search_activated_mtrl_alpha = 0x7f070042; public static final int abc_textfield_search_activated_mtrl_alpha = 0x7f070042;
public static final int abc_textfield_search_default_mtrl_alpha = 0x7f070043; public static final int abc_textfield_search_default_mtrl_alpha = 0x7f070043;
public static final int abc_textfield_search_material = 0x7f070044; public static final int abc_textfield_search_material = 0x7f070044;
public static final int notification_template_icon_bg = 0x7f070063; public static final int notification_template_icon_bg = 0x7f070065;
} }
public static final class id { public static final class id {
public static final int action0 = 0x7f080000; public static final int action0 = 0x7f080000;
@ -529,29 +529,29 @@ public final class R {
public static final int search_src_text = 0x7f080071; public static final int search_src_text = 0x7f080071;
public static final int search_voice_btn = 0x7f080072; public static final int search_voice_btn = 0x7f080072;
public static final int select_dialog_listview = 0x7f080073; public static final int select_dialog_listview = 0x7f080073;
public static final int shortcut = 0x7f080083; public static final int shortcut = 0x7f080084;
public static final int showCustom = 0x7f080088; public static final int showCustom = 0x7f080089;
public static final int showHome = 0x7f080089; public static final int showHome = 0x7f08008a;
public static final int showTitle = 0x7f08008a; public static final int showTitle = 0x7f08008b;
public static final int spacer = 0x7f08008b; public static final int spacer = 0x7f08008c;
public static final int split_action_bar = 0x7f08008c; public static final int split_action_bar = 0x7f08008d;
public static final int src_atop = 0x7f08008d; public static final int src_atop = 0x7f08008e;
public static final int src_in = 0x7f08008e; public static final int src_in = 0x7f08008f;
public static final int src_over = 0x7f08008f; public static final int src_over = 0x7f080090;
public static final int status_bar_latest_event_content = 0x7f080096; public static final int status_bar_latest_event_content = 0x7f080097;
public static final int submit_area = 0x7f080097; public static final int submit_area = 0x7f080098;
public static final int tabMode = 0x7f080098; public static final int tabMode = 0x7f080099;
public static final int text = 0x7f08009a; public static final int text = 0x7f08009b;
public static final int text2 = 0x7f08009b; public static final int text2 = 0x7f08009c;
public static final int textSpacerNoButtons = 0x7f08009c; public static final int textSpacerNoButtons = 0x7f08009d;
public static final int time = 0x7f08009d; public static final int time = 0x7f08009e;
public static final int title = 0x7f08009e; public static final int title = 0x7f08009f;
public static final int title_template = 0x7f08009f; public static final int title_template = 0x7f0800a0;
public static final int topPanel = 0x7f0800bc; public static final int topPanel = 0x7f0800bd;
public static final int up = 0x7f0800ce; public static final int up = 0x7f0800cf;
public static final int useLogo = 0x7f0800cf; public static final int useLogo = 0x7f0800d0;
public static final int withText = 0x7f0800d0; public static final int withText = 0x7f0800d1;
public static final int wrap_content = 0x7f0800d9; public static final int wrap_content = 0x7f0800da;
} }
public static final class integer { public static final class integer {
public static final int abc_config_activityDefaultDur = 0x7f090000; public static final int abc_config_activityDefaultDur = 0x7f090000;

File diff suppressed because one or more lines are too long

View File

@ -490,81 +490,84 @@ int drawable guis_clock 0x7f070052
int drawable guis_goal 0x7f070053 int drawable guis_goal 0x7f070053
int drawable guis_lock_locked 0x7f070054 int drawable guis_lock_locked 0x7f070054
int drawable guis_magnet_field 0x7f070055 int drawable guis_magnet_field 0x7f070055
int drawable guis_pausebutton 0x7f070056 int drawable guis_music_off 0x7f070056
int drawable guis_playerarrow 0x7f070057 int drawable guis_music_on 0x7f070057
int drawable guis_radius 0x7f070058 int drawable guis_pausebutton 0x7f070058
int drawable guis_settings_disabled 0x7f070059 int drawable guis_playerarrow 0x7f070059
int drawable guis_settings_enabled 0x7f07005a int drawable guis_radius 0x7f07005a
int drawable guis_shape_shop_disabled 0x7f07005b int drawable guis_settings_disabled 0x7f07005b
int drawable guis_shape_shop_enabled 0x7f07005c int drawable guis_settings_enabled 0x7f07005c
int drawable guis_sound_off 0x7f07005d int drawable guis_shape_shop_disabled 0x7f07005d
int drawable guis_sound_on 0x7f07005e int drawable guis_shape_shop_enabled 0x7f07005e
int drawable guis_splitter 0x7f07005f int drawable guis_sound_off 0x7f07005f
int drawable guis_tick 0x7f070060 int drawable guis_sound_on 0x7f070060
int drawable guis_tool_shop_disabled 0x7f070061 int drawable guis_splitter 0x7f070061
int drawable guis_tool_shop_enabled 0x7f070062 int drawable guis_tick 0x7f070062
int drawable notification_template_icon_bg 0x7f070063 int drawable guis_tool_shop_disabled 0x7f070063
int drawable obstacles_grass 0x7f070064 int drawable guis_tool_shop_enabled 0x7f070064
int drawable obstacles_snow 0x7f070065 int drawable notification_template_icon_bg 0x7f070065
int drawable playershapes_ball 0x7f070066 int drawable obstacles_grass 0x7f070066
int drawable playershapes_clock 0x7f070067 int drawable obstacles_snow 0x7f070067
int drawable playershapes_hypno_spiral 0x7f070068 int drawable playershapes_ball 0x7f070068
int drawable playershapes_locked 0x7f070069 int drawable playershapes_clock 0x7f070069
int drawable playershapes_pacman 0x7f07006a int drawable playershapes_hypno_spiral 0x7f07006a
int drawable playershapes_smiley 0x7f07006b int drawable playershapes_locked 0x7f07006b
int drawable playershapes_sun 0x7f07006c int drawable playershapes_pacman 0x7f07006c
int drawable playershapes_wheel 0x7f07006d int drawable playershapes_smiley 0x7f07006d
int drawable terrain_c_grass 0x7f07006e int drawable playershapes_sun 0x7f07006e
int drawable terrain_c_ice 0x7f07006f int drawable playershapes_wheel 0x7f07006f
int drawable terrain_t_grass 0x7f070070 int drawable terrain_c_grass 0x7f070070
int drawable terrain_t_ice 0x7f070071 int drawable terrain_c_ice 0x7f070071
int drawable tools_bomb 0x7f070072 int drawable terrain_t_grass 0x7f070072
int drawable tools_bomb_button 0x7f070073 int drawable terrain_t_ice 0x7f070073
int drawable tools_button_empty 0x7f070074 int drawable tools_bomb 0x7f070074
int drawable tools_button_locked 0x7f070075 int drawable tools_bomb_button 0x7f070075
int drawable tools_button_unlocked 0x7f070076 int drawable tools_button_empty 0x7f070076
int drawable tools_magnet 0x7f070077 int drawable tools_button_locked 0x7f070077
int drawable tools_magnet_button 0x7f070078 int drawable tools_button_unlocked 0x7f070078
int drawable tools_power_mushroom 0x7f070079 int drawable tools_magnet 0x7f070079
int drawable tools_power_mushroom_button 0x7f07007a int drawable tools_magnet_button 0x7f07007a
int drawable tools_ramp 0x7f07007b int drawable tools_power_mushroom 0x7f07007b
int drawable tools_ramp_button 0x7f07007c int drawable tools_power_mushroom_button 0x7f07007c
int drawable tools_spring 0x7f07007d int drawable tools_ramp 0x7f07007d
int drawable tools_spring_button 0x7f07007e int drawable tools_ramp_button 0x7f07007e
int drawable tools_stasis 0x7f07007f int drawable tools_spring 0x7f07007f
int drawable tools_stasis_button 0x7f070080 int drawable tools_spring_button 0x7f070080
int drawable tutorial_place_ramp_air_1 0x7f070081 int drawable tools_stasis 0x7f070081
int drawable tutorial_place_ramp_air_2 0x7f070082 int drawable tools_stasis_button 0x7f070082
int drawable tutorial_place_ramp_gap 0x7f070083 int drawable tutorial_place_ramp_air_1 0x7f070083
int drawable tutorial_place_ramp_obstacle 0x7f070084 int drawable tutorial_place_ramp_air_2 0x7f070084
int drawable tutorial_place_tools 0x7f070085 int drawable tutorial_place_ramp_gap 0x7f070085
int drawable tutorial_switch_tools 0x7f070086 int drawable tutorial_place_ramp_obstacle 0x7f070086
int drawable tutorial_to_toolshop 0x7f070087 int drawable tutorial_place_tools 0x7f070087
int drawable tutorial_toolshop_all_tools 0x7f070088 int drawable tutorial_switch_tools 0x7f070088
int drawable tutorial_toolshop_equip_spring 0x7f070089 int drawable tutorial_to_toolshop 0x7f070089
int drawable tutorial_toolshop_inspector 0x7f07008a int drawable tutorial_toolshop_all_tools 0x7f07008a
int drawable tutorial_toolshop_select_buy_spring 0x7f07008b int drawable tutorial_toolshop_equip_spring 0x7f07008b
int drawable tutorial_toolshop_toolbar 0x7f07008c int drawable tutorial_toolshop_inspector 0x7f07008c
int drawable world_previews_grasslands 0x7f07008d int drawable tutorial_toolshop_select_buy_spring 0x7f07008d
int drawable world_previews_icymountains 0x7f07008e int drawable tutorial_toolshop_toolbar 0x7f07008e
int drawable xml_background_bountymessage 0x7f07008f int drawable world_previews_grasslands 0x7f07008f
int drawable xml_background_dialog_button 0x7f070090 int drawable world_previews_icymountains 0x7f070090
int drawable xml_background_exit_confirm_dialog 0x7f070091 int drawable xml_background_bountymessage 0x7f070091
int drawable xml_background_game_over_message_button 0x7f070092 int drawable xml_background_dialog_button 0x7f070092
int drawable xml_background_levelbutton 0x7f070093 int drawable xml_background_exit_confirm_dialog 0x7f070093
int drawable xml_background_toolslot 0x7f070094 int drawable xml_background_game_over_message_button 0x7f070094
int drawable xml_background_toolupgrade 0x7f070095 int drawable xml_background_levelbutton 0x7f070095
int drawable xml_background_tutorialimageview 0x7f070096 int drawable xml_background_toolslot 0x7f070096
int drawable xml_background_tutorialtextview 0x7f070097 int drawable xml_background_toolupgrade 0x7f070097
int drawable xml_background_worldbutton 0x7f070098 int drawable xml_background_tutorialimageview 0x7f070098
int drawable xml_layers_toolprogressbar 0x7f070099 int drawable xml_background_tutorialtextview 0x7f070099
int drawable xml_selector_gamebutton 0x7f07009a int drawable xml_background_worldbutton 0x7f07009a
int drawable xml_selector_pricebutton 0x7f07009b int drawable xml_layers_toolprogressbar 0x7f07009b
int drawable xml_selector_settingsbutton 0x7f07009c int drawable xml_selector_gamebutton 0x7f07009c
int drawable xml_selector_shapeshopbutton 0x7f07009d int drawable xml_selector_music 0x7f07009d
int drawable xml_selector_sound 0x7f07009e int drawable xml_selector_pricebutton 0x7f07009e
int drawable xml_selector_toolshopbutton 0x7f07009f int drawable xml_selector_settingsbutton 0x7f07009f
int drawable xml_shape_inspector_checkbox 0x7f0700a0 int drawable xml_selector_shapeshopbutton 0x7f0700a0
int drawable xml_selector_sound 0x7f0700a1
int drawable xml_selector_toolshopbutton 0x7f0700a2
int drawable xml_shape_inspector_checkbox 0x7f0700a3
int id action0 0x7f080000 int id action0 0x7f080000
int id action_bar 0x7f080001 int id action_bar 0x7f080001
int id action_bar_activity_content 0x7f080002 int id action_bar_activity_content 0x7f080002
@ -681,108 +684,109 @@ int id search_plate 0x7f080070
int id search_src_text 0x7f080071 int id search_src_text 0x7f080071
int id search_voice_btn 0x7f080072 int id search_voice_btn 0x7f080072
int id select_dialog_listview 0x7f080073 int id select_dialog_listview 0x7f080073
int id settings_reset 0x7f080074 int id settings_musictoggle 0x7f080074
int id settings_soundtoggle 0x7f080075 int id settings_reset 0x7f080075
int id settings_topbar 0x7f080076 int id settings_soundtoggle 0x7f080076
int id shape_button_button 0x7f080077 int id settings_topbar 0x7f080077
int id shape_button_textview 0x7f080078 int id shape_button_button 0x7f080078
int id shape_inspector_check_box 0x7f080079 int id shape_button_textview 0x7f080079
int id shape_inspector_check_box_image 0x7f08007a int id shape_inspector_check_box 0x7f08007a
int id shape_inspector_check_box_text 0x7f08007b int id shape_inspector_check_box_image 0x7f08007b
int id shape_inspector_description 0x7f08007c int id shape_inspector_check_box_text 0x7f08007c
int id shape_inspector_imageview 0x7f08007d int id shape_inspector_description 0x7f08007d
int id shape_inspector_title 0x7f08007e int id shape_inspector_imageview 0x7f08007e
int id shape_shop_bottomRow 0x7f08007f int id shape_inspector_title 0x7f08007f
int id shape_shop_shape_inspector 0x7f080080 int id shape_shop_bottomRow 0x7f080080
int id shape_shop_topRow 0x7f080081 int id shape_shop_shape_inspector 0x7f080081
int id shape_shop_topbar 0x7f080082 int id shape_shop_topRow 0x7f080082
int id shortcut 0x7f080083 int id shape_shop_topbar 0x7f080083
int id shortmenu_continue 0x7f080084 int id shortcut 0x7f080084
int id shortmenu_exit 0x7f080085 int id shortmenu_continue 0x7f080085
int id shortmenu_restart 0x7f080086 int id shortmenu_exit 0x7f080086
int id shortmenu_topbar 0x7f080087 int id shortmenu_restart 0x7f080087
int id showCustom 0x7f080088 int id shortmenu_topbar 0x7f080088
int id showHome 0x7f080089 int id showCustom 0x7f080089
int id showTitle 0x7f08008a int id showHome 0x7f08008a
int id spacer 0x7f08008b int id showTitle 0x7f08008b
int id split_action_bar 0x7f08008c int id spacer 0x7f08008c
int id src_atop 0x7f08008d int id split_action_bar 0x7f08008d
int id src_in 0x7f08008e int id src_atop 0x7f08008e
int id src_over 0x7f08008f int id src_in 0x7f08008f
int id startscreen_finish_world_1 0x7f080090 int id src_over 0x7f080090
int id startscreen_gain_90_ep 0x7f080091 int id startscreen_finish_world_1 0x7f080091
int id startscreen_play 0x7f080092 int id startscreen_gain_90_ep 0x7f080092
int id startscreen_settings 0x7f080093 int id startscreen_play 0x7f080093
int id startscreen_to_gl_test_screen 0x7f080094 int id startscreen_settings 0x7f080094
int id startscreen_unlock_levels 0x7f080095 int id startscreen_to_gl_test_screen 0x7f080095
int id status_bar_latest_event_content 0x7f080096 int id startscreen_unlock_levels 0x7f080096
int id submit_area 0x7f080097 int id status_bar_latest_event_content 0x7f080097
int id tabMode 0x7f080098 int id submit_area 0x7f080098
int id task_completed_unlock_list 0x7f080099 int id tabMode 0x7f080099
int id text 0x7f08009a int id task_completed_unlock_list 0x7f08009a
int id text2 0x7f08009b int id text 0x7f08009b
int id textSpacerNoButtons 0x7f08009c int id text2 0x7f08009c
int id time 0x7f08009d int id textSpacerNoButtons 0x7f08009d
int id title 0x7f08009e int id time 0x7f08009e
int id title_template 0x7f08009f int id title 0x7f08009f
int id tool_button_animation_layer 0x7f0800a0 int id title_template 0x7f0800a0
int id tool_button_background_layer 0x7f0800a1 int id tool_button_animation_layer 0x7f0800a1
int id tool_button_progress_bar 0x7f0800a2 int id tool_button_background_layer 0x7f0800a2
int id tool_inspector_description 0x7f0800a3 int id tool_button_progress_bar 0x7f0800a3
int id tool_inspector_imageview 0x7f0800a4 int id tool_inspector_description 0x7f0800a4
int id tool_inspector_level_view 0x7f0800a5 int id tool_inspector_imageview 0x7f0800a5
int id tool_inspector_pricebutton 0x7f0800a6 int id tool_inspector_level_view 0x7f0800a6
int id tool_inspector_title 0x7f0800a7 int id tool_inspector_pricebutton 0x7f0800a7
int id tool_upgrade_imageview 0x7f0800a8 int id tool_inspector_title 0x7f0800a8
int id tool_upgrade_pricebutton 0x7f0800a9 int id tool_upgrade_imageview 0x7f0800a9
int id tool_upgrade_title 0x7f0800aa int id tool_upgrade_pricebutton 0x7f0800aa
int id tool_upgrade_value_new 0x7f0800ab int id tool_upgrade_title 0x7f0800ab
int id tool_upgrade_value_old 0x7f0800ac int id tool_upgrade_value_new 0x7f0800ac
int id toolbutton_1 0x7f0800ad int id tool_upgrade_value_old 0x7f0800ad
int id toolbutton_2 0x7f0800ae int id toolbutton_1 0x7f0800ae
int id toolbutton_3 0x7f0800af int id toolbutton_2 0x7f0800af
int id toolbutton_4 0x7f0800b0 int id toolbutton_3 0x7f0800b0
int id toolofferslot_slot 0x7f0800b1 int id toolbutton_4 0x7f0800b1
int id toolofferslot_title 0x7f0800b2 int id toolofferslot_slot 0x7f0800b2
int id toolshop_slot1 0x7f0800b3 int id toolofferslot_title 0x7f0800b3
int id toolshop_slot2 0x7f0800b4 int id toolshop_slot1 0x7f0800b4
int id toolshop_slot3 0x7f0800b5 int id toolshop_slot2 0x7f0800b5
int id toolshop_slot4 0x7f0800b6 int id toolshop_slot3 0x7f0800b6
int id toolshop_tool_offer_bottom_row 0x7f0800b7 int id toolshop_slot4 0x7f0800b7
int id toolshop_tool_offer_top_row 0x7f0800b8 int id toolshop_tool_offer_bottom_row 0x7f0800b8
int id toolshop_toolinspector 0x7f0800b9 int id toolshop_tool_offer_top_row 0x7f0800b9
int id toolshop_topbar 0x7f0800ba int id toolshop_toolinspector 0x7f0800ba
int id toolslot_image 0x7f0800bb int id toolshop_topbar 0x7f0800bb
int id topPanel 0x7f0800bc int id toolslot_image 0x7f0800bc
int id topbar_energycount 0x7f0800bd int id topPanel 0x7f0800bd
int id topbar_energycount_decrease 0x7f0800be int id topbar_energycount 0x7f0800be
int id topbar_energyview 0x7f0800bf int id topbar_energycount_decrease 0x7f0800bf
int id topbar_layout 0x7f0800c0 int id topbar_energyview 0x7f0800c0
int id topbar_leveldisplay 0x7f0800c1 int id topbar_layout 0x7f0800c1
int id topbar_levellayout 0x7f0800c2 int id topbar_leveldisplay 0x7f0800c2
int id topbar_levelprogress 0x7f0800c3 int id topbar_levellayout 0x7f0800c3
int id topbar_settings 0x7f0800c4 int id topbar_levelprogress 0x7f0800c4
int id topbar_shapeshop 0x7f0800c5 int id topbar_settings 0x7f0800c5
int id topbar_starcount 0x7f0800c6 int id topbar_shapeshop 0x7f0800c6
int id topbar_starcount_decrease 0x7f0800c7 int id topbar_starcount 0x7f0800c7
int id topbar_starview 0x7f0800c8 int id topbar_starcount_decrease 0x7f0800c8
int id topbar_toolshop 0x7f0800c9 int id topbar_starview 0x7f0800c9
int id tutorial_image_view 0x7f0800ca int id topbar_toolshop 0x7f0800ca
int id tutorial_text_view 0x7f0800cb int id tutorial_image_view 0x7f0800cb
int id unlockmessage_message 0x7f0800cc int id tutorial_text_view 0x7f0800cc
int id unlockmessage_toolimage 0x7f0800cd int id unlockmessage_message 0x7f0800cd
int id up 0x7f0800ce int id unlockmessage_toolimage 0x7f0800ce
int id useLogo 0x7f0800cf int id up 0x7f0800cf
int id withText 0x7f0800d0 int id useLogo 0x7f0800d0
int id worldbutton_energycount 0x7f0800d1 int id withText 0x7f0800d1
int id worldbutton_levelcount 0x7f0800d2 int id worldbutton_energycount 0x7f0800d2
int id worldbutton_lock 0x7f0800d3 int id worldbutton_levelcount 0x7f0800d3
int id worldbutton_preview 0x7f0800d4 int id worldbutton_lock 0x7f0800d4
int id worldbutton_starcount 0x7f0800d5 int id worldbutton_preview 0x7f0800d5
int id worldbutton_title 0x7f0800d6 int id worldbutton_starcount 0x7f0800d6
int id worlds_layout 0x7f0800d7 int id worldbutton_title 0x7f0800d7
int id worlds_topbar 0x7f0800d8 int id worlds_layout 0x7f0800d8
int id wrap_content 0x7f0800d9 int id worlds_topbar 0x7f0800d9
int id wrap_content 0x7f0800da
int integer abc_config_activityDefaultDur 0x7f090000 int integer abc_config_activityDefaultDur 0x7f090000
int integer abc_config_activityShortDur 0x7f090001 int integer abc_config_activityShortDur 0x7f090001
int integer abc_max_action_buttons 0x7f090002 int integer abc_max_action_buttons 0x7f090002
@ -859,7 +863,18 @@ int layout worlds 0x7f0a0043
int mipmap ic_launcher 0x7f0b0000 int mipmap ic_launcher 0x7f0b0000
int raw music_game 0x7f0c0000 int raw music_game 0x7f0c0000
int raw music_menu 0x7f0c0001 int raw music_menu 0x7f0c0001
int raw ramp 0x7f0c0002 int raw sound_collect_energy 0x7f0c0002
int raw sound_collect_star 0x7f0c0003
int raw sound_countdown 0x7f0c0004
int raw sound_die 0x7f0c0005
int raw sound_explosion 0x7f0c0006
int raw sound_firework 0x7f0c0007
int raw sound_goal 0x7f0c0008
int raw sound_magnet 0x7f0c0009
int raw sound_mushroom 0x7f0c000a
int raw sound_place_tool 0x7f0c000b
int raw sound_spring 0x7f0c000c
int raw sound_stasis 0x7f0c000d
int string abc_action_bar_home_description 0x7f0d0000 int string abc_action_bar_home_description 0x7f0d0000
int string abc_action_bar_home_description_format 0x7f0d0001 int string abc_action_bar_home_description_format 0x7f0d0001
int string abc_action_bar_home_subtitle_description_format 0x7f0d0002 int string abc_action_bar_home_subtitle_description_format 0x7f0d0002

View File

@ -435,5 +435,18 @@
</stars> </stars>
<energy x="18.570074" y="0.46666658"/> <energy x="18.570074" y="0.46666658"/>
</level> </level>
<level packId="2" id="7" goalX="3.0" startSpeed="0.5" endSpeed="0.5" terrainEdge="-0.6" ceilingEdge="1.0">
<terrainTiles class="java.util.ArrayList">
<tileData x="0.0" width="6.0"/>
</terrainTiles>
<ceilingTiles class="java.util.ArrayList">
<tileData x="0.0" width="6.0"/>
</ceilingTiles>
<obstacles class="java.util.ArrayList"/>
<stars class="java.util.ArrayList">
<positionData x="0.3066666" y="-0.37999997"/>
</stars>
<energy x="1.9466664" y="-0.3933333"/>
</level>
</levels> </levels>
</levelPack> </levelPack>

View File

@ -8,28 +8,46 @@ import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.entities.particles.ParticleSource; import de.frajul.endlessroll.entities.particles.ParticleSource;
import de.frajul.endlessroll.entities.particles.ParticleSystem; import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.main.game.Timer; import de.frajul.endlessroll.main.game.Timer;
import de.frajul.endlessroll.sounds.SoundManager;
import de.frajul.endlessroll.sounds.SoundStream;
/** /**
* Created by Julian on 11.02.2016. * Created by Julian on 11.02.2016.
*/ */
public class Magnet extends Tool { public class Magnet extends Tool {
private SoundManager soundManager;
private ParticleSource particleSource; private ParticleSource particleSource;
private SoundStream soundStream;
public Magnet(Vector position, ParticleSystem particleSystem) { public Magnet(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
super(ToolType.MAGNET, position, .24f, .24f, false, false); super(ToolType.MAGNET, position, .24f, .24f, false, false);
this.soundManager = soundManager;
animation.setRequiredDelta(300); animation.setRequiredDelta(300);
animation.setIndexSequence(new int[]{1, 1, 0}); animation.setIndexSequence(new int[]{1, 1, 0});
animation.setLooping(true); animation.setLooping(true);
super.setFloating(true); super.setFloating(true);
particleSource = new ParticleSource(new Vector(position), particleSystem.magnet); particleSource = new ParticleSource(new Vector(position), particleSystem.magnet);
particleSource.start(); particleSource.start();
soundStream = soundManager.playSound(soundManager.magnetSound);
} }
@Override @Override
public void destroy(DestroyEffect destroyEffect) { public void destroy(DestroyEffect destroyEffect) {
super.destroy(destroyEffect); super.destroy(destroyEffect);
particleSource.kill(); particleSource.kill();
soundManager.stopSound(soundStream);
}
public void updateSoundVolume(Player player) {
float distanceToPlayer = super.getPosition().vectorTo(player.getPosition()).length();
float factor = 1.0f / (distanceToPlayer * distanceToPlayer);
if (distanceToPlayer > 2 && player.getPosition().getX() > super.getPosition().getX()) {
soundManager.stopSound(soundStream);
return;
}
soundStream.setCurrentVolumeModifier(factor);
soundManager.onStreamVolumeChanged(soundStream);
} }
@Override @Override

View File

@ -5,6 +5,8 @@ import de.frajul.endlessroll.entities.DestroyEffect;
import de.frajul.endlessroll.entities.Player; import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collision.geometry.Geometry; import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.main.game.Timer; import de.frajul.endlessroll.main.game.Timer;
import de.frajul.endlessroll.sounds.Sound;
import de.frajul.endlessroll.sounds.SoundManager;
/** /**
* Created by Julian on 02.10.2017. * Created by Julian on 02.10.2017.
@ -12,14 +14,18 @@ import de.frajul.endlessroll.main.game.Timer;
public class PowerMushroom extends Tool { public class PowerMushroom extends Tool {
public PowerMushroom(Vector position) { private SoundManager soundManager;
public PowerMushroom(Vector position, SoundManager soundManager) {
super(ToolType.POWER_MUSHROOM, position, .35f, .3f, true, true); super(ToolType.POWER_MUSHROOM, position, .35f, .3f, true, true);
animation.disable(); animation.disable();
this.soundManager = soundManager;
} }
@Override @Override
public void onPlayerCollision(Player player, Timer timer) { public void onPlayerCollision(Player player, Timer timer) {
player.startSuperPower((long) ToolType.POWER_MUSHROOM.getCurrentUpgradeValue(ToolUpgradeType.DURATION)); player.startSuperPower((long) ToolType.POWER_MUSHROOM.getCurrentUpgradeValue(ToolUpgradeType.DURATION));
soundManager.playSound(soundManager.mushroomSound);
super.destroy(DestroyEffect.ENERGY_COLLECT); super.destroy(DestroyEffect.ENERGY_COLLECT);
} }

View File

@ -5,6 +5,7 @@ import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collision.geometry.Geometry; import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.entities.collision.geometry.Quad; import de.frajul.endlessroll.entities.collision.geometry.Quad;
import de.frajul.endlessroll.main.game.Timer; import de.frajul.endlessroll.main.game.Timer;
import de.frajul.endlessroll.sounds.SoundManager;
/** /**
* Created by Julian on 04.01.2016. * Created by Julian on 04.01.2016.
@ -12,11 +13,13 @@ import de.frajul.endlessroll.main.game.Timer;
public class Spring extends Tool { public class Spring extends Tool {
private boolean hasYetCollided = false; private boolean hasYetCollided = false;
private SoundManager soundManager;
public Spring(Vector position) { public Spring(Vector position, SoundManager soundManager) {
super(ToolType.SPRING, position, .3f, .35f, true, true); super(ToolType.SPRING, position, .3f, .35f, true, true);
animation.setIndexSequence(new int[]{1, 0, 0, 3, 3, 3, 1}); animation.setIndexSequence(new int[]{1, 0, 0, 3, 3, 3, 1});
animation.setRequiredDelta(80); animation.setRequiredDelta(80);
this.soundManager = soundManager;
} }
@Override @Override
@ -29,6 +32,7 @@ public class Spring extends Tool {
public void onPlayerCollision(Player player, Timer timer) { public void onPlayerCollision(Player player, Timer timer) {
if (!hasYetCollided) { if (!hasYetCollided) {
hasYetCollided = true; hasYetCollided = true;
soundManager.playSound(soundManager.springSound);
player.clearAllForces(); player.clearAllForces();
player.getMovement().setY(0); player.getMovement().setY(0);

View File

@ -6,25 +6,30 @@ import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collision.geometry.Geometry; import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.entities.particles.ParticleSource; import de.frajul.endlessroll.entities.particles.ParticleSource;
import de.frajul.endlessroll.entities.particles.ParticleSystem; import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.main.game.GameScene;
import de.frajul.endlessroll.main.game.Timer; import de.frajul.endlessroll.main.game.Timer;
import de.frajul.endlessroll.sounds.SoundManager;
import de.frajul.endlessroll.sounds.SoundStream;
/** /**
* Created by Julian on 11.02.2016. * Created by Julian on 11.02.2016.
*/ */
public class Stasis extends Tool { public class Stasis extends Tool {
private SoundManager soundManager;
private ParticleSource particleSource; private ParticleSource particleSource;
private boolean firstCollision = true; private boolean firstCollision = true;
private final static float Y_SLOW_FACTOR = .4f; //Final .2f private final static float Y_SLOW_FACTOR = .4f; //Final .2f
private final static float X_SLOW_FACTOR = .9f; //Final .8f private final static float X_SLOW_FACTOR = .9f; //Final .8f
private float forceValue; private float forceValue;
public Stasis(Vector position, ParticleSystem particleSystem) { private SoundStream soundStream;
public Stasis(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
super(ToolType.STASIS, position, super(ToolType.STASIS, position,
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, .7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100,
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false, .7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false,
false); false);
this.soundManager = soundManager;
animation.setLooping(true); animation.setLooping(true);
animation.setRequiredDelta(300); animation.setRequiredDelta(300);
animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3}); animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3});
@ -33,12 +38,31 @@ public class Stasis extends Tool {
particleSource.setSpawnSize(new Vector(super.width, super.height)); particleSource.setSpawnSize(new Vector(super.width, super.height));
particleSource.start(); particleSource.start();
forceValue = ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.FORCE); forceValue = ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.FORCE);
soundStream = soundManager.playSound(soundManager.stasisSound);
}
public void updateSoundVolume(Player player) {
float distanceToPlayer = super.getPosition().getX() - player.getPosition().getX();
boolean playerInXRange = (player.getRightEdge() >= super.getLeftEdge() && player
.getRightEdge() <= super.getRightEdge()) || (player.getLeftEdge() >= super
.getLeftEdge() && player.getLeftEdge() <= super.getRightEdge());
float factor = 1.0f;
if (!playerInXRange) {
factor = 1.0f / (distanceToPlayer * distanceToPlayer);
if (distanceToPlayer < -2) {
soundManager.stopSound(soundStream);
return;
}
}
soundStream.setCurrentVolumeModifier(factor);
soundManager.onStreamVolumeChanged(soundStream);
} }
@Override @Override
public void destroy(DestroyEffect destroyEffect) { public void destroy(DestroyEffect destroyEffect) {
super.destroy(destroyEffect); super.destroy(destroyEffect);
particleSource.kill(); particleSource.kill();
soundManager.stopSound(soundStream);
} }
@Override @Override

View File

@ -11,32 +11,33 @@ import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.particles.ParticleSystem; import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.textures.Texture; import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack; import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.sounds.Sound;
import de.frajul.endlessroll.sounds.SoundManager; import de.frajul.endlessroll.sounds.SoundManager;
public enum ToolType { public enum ToolType {
//Check newInstance when new Tool is added! //Check newInstance when new Tool is added!
RAMP(R.string.tool_name_ramp, R.string.tool_description_ramp, R.drawable.tools_ramp, RAMP(R.string.tool_name_ramp, R.string.tool_description_ramp, R.drawable.tools_ramp,
R.drawable.tools_ramp_button, R.raw.ramp, 0, 1, 5, R.drawable.tools_ramp_button, 0, 1, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 3000, 1000)), new ToolUpgrade(ToolUpgradeType.COOLDOWN, 3000, 1000)),
SPRING(R.string.tool_name_spring, R.string.tool_description_spring, R.drawable.tools_spring, SPRING(R.string.tool_name_spring, R.string.tool_description_spring, R.drawable.tools_spring,
R.drawable.tools_spring_button, R.raw.ramp, 5, 2, 5, R.drawable.tools_spring_button, 5, 2, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 4000, 2000)), new ToolUpgrade(ToolUpgradeType.COOLDOWN, 4000, 2000)),
BOMB(R.string.tool_name_bomb, R.string.tool_description_bomb, R.drawable.tools_bomb, BOMB(R.string.tool_name_bomb, R.string.tool_description_bomb, R.drawable.tools_bomb,
R.drawable.tools_bomb_button, R.raw.ramp, 12, 4, 5, R.drawable.tools_bomb_button, 12, 4, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000), new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000),
new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 400), new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 400),
new ToolUpgrade(ToolUpgradeType.RANGE, 100, 200)), new ToolUpgrade(ToolUpgradeType.RANGE, 100, 200)),
MAGNET(R.string.tool_name_magnet, R.string.tool_description_magnet, R.drawable.tools_magnet, MAGNET(R.string.tool_name_magnet, R.string.tool_description_magnet, R.drawable.tools_magnet,
R.drawable.tools_magnet_button, R.raw.ramp, 10, 2, 5, R.drawable.tools_magnet_button, 10, 2, 5,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 3000), new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 3000),
new ToolUpgrade(ToolUpgradeType.FORCE, 100, 500)), new ToolUpgrade(ToolUpgradeType.FORCE, 100, 500)),
POWER_MUSHROOM(R.string.tool_name_power_mushroom, R.string.tool_description_power_mushroom, POWER_MUSHROOM(R.string.tool_name_power_mushroom, R.string.tool_description_power_mushroom,
R.drawable.tools_power_mushroom, R.drawable.tools_power_mushroom_button, R.raw.ramp, 5, R.drawable.tools_power_mushroom, R.drawable.tools_power_mushroom_button, 5,
5, 7, new ToolUpgrade(ToolUpgradeType.COOLDOWN, 15000, 11000), 5, 7, new ToolUpgrade(ToolUpgradeType.COOLDOWN, 15000, 11000),
new ToolUpgrade(ToolUpgradeType.DURATION, 5000, 10000)), new ToolUpgrade(ToolUpgradeType.DURATION, 5000, 10000)),
STASIS(R.string.tool_name_stasis, R.string.tool_description_stasis, R.drawable.tools_stasis, STASIS(R.string.tool_name_stasis, R.string.tool_description_stasis, R.drawable.tools_stasis,
R.drawable.tools_stasis_button, R.raw.ramp, 15, 4, 6, R.drawable.tools_stasis_button, 15, 4, 6,
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000), new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000),
new ToolUpgrade(ToolUpgradeType.FORCE, 1, 2), new ToolUpgrade(ToolUpgradeType.FORCE, 1, 2),
new ToolUpgrade(ToolUpgradeType.SIZE, 100, 200)); new ToolUpgrade(ToolUpgradeType.SIZE, 100, 200));
@ -47,23 +48,20 @@ public enum ToolType {
private final int description; private final int description;
private final int toolTextureId; private final int toolTextureId;
private final int buttonDrawable; private final int buttonDrawable;
private final int placingSoundId;
private final int buyPrice; private final int buyPrice;
private final int upgradePrice; private final int upgradePrice;
private final int maxUpgradeLevel; private final int maxUpgradeLevel;
private final List<ToolUpgrade> upgrades; private final List<ToolUpgrade> upgrades;
private Texture toolTexture = null; private Texture toolTexture = null;
private int placingSound = -1;
private boolean bought; private boolean bought;
private int currentUpgradeLevel = 1; private int currentUpgradeLevel = 1;
ToolType(@StringRes int name, @StringRes int description, int toolTextureId, int buttonDrawable, int placingSoundId, int buyPrice, int upgradePrice, int maxUpgradeLevel, ToolUpgrade... upgrades) { ToolType(@StringRes int name, @StringRes int description, int toolTextureId, int buttonDrawable, int buyPrice, int upgradePrice, int maxUpgradeLevel, ToolUpgrade... upgrades) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.toolTextureId = toolTextureId; this.toolTextureId = toolTextureId;
this.buttonDrawable = buttonDrawable; this.buttonDrawable = buttonDrawable;
this.placingSoundId = placingSoundId;
this.buyPrice = buyPrice; this.buyPrice = buyPrice;
this.upgradePrice = upgradePrice; this.upgradePrice = upgradePrice;
this.maxUpgradeLevel = maxUpgradeLevel; this.maxUpgradeLevel = maxUpgradeLevel;
@ -71,26 +69,26 @@ public enum ToolType {
} }
@Nullable @Nullable
public Tool newInstance(Vector position, ParticleSystem particleSystem) { public Tool newInstance(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
Tool tool = null; Tool tool = null;
switch (this) { switch (this) {
case RAMP: case RAMP:
tool = new Ramp(position); tool = new Ramp(position);
break; break;
case SPRING: case SPRING:
tool = new Spring(position); tool = new Spring(position, soundManager);
break; break;
case MAGNET: case MAGNET:
tool = new Magnet(position, particleSystem); tool = new Magnet(position, particleSystem, soundManager);
break; break;
case BOMB: case BOMB:
tool = new Bomb(position); tool = new Bomb(position);
break; break;
case POWER_MUSHROOM: case POWER_MUSHROOM:
tool = new PowerMushroom(position); tool = new PowerMushroom(position, soundManager);
break; break;
case STASIS: case STASIS:
tool = new Stasis(position,particleSystem); tool = new Stasis(position, particleSystem, soundManager);
break; break;
} }
if (tool != null && tool.isPlacedByRightEdge()) if (tool != null && tool.isPlacedByRightEdge())
@ -98,22 +96,11 @@ public enum ToolType {
return tool; return tool;
} }
public static void loadAllPlacingSounds(SoundManager soundManager) {
for (ToolType type : values())
type.loadPlacingSound(soundManager);
}
public static void loadAllToolTextures(TexturePack texturePack) { public static void loadAllToolTextures(TexturePack texturePack) {
for (ToolType type : values()) for (ToolType type : values())
type.loadToolTexture(texturePack); type.loadToolTexture(texturePack);
} }
private void loadPlacingSound(SoundManager soundManager) {
if (placingSoundId == -1)
return;
placingSound = soundManager.loadSound(placingSoundId);
}
private void loadToolTexture(TexturePack texturePack) { private void loadToolTexture(TexturePack texturePack) {
if (toolTextureId == -1) if (toolTextureId == -1)
return; return;
@ -131,10 +118,6 @@ public enum ToolType {
return buttonDrawable; return buttonDrawable;
} }
public int getPlacingSound() {
return placingSound;
}
@StringRes @StringRes
public int getName() { public int getName() {
return name; return name;

View File

@ -16,7 +16,8 @@ import de.frajul.endlessroll.user.User;
public class DataStorageHandler { public class DataStorageHandler {
private final String PREFERENCES_NAME = "GamePreferences"; private final String PREFERENCES_NAME = "GamePreferences";
private final String SOUND_ON = "Sound"; private final String SOUNDS_MUTED = "SoundsMuted";
private final String MUSIC_MUTED = "MusicMuted";
private final String USER_EP = "EP"; private final String USER_EP = "EP";
private final String USER_LEVEL = "Level"; private final String USER_LEVEL = "Level";
private final String USER_STARS = "Stars"; private final String USER_STARS = "Stars";
@ -37,13 +38,23 @@ public class DataStorageHandler {
database = new MyDatabase(activity); database = new MyDatabase(activity);
} }
public boolean readIsSoundOn() { public boolean readIsSoundsMuted() {
return preferences.getBoolean(SOUND_ON, false); return preferences.getBoolean(SOUNDS_MUTED, false);
} }
public void writeSoundOn(boolean soundOn) { public void writeSoundsMuted(boolean soundsMuted) {
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(SOUND_ON, soundOn); editor.putBoolean(SOUNDS_MUTED, soundsMuted);
editor.apply();
}
public boolean readIsMusicMuted() {
return preferences.getBoolean(MUSIC_MUTED, false);
}
public void writeMusicMuted(boolean musicMuted) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(MUSIC_MUTED, musicMuted);
editor.apply(); editor.apply();
} }

View File

@ -91,7 +91,8 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
user = dataStorageHandler.readUserData(this); user = dataStorageHandler.readUserData(this);
soundManager = new SoundManager(this); soundManager = new SoundManager(this);
soundManager.setSoundOn(dataStorageHandler.readIsSoundOn()); soundManager.setSoundsMuted(dataStorageHandler.readIsSoundsMuted());
soundManager.setMusicMuted(dataStorageHandler.readIsMusicMuted());
levelManager = new LevelManager(this, dataStorageHandler); levelManager = new LevelManager(this, dataStorageHandler);
tutorialManager = new TutorialManager(this); tutorialManager = new TutorialManager(this);
@ -138,7 +139,7 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
} }
public void flipToScreen(final Screen.ScreenType screen) { public void flipToScreen(final Screen.ScreenType screen) {
if (screen != Screen.ScreenType.NONE) { if (screen != Screen.ScreenType.NONE && flipper.getCurrentScreen().getType() != screen) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -271,7 +272,7 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
glSurfaceView.onPause(); glSurfaceView.onPause();
if (flipper.getCurrentScreen() == gameScreen) if (flipper.getCurrentScreen() == gameScreen)
gameScreen.onPause(); gameScreen.onPause();
soundManager.pause(); soundManager.activityPause();
super.onPause(); super.onPause();
} }
@ -279,7 +280,7 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
protected void onResume() { protected void onResume() {
GameLog.d("OnResume"); GameLog.d("OnResume");
glSurfaceView.onResume(); glSurfaceView.onResume();
soundManager.resume(); soundManager.activityResume();
super.onResume(); super.onResume();
} }
@ -288,7 +289,6 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
GameLog.d("OnDestroy"); GameLog.d("OnDestroy");
soundManager.destroy(); soundManager.destroy();
dataStorageHandler.writeSoundOn(soundManager.isSoundOn());
super.onDestroy(); super.onDestroy();
} }

View File

@ -68,7 +68,7 @@ public class Game extends Rendering<GameScene> {
this.timer = timer; this.timer = timer;
try { try {
if (isFirstTime) { if (isFirstTime) {
scene = new GameScene(texturePack, particleSystem); scene = new GameScene(gameActivity, texturePack, particleSystem);
firework = new Firework(particleSystem.firework, scene.getCamera()); firework = new Firework(particleSystem.firework, scene.getCamera());
if (level != null) if (level != null)
startGame(levelPack, level); startGame(levelPack, level);
@ -88,6 +88,7 @@ public class Game extends Rendering<GameScene> {
this.level = level; this.level = level;
this.levelPack = levelPack; this.levelPack = levelPack;
if (scene != null) { if (scene != null) {
gameActivity.getSoundManager().gameMusic.reset();
gameState = GameState.COUNTDOWN; gameState = GameState.COUNTDOWN;
gameActivity.getTutorialManager().resetGameTutorials(); gameActivity.getTutorialManager().resetGameTutorials();
collectedStars.clear(); collectedStars.clear();
@ -106,8 +107,8 @@ public class Game extends Rendering<GameScene> {
} }
public void countdownFinished() { public void countdownFinished() {
GameLog.i("Start music"); gameActivity.getSoundManager().resumeAllSounds();
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().gameMusic); gameActivity.getSoundManager().gameMusic.start();
gameState = GameState.RUNNING; gameState = GameState.RUNNING;
} }
@ -205,6 +206,7 @@ public class Game extends Rendering<GameScene> {
public void tryToPause() { public void tryToPause() {
if (gameState == GameState.GAME_OVER || gameState == GameState.LEVEL_FINISHED || gameState == GameState.PAUSED) if (gameState == GameState.GAME_OVER || gameState == GameState.LEVEL_FINISHED || gameState == GameState.PAUSED)
return; return;
gameActivity.getSoundManager().pauseAllSounds();
gameActivity.getSoundManager().gameMusic.pause(); gameActivity.getSoundManager().gameMusic.pause();
viewManager.showShortMenu(); viewManager.showShortMenu();
if (gameState == GameState.COUNTDOWN) if (gameState == GameState.COUNTDOWN)
@ -222,7 +224,7 @@ public class Game extends Rendering<GameScene> {
private void addTool(float x, float y) { private void addTool(float x, float y) {
try { try {
gameActivity.getSoundManager().playSound(currentTool.getPlacingSound()); gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().placeToolSound);
scene.addTool(currentTool, x, y, physics); scene.addTool(currentTool, x, y, physics);
} catch (Exception e) { } catch (Exception e) {
onException(e); onException(e);
@ -230,8 +232,9 @@ public class Game extends Rendering<GameScene> {
} }
public void onGameOver(boolean playerExplode) { public void onGameOver(boolean playerExplode) {
gameActivity.getSoundManager().gameMusic.pause(); gameActivity.getSoundManager().gameMusic.stop();
//TODO: Die sound gameActivity.getSoundManager().stopAllSounds();
gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().dieSound);
if (playerExplode) { if (playerExplode) {
scene.getUncategorizedEntities().remove(player); scene.getUncategorizedEntities().remove(player);
DestroyEffect.EXPLOSION.createEffect(particleSystem, player.getPosition(), DestroyEffect.EXPLOSION.createEffect(particleSystem, player.getPosition(),
@ -242,8 +245,9 @@ public class Game extends Rendering<GameScene> {
} }
private void onGoalReached() { private void onGoalReached() {
gameActivity.getSoundManager().gameMusic.pause(); gameActivity.getSoundManager().gameMusic.stop();
//TODO: Goal + firework sound gameActivity.getSoundManager().stopAllSounds();
gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().goalSound);
gameState = GameState.LEVEL_FINISHED; gameState = GameState.LEVEL_FINISHED;
if (!level.isFinished()) if (!level.isFinished())
@ -263,6 +267,7 @@ public class Game extends Rendering<GameScene> {
} }
firework.start(); firework.start();
gameActivity.getSoundManager().playSound(gameActivity.getSoundManager().fireworkSound);
//viewManager.showGameOverMessage(levelPack.isLastLevel(level), MessageType.WIN); //viewManager.showGameOverMessage(levelPack.isLastLevel(level), MessageType.WIN);
//TODO: fadeInWithDelay something //TODO: fadeInWithDelay something
@ -290,13 +295,21 @@ public class Game extends Rendering<GameScene> {
} }
public void onStarCollision(Star star) { public void onStarCollision(Star star) {
scene.onStarCollision(star); if (!star.isDestroyed()) {
collectedStars.add(star.getIndex()); scene.onStarCollision(star);
gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().collectStarSound);
collectedStars.add(star.getIndex());
}
} }
public void onEnergyCollision(Energy energy) { public void onEnergyCollision(Energy energy) {
scene.onEnergyCollision(energy); if (!energy.isDestroyed()) {
energyCollected = true; scene.onEnergyCollision(energy);
gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().collectEnergySound);
energyCollected = true;
}
} }
@Override @Override

View File

@ -12,12 +12,14 @@ import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.shapes.PlayerShape; import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.textures.TexturePack; import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.entities.tools.Bomb; import de.frajul.endlessroll.entities.tools.Bomb;
import de.frajul.endlessroll.entities.tools.Magnet;
import de.frajul.endlessroll.entities.tools.Stasis; import de.frajul.endlessroll.entities.tools.Stasis;
import de.frajul.endlessroll.entities.tools.Tool; import de.frajul.endlessroll.entities.tools.Tool;
import de.frajul.endlessroll.entities.tools.ToolType; import de.frajul.endlessroll.entities.tools.ToolType;
import de.frajul.endlessroll.levels.Level; import de.frajul.endlessroll.levels.Level;
import de.frajul.endlessroll.levels.ObstacleData; import de.frajul.endlessroll.levels.ObstacleData;
import de.frajul.endlessroll.levels.worlds.World; import de.frajul.endlessroll.levels.worlds.World;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog; import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.main.physics.Physics; import de.frajul.endlessroll.main.physics.Physics;
@ -26,13 +28,15 @@ import de.frajul.endlessroll.main.physics.Physics;
*/ */
public class GameScene extends Scene { public class GameScene extends Scene {
private GameActivity gameActivity;
private World currentWorld; private World currentWorld;
private CollisionDetector collisionDetector; private CollisionDetector collisionDetector;
private Goal goal; private Goal goal;
private float goalX; private float goalX;
public GameScene(TexturePack texturePack, ParticleSystem particleSystem) throws Exception { public GameScene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) throws Exception {
super(texturePack, particleSystem); super(gameActivity, texturePack, particleSystem);
this.gameActivity = gameActivity;
collisionDetector = new CollisionDetector(); collisionDetector = new CollisionDetector();
goal = new Goal(textures.goal); goal = new Goal(textures.goal);
@ -45,8 +49,8 @@ public class GameScene extends Scene {
terrain.loadData(world, level.getTerrainEdge(), level.getTerrainTiles()); terrain.loadData(world, level.getTerrainEdge(), level.getTerrainTiles());
ceiling.loadData(world, level.getCeilingEdge(), level.getCeilingTiles()); ceiling.loadData(world, level.getCeilingEdge(), level.getCeilingTiles());
uncategorizedEntities.add(goal); uncategorizedEntities.add(goal);
player.init(playerShape, terrain.getEdge(), level.getStartSpeed(), player.init(playerShape, terrain.getEdge(), level.getStartSpeed(), level.getEndSpeed(),
level.getEndSpeed(), particleSystem); particleSystem);
uncategorizedEntities.add(player); uncategorizedEntities.add(player);
collectables.init(level, textures); collectables.init(level, textures);
for (ObstacleData data : level.getObstacles()) for (ObstacleData data : level.getObstacles())
@ -55,10 +59,10 @@ public class GameScene extends Scene {
goalX = level.getGoalX(); goalX = level.getGoalX();
goal.setGoalX(goalX); goal.setGoalX(goalX);
if(world == World.ICY_MOUNTAINS){ if (world == World.ICY_MOUNTAINS) {
enviromentParticles = new ParticleSource(new Vector(), particleSystem.snow); enviromentParticles = new ParticleSource(new Vector(), particleSystem.snow);
enviromentParticles.start(); enviromentParticles.start();
}else if(enviromentParticles != null){ } else if (enviromentParticles != null) {
enviromentParticles.kill(); enviromentParticles.kill();
} }
GameLog.d("Level " + level.getId() + " successfully loaded"); GameLog.d("Level " + level.getId() + " successfully loaded");
@ -79,7 +83,7 @@ public class GameScene extends Scene {
public void addTool(ToolType type, float screenX, float screenY, Physics physics) throws Exception { public void addTool(ToolType type, float screenX, float screenY, Physics physics) throws Exception {
Vector position = calcWorldFromScreenCoords(screenX, screenY); Vector position = calcWorldFromScreenCoords(screenX, screenY);
Tool tool = type.newInstance(position, particleSystem); Tool tool = type.newInstance(position, particleSystem, gameActivity.getSoundManager());
physics.checkSingleToolCollision(tool, this); physics.checkSingleToolCollision(tool, this);
if (tool == null) if (tool == null)
@ -123,6 +127,13 @@ public class GameScene extends Scene {
if (bomb.isExploding()) if (bomb.isExploding())
bomb.explode(obstacles, collisionDetector); bomb.explode(obstacles, collisionDetector);
} }
else if (tool instanceof Stasis) {
Stasis stasis = (Stasis) tool;
stasis.updateSoundVolume(player);
} else if(tool instanceof Magnet){
Magnet magnet = (Magnet) tool;
magnet.updateSoundVolume(player);
}
} }
} }

View File

@ -8,6 +8,7 @@ import java.util.List;
import de.frajul.endlessroll.data.Vector; import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.AnimatedEntity; import de.frajul.endlessroll.entities.AnimatedEntity;
import de.frajul.endlessroll.entities.Background; import de.frajul.endlessroll.entities.Background;
import de.frajul.endlessroll.entities.DestroyEffect;
import de.frajul.endlessroll.entities.Entity; import de.frajul.endlessroll.entities.Entity;
import de.frajul.endlessroll.entities.Obstacle; import de.frajul.endlessroll.entities.Obstacle;
import de.frajul.endlessroll.entities.Player; import de.frajul.endlessroll.entities.Player;
@ -19,6 +20,7 @@ import de.frajul.endlessroll.entities.tileLists.Ceiling;
import de.frajul.endlessroll.entities.tileLists.Terrain; import de.frajul.endlessroll.entities.tileLists.Terrain;
import de.frajul.endlessroll.entities.tools.Tool; import de.frajul.endlessroll.entities.tools.Tool;
import de.frajul.endlessroll.levels.worlds.World; import de.frajul.endlessroll.levels.worlds.World;
import de.frajul.endlessroll.main.GameActivity;
/** /**
* Created by Julian on 20.07.2016. * Created by Julian on 20.07.2016.
@ -28,6 +30,8 @@ public abstract class Scene {
//Not sure if needed, this why set on very high value //Not sure if needed, this why set on very high value
private final float MAX_Y_MOVEMENT = -1f; private final float MAX_Y_MOVEMENT = -1f;
private GameActivity gameActivity;
protected Camera camera; protected Camera camera;
private Vector screenSize; private Vector screenSize;
private Entity playerArrow; private Entity playerArrow;
@ -46,7 +50,8 @@ public abstract class Scene {
protected List<Tool> tools = Collections.synchronizedList(new ArrayList<Tool>()); protected List<Tool> tools = Collections.synchronizedList(new ArrayList<Tool>());
protected Collectables collectables = new Collectables(); protected Collectables collectables = new Collectables();
public Scene(TexturePack texturePack, ParticleSystem particleSystem) { public Scene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
this.gameActivity = gameActivity;
this.particleSystem = particleSystem; this.particleSystem = particleSystem;
setTexturePack(texturePack); setTexturePack(texturePack);
camera = new Camera(); camera = new Camera();
@ -120,9 +125,14 @@ public abstract class Scene {
moveEnviroment(finalMovement.x); moveEnviroment(finalMovement.x);
} }
if (entity.isDestroyed() && entity.getDestroyEffect() != null) if (entity.isDestroyed() && entity.getDestroyEffect() != null) {
if (entity.getDestroyEffect() == DestroyEffect.EXPLOSION) {
gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().explosionSound);
}
entity.getDestroyEffect().createEffect(particleSystem, new Vector(entity.getPosition()), entity.getDestroyEffect().createEffect(particleSystem, new Vector(entity.getPosition()),
new Vector(entity.getWidth(), entity.getHeight())).start(); new Vector(entity.getWidth(), entity.getHeight())).start();
}
if (entity.getRightEdge() - camera.getX() < -3f || entity.isDestroyed()) { if (entity.getRightEdge() - camera.getX() < -3f || entity.isDestroyed()) {
return true; return true;
} }

View File

@ -8,6 +8,7 @@ import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.shapes.PlayerShape; import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.textures.TexturePack; import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.levels.worlds.World; import de.frajul.endlessroll.levels.worlds.World;
import de.frajul.endlessroll.main.GameActivity;
public class StartScene extends Scene { public class StartScene extends Scene {
@ -15,8 +16,8 @@ public class StartScene extends Scene {
private Random random; private Random random;
private World currentWorld = World.GRASSLANDS; private World currentWorld = World.GRASSLANDS;
public StartScene(TexturePack texturePack, ParticleSystem particleSystem) { public StartScene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
super(texturePack, particleSystem); super(gameActivity, texturePack, particleSystem);
player.init(PlayerShape.BALL, TERRAIN_EDGE, 0.5f, 0.5f, null); player.init(PlayerShape.BALL, TERRAIN_EDGE, 0.5f, 0.5f, null);
uncategorizedEntities.add(player); uncategorizedEntities.add(player);

View File

@ -10,11 +10,12 @@ import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.textures.TexturePack; import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.levels.ObstacleData; import de.frajul.endlessroll.levels.ObstacleData;
import de.frajul.endlessroll.levels.worlds.World; import de.frajul.endlessroll.levels.worlds.World;
import de.frajul.endlessroll.main.GameActivity;
public class TestScreenScene extends Scene { public class TestScreenScene extends Scene {
public TestScreenScene(TexturePack texturePack, ParticleSystem particleSystem) { public TestScreenScene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
super(texturePack, particleSystem); super(gameActivity, texturePack, particleSystem);
terrain.createEndless(World.ICY_MOUNTAINS, -1.0f); terrain.createEndless(World.ICY_MOUNTAINS, -1.0f);
background.changeTexture(World.ICY_MOUNTAINS.getBackgroundTexture()); background.changeTexture(World.ICY_MOUNTAINS.getBackgroundTexture());
new ParticleSource(new Vector(0, 0.0f), particleSystem.colorChange).start(); new ParticleSource(new Vector(0, 0.0f), particleSystem.colorChange).start();

View File

@ -24,7 +24,7 @@ public class GLTestScreen extends GLScreen<RelativeLayout> {
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
glView.setCurrentRendering(rendering); glView.setCurrentRendering(rendering);
} }

View File

@ -29,8 +29,7 @@ public class GameScreen extends GLScreen<RelativeLayout> {
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(null); gameActivity.getSoundManager().menuMusic.stop();
gameActivity.getSoundManager().menuMusic.reset();
glView.setCurrentRendering(game); glView.setCurrentRendering(game);
game.getViewManager().prepareToBeShown(); game.getViewManager().prepareToBeShown();

View File

@ -62,7 +62,7 @@ public class LevelsScreen extends Screen<LinearLayout> implements LevelButtonOnC
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
topBar.update(); topBar.update();
build(); build();

View File

@ -63,7 +63,7 @@ public class PlayerShapeShopScreen extends Screen<RelativeLayout> implements Pla
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
createViews(); createViews();
topBar.update(); topBar.update();

View File

@ -19,6 +19,7 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
private final int CALL_ID_CONFIRM_RESET = 1; private final int CALL_ID_CONFIRM_RESET = 1;
private TopBar topBar; private TopBar topBar;
private ToggleButton musicToggle;
private ToggleButton soundToggle; private ToggleButton soundToggle;
private Button resetButton; private Button resetButton;
private boolean resetPressed = false; private boolean resetPressed = false;
@ -28,6 +29,8 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
public SettingsScreen(GameActivity gameActivity) { public SettingsScreen(GameActivity gameActivity) {
super(ScreenType.SETTINGS, gameActivity, R.layout.settings); super(ScreenType.SETTINGS, gameActivity, R.layout.settings);
topBar = super.createTopBar(R.id.settings_topbar); topBar = super.createTopBar(R.id.settings_topbar);
musicToggle = (ToggleButton) layout.findViewById(R.id.settings_musictoggle);
musicToggle.setOnClickListener(this);
soundToggle = (ToggleButton) layout.findViewById(R.id.settings_soundtoggle); soundToggle = (ToggleButton) layout.findViewById(R.id.settings_soundtoggle);
soundToggle.setOnClickListener(this); soundToggle.setOnClickListener(this);
resetButton = (Button) layout.findViewById(R.id.settings_reset); resetButton = (Button) layout.findViewById(R.id.settings_reset);
@ -38,16 +41,21 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
topBar.update(); topBar.update();
soundToggle.setChecked(gameActivity.getSoundManager().isSoundOn()); musicToggle.setChecked(!gameActivity.getSoundManager().isMusicMuted());
soundToggle.setChecked(!gameActivity.getSoundManager().isSoundsMuted());
resetButton.setEnabled(super.caller != ScreenType.GAME); resetButton.setEnabled(super.caller != ScreenType.GAME);
resetPressed = false; resetPressed = false;
} }
@Override @Override
public void onBackKeyDown() { public void onBackKeyDown() {
gameActivity.getDataStorageHandler()
.writeSoundsMuted(gameActivity.getSoundManager().isSoundsMuted());
gameActivity.getDataStorageHandler()
.writeMusicMuted(gameActivity.getSoundManager().isMusicMuted());
//ResetButton is disabled if caller is GAME, because shortMenu or GoalMessage would still be visible on next level start //ResetButton is disabled if caller is GAME, because shortMenu or GoalMessage would still be visible on next level start
if (resetPressed && (super.caller == ScreenType.LEVELS || super.caller == ScreenType.GAME)) { if (resetPressed && (super.caller == ScreenType.LEVELS || super.caller == ScreenType.GAME)) {
super.caller = ScreenType.WORLDS; super.caller = ScreenType.WORLDS;
@ -57,8 +65,10 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.equals(soundToggle)) { if (v.equals(musicToggle)) {
gameActivity.getSoundManager().setSoundOn(soundToggle.isChecked()); gameActivity.getSoundManager().setMusicMuted(!musicToggle.isChecked());
} else if (v.equals(soundToggle)) {
gameActivity.getSoundManager().setSoundsMuted(!soundToggle.isChecked());
} else if (v.equals(resetButton)) { } else if (v.equals(resetButton)) {
resetConfirmDialog.show(CALL_ID_CONFIRM_RESET, R.string.confirm_dialog_reset); resetConfirmDialog.show(CALL_ID_CONFIRM_RESET, R.string.confirm_dialog_reset);
} }

View File

@ -61,7 +61,7 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
glView.setCurrentRendering(rendering); glView.setCurrentRendering(rendering);
((StartScene) rendering.getScene()).randomizeWorld(); ((StartScene) rendering.getScene()).randomizeWorld();

View File

@ -16,11 +16,13 @@ import de.frajul.endlessroll.rendering.Rendering;
*/ */
public class StartScreenRendering extends Rendering<StartScene> { public class StartScreenRendering extends Rendering<StartScene> {
private GameActivity gameActivity;
private Timer timer; private Timer timer;
private ParticleSystem particleSystem; private ParticleSystem particleSystem;
public StartScreenRendering(GameActivity gameActivity) throws Exception { public StartScreenRendering(GameActivity gameActivity) throws Exception {
super(gameActivity); super(gameActivity);
this.gameActivity = gameActivity;
this.particleSystem = new ParticleSystem(gameActivity); this.particleSystem = new ParticleSystem(gameActivity);
} }
@ -29,7 +31,7 @@ public class StartScreenRendering extends Rendering<StartScene> {
GameLog.d("init Start Screen Rendering"); GameLog.d("init Start Screen Rendering");
this.timer = timer; this.timer = timer;
if (isFirstTime) if (isFirstTime)
scene = new StartScene(texturePack, particleSystem); scene = new StartScene(gameActivity, texturePack, particleSystem);
else { else {
scene.setTexturePack(texturePack); scene.setTexturePack(texturePack);
} }

View File

@ -17,11 +17,13 @@ import de.frajul.endlessroll.rendering.Rendering;
*/ */
public class TestScreenRendering extends Rendering<TestScreenScene> { public class TestScreenRendering extends Rendering<TestScreenScene> {
private GameActivity gameActivity;
private Timer timer; private Timer timer;
private ParticleSystem particleSystem; private ParticleSystem particleSystem;
public TestScreenRendering(GameActivity gameActivity) throws Exception{ public TestScreenRendering(GameActivity gameActivity) throws Exception{
super(gameActivity); super(gameActivity);
this.gameActivity = gameActivity;
particleSystem = new ParticleSystem(gameActivity); particleSystem = new ParticleSystem(gameActivity);
} }
@ -30,7 +32,7 @@ public class TestScreenRendering extends Rendering<TestScreenScene> {
this.timer = timer; this.timer = timer;
try { try {
if (isFirstTime) if (isFirstTime)
scene = new TestScreenScene(texturePack, particleSystem); scene = new TestScreenScene(gameActivity, texturePack, particleSystem);
else else
scene.setTexturePack(texturePack); scene.setTexturePack(texturePack);
}catch (Exception e){ }catch (Exception e){

View File

@ -87,7 +87,7 @@ public class ToolShopScreen extends Screen<RelativeLayout> implements View.OnCli
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
topBar.update(); topBar.update();
slotSettings.unlockSlotsIfLevelReached(gameActivity.getUser().getLevelUpBounties()); slotSettings.unlockSlotsIfLevelReached(gameActivity.getUser().getLevelUpBounties());

View File

@ -42,7 +42,7 @@ public class WorldsScreen extends Screen<RelativeLayout> implements WorldButtonO
@Override @Override
public void prepareToBeShown() { public void prepareToBeShown() {
gameActivity.getSoundManager().setCurrentMusic(gameActivity.getSoundManager().menuMusic); gameActivity.getSoundManager().menuMusic.start();
topBar.update(); topBar.update();
for (WorldButton button : worldButtons) for (WorldButton button : worldButtons)

View File

@ -12,64 +12,57 @@ public class Music {
private ExceptionHandler handler; private ExceptionHandler handler;
private MediaPlayer player; private MediaPlayer player;
private boolean mute; private boolean started;
private boolean paused = true; private boolean muted;
private int pausedPosition; private boolean paused;
private boolean activityPaused;
public Music(ExceptionHandler handler, Context context, int id) { public Music(ExceptionHandler handler, Context context, int id) {
this.handler = handler; this.handler = handler;
player = MediaPlayer.create(context, id); player = MediaPlayer.create(context, id);
} }
public void setMute(boolean mute) {
this.mute = mute;
if (mute && !paused) {
stop();
paused = false;
}
if (!mute && !paused)
start();
}
public void pause() {
try {
if (!paused) {
player.pause();
paused = true;
pausedPosition = player.getCurrentPosition();
}
} catch (Exception e) {
handler.onException(e);
}
}
public void start() { public void start() {
try { started = true;
if (!mute) paused = false;
player.start(); onStateChanged();
paused = false;
} catch (Exception e) {
handler.onException(e);
}
} }
public void stop() { public void stop() {
try { started = false;
if (!paused) onStateChanged();
player.pause(); reset();
player.seekTo(0);
paused = true;
} catch (Exception e) {
handler.onException(e);
}
} }
public void setMuted(boolean muted) {
this.muted = muted;
onStateChanged();
}
public void resume() { public void pause() {
paused = true;
onStateChanged();
}
public void activityPause() {
activityPaused = true;
onStateChanged();
}
public void activityResume() {
activityPaused = false;
onStateChanged();
}
private void onStateChanged() {
try { try {
if (paused) { boolean newState = started && !muted && !paused && !activityPaused;
player.seekTo(pausedPosition); if (player.isPlaying()) {
start(); if (!newState)
player.pause();
} else {
if (newState)
player.start();
} }
} catch (Exception e) { } catch (Exception e) {
handler.onException(e); handler.onException(e);

View File

@ -0,0 +1,55 @@
package de.frajul.endlessroll.sounds;
/**
* Created by Julian on 17.01.2018.
*/
public class Sound {
private int soundId;
private float volume;
private boolean looping;
public Sound(int soundId) {
this(soundId, 1.0f);
}
public Sound(int soundId, float volume) {
this(soundId, volume, false);
}
public Sound(int soundId, boolean looping) {
this(soundId, 1.0f, looping);
}
public Sound(int soundId, float volume, boolean looping) {
this.soundId = soundId;
this.volume = volume;
this.looping = looping;
}
public int getSoundId() {
return soundId;
}
public void setSoundId(int soundId) {
this.soundId = soundId;
}
public float getVolume() {
return volume;
}
public void setVolume(float volume) {
this.volume = volume;
}
public boolean isLooping() {
return looping;
}
public void setLooping(boolean looping) {
this.looping = looping;
}
}

View File

@ -4,8 +4,10 @@ import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.SoundPool; import android.media.SoundPool;
import java.util.ArrayList;
import java.util.List;
import de.frajul.endlessroll.R; import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.tools.ToolType;
import de.frajul.endlessroll.main.GameActivity; import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog; import de.frajul.endlessroll.main.GameLog;
@ -16,52 +18,93 @@ public class SoundManager {
private Context context; private Context context;
private SoundPool soundPool; private SoundPool soundPool;
private boolean soundOn; private boolean soundsMuted;
private boolean musicMuted;
public final Music menuMusic; public final Music menuMusic;
public final Music gameMusic; public final Music gameMusic;
private Music currentMusic;
public final Sound goalSound;
public final Sound dieSound;
public final Sound collectStarSound;
public final Sound collectEnergySound;
public final Sound countdownSound;
public final Sound explosionSound;
public final Sound fireworkSound;
public final Sound stasisSound;
public final Sound mushroomSound;
public final Sound springSound;
public final Sound placeToolSound;
public final Sound magnetSound;
private List<SoundStream> allStartedStreams = new ArrayList<>();
public SoundManager(GameActivity activity) { public SoundManager(GameActivity activity) {
this.context = activity; this.context = activity;
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
menuMusic = new Music(activity, activity, R.raw.music_menu); menuMusic = new Music(activity, activity, R.raw.music_menu);
menuMusic.getPlayer().setLooping(true); menuMusic.getPlayer().setLooping(true);
gameMusic = new Music(activity, context, R.raw.music_game); gameMusic = new Music(activity, context, R.raw.music_game);
gameMusic.getPlayer().setLooping(true); gameMusic.getPlayer().setLooping(true);
ToolType.loadAllPlacingSounds(this);
goalSound = new Sound(loadSound(R.raw.sound_goal));
dieSound = new Sound(loadSound(R.raw.sound_die));
collectStarSound = new Sound(loadSound(R.raw.sound_collect_star), .7f);
collectEnergySound = new Sound(loadSound(R.raw.sound_collect_energy));
countdownSound = new Sound(loadSound(R.raw.sound_countdown));
explosionSound = new Sound(loadSound(R.raw.sound_explosion), 2);
fireworkSound = new Sound(loadSound(R.raw.sound_firework));
stasisSound = new Sound(loadSound(R.raw.sound_stasis), 1.3f, true);
mushroomSound = new Sound(loadSound(R.raw.sound_mushroom));
springSound = new Sound(loadSound(R.raw.sound_spring), 1.5f);
placeToolSound = new Sound(loadSound(R.raw.sound_place_tool), 1.5f);
magnetSound = new Sound(loadSound(R.raw.sound_magnet), 1.2f, true);
} }
public void setCurrentMusic(Music music) { public void setSoundsMuted(boolean soundsMuted) {
if (currentMusic != null && !currentMusic.equals(music)) { this.soundsMuted = soundsMuted;
currentMusic.pause(); for (SoundStream stream : allStartedStreams) {
float systemVolume = getSystemVolume();
soundPool.setVolume(stream.getId(), systemVolume * stream.getModifiedVolume(),
systemVolume * stream.getModifiedVolume());
} }
this.currentMusic = music;
if (music != null)
currentMusic.start();
} }
public void setSoundOn(boolean on) { public void setMusicMuted(boolean musicMuted) {
this.soundOn = on; this.musicMuted = musicMuted;
menuMusic.setMute(!on); menuMusic.setMuted(musicMuted);
gameMusic.setMute(!on); gameMusic.setMuted(musicMuted);
} }
public boolean isSoundOn() { public boolean isSoundsMuted() {
return soundOn; return soundsMuted;
} }
public void pause() { public boolean isMusicMuted() {
return musicMuted;
}
public void activityPause() {
soundPool.autoPause(); soundPool.autoPause();
if (currentMusic != null) gameMusic.activityPause();
currentMusic.pause(); menuMusic.activityPause();
} }
public void resume() { public void activityResume() {
soundPool.autoResume(); soundPool.autoResume();
if (currentMusic != null) gameMusic.activityResume();
currentMusic.resume(); menuMusic.activityResume();
}
public void pauseAllSounds() {
for (SoundStream stream : allStartedStreams)
soundPool.pause(stream.getId());
}
public void resumeAllSounds() {
for (SoundStream stream : allStartedStreams)
soundPool.resume(stream.getId());
} }
public void destroy() { public void destroy() {
@ -75,21 +118,43 @@ public class SoundManager {
return sound; return sound;
} }
public void playSound(int id) { public SoundStream playSound(Sound sound) {
float volume = getVolume(); float systemVolume = getSystemVolume();
int feedback = soundPool.play(id, volume, volume, 1, 0, 1); int streamId = soundPool.play(sound.getSoundId(), systemVolume * sound.getVolume(),
if (feedback == 0) systemVolume * sound.getVolume(), 1, sound.isLooping() ? -1 : 0, 1);
GameLog.e("SoundId: " + id + " cannot be played"); if (streamId == 0)
GameLog.e("SoundId: " + sound.getSoundId() + " cannot be played");
SoundStream soundStream = new SoundStream(streamId, sound.getVolume());
allStartedStreams.add(soundStream);
return soundStream;
} }
private float getVolume() { public void onStreamVolumeChanged(SoundStream stream) {
if (soundOn) { if (!soundsMuted) {
AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); float systemVolume = getSystemVolume();
float volume = manager.getStreamVolume(AudioManager.STREAM_MUSIC); soundPool.setVolume(stream.getId(), systemVolume * stream.getModifiedVolume(),
float maxVolume = manager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); systemVolume * stream.getModifiedVolume());
return volume / maxVolume;
} }
return 0; }
public void stopSound(SoundStream stream) {
allStartedStreams.remove(stream);
soundPool.stop(stream.getId());
}
public void stopAllSounds() {
for (SoundStream stream : allStartedStreams)
soundPool.stop(stream.getId());
allStartedStreams.clear();
}
private float getSystemVolume() {
if (soundsMuted)
return 0;
AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
float volume = manager.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = manager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
return volume / maxVolume;
} }
} }

View File

@ -0,0 +1,37 @@
package de.frajul.endlessroll.sounds;
/**
* Created by Julian on 19.01.2018.
*/
public class SoundStream {
private int id;
private float soundVolume;
private float currentVolumeModifier;
public SoundStream(int id, float soundVolume) {
this.id = id;
this.soundVolume = soundVolume;
}
public float getModifiedVolume() {
return soundVolume * currentVolumeModifier;
}
public int getId() {
return id;
}
public float getSoundVolume() {
return soundVolume;
}
public float getCurrentVolumeModifier() {
return currentVolumeModifier;
}
public void setCurrentVolumeModifier(float currentVolumeModifier) {
this.currentVolumeModifier = currentVolumeModifier;
}
}

View File

@ -1,7 +1,6 @@
package de.frajul.endlessroll.views; package de.frajul.endlessroll.views;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationSet; import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
@ -9,6 +8,8 @@ import android.widget.TextView;
import de.frajul.endlessroll.R; import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.game.Game; import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.sounds.SoundManager;
import de.frajul.endlessroll.sounds.SoundStream;
/** /**
* Created by Julian on 31.07.2016. * Created by Julian on 31.07.2016.
@ -18,26 +19,35 @@ public class Countdown implements Animation.AnimationListener {
private Game game; private Game game;
private AnimationSet animations; private AnimationSet animations;
private TextView textView; private TextView textView;
private SoundManager soundManager;
private SoundStream soundStream;
private boolean firstHalfRepeated = true; private boolean firstHalfRepeated = true;
private int repeatCount = 0; private int repeatCount = 0;
public Countdown(Game game, Typeface typeface, TextView textView) { public Countdown(Game game, SoundManager soundManager, Typeface typeface, TextView textView) {
this.game = game; this.game = game;
this.soundManager = soundManager;
this.textView = textView; this.textView = textView;
this.textView.setTypeface(typeface); this.textView.setTypeface(typeface);
animations = (AnimationSet) AnimationUtils.loadAnimation(game.getContext(), R.anim.countdown); animations = (AnimationSet) AnimationUtils
.loadAnimation(game.getContext(), R.anim.countdown);
for (Animation animation : animations.getAnimations()) for (Animation animation : animations.getAnimations())
animation.setAnimationListener(this); animation.setAnimationListener(this);
} }
public void start() { public void start() {
reset(); if (textView.getAnimation() == null || !textView.getAnimation().isInitialized()) {
textView.startAnimation(animations); reset();
textView.startAnimation(animations);
soundStream = soundManager.playSound(soundManager.countdownSound);
}
} }
public void stop() { public void stop() {
textView.clearAnimation(); textView.clearAnimation();
if (soundStream != null)
soundManager.stopSound(soundStream);
} }
private void reset() { private void reset() {
@ -59,6 +69,7 @@ public class Countdown implements Animation.AnimationListener {
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
if (!firstHalfRepeated) if (!firstHalfRepeated)
repeatCount++; repeatCount++;
firstHalfRepeated = !firstHalfRepeated; firstHalfRepeated = !firstHalfRepeated;
textView.setText((3 - repeatCount) + ""); textView.setText((3 - repeatCount) + "");
if (repeatCount == 1) { if (repeatCount == 1) {

View File

@ -18,6 +18,7 @@ import de.frajul.endlessroll.main.screens.Screen;
public class GameOverMessage implements View.OnClickListener { public class GameOverMessage implements View.OnClickListener {
private Animation fadeIn; private Animation fadeIn;
private GameActivity gameActivity;
private Game game; private Game game;
private View layout; private View layout;
@ -27,6 +28,7 @@ public class GameOverMessage implements View.OnClickListener {
public GameOverMessage(Game game, GameActivity gameActivity, View layout) { public GameOverMessage(Game game, GameActivity gameActivity, View layout) {
this.game = game; this.game = game;
this.gameActivity = gameActivity;
this.layout = layout; this.layout = layout;
layout.setVisibility(View.GONE); layout.setVisibility(View.GONE);
Typeface typeface = gameActivity.getTypeface(); Typeface typeface = gameActivity.getTypeface();
@ -61,6 +63,7 @@ public class GameOverMessage implements View.OnClickListener {
private void hide() { private void hide() {
layout.clearAnimation(); layout.clearAnimation();
layout.setVisibility(View.GONE); layout.setVisibility(View.GONE);
gameActivity.getSoundManager().stopAllSounds();
} }
@Override @Override

View File

@ -87,6 +87,7 @@ public class GoalMessage implements GoalMessageLevelButtonOnClickListener, View.
private void hide() { private void hide() {
layout.clearAnimation(); layout.clearAnimation();
layout.setVisibility(View.GONE); layout.setVisibility(View.GONE);
gameActivity.getSoundManager().stopAllSounds();
} }
@Override @Override

View File

@ -51,7 +51,7 @@ public class ViewManager implements View.OnClickListener {
gameOverMessage = new GameOverMessage(game, gameActivity, gameOverMessage = new GameOverMessage(game, gameActivity,
layout.findViewById(R.id.game_game_over_message)); layout.findViewById(R.id.game_game_over_message));
goalMessage = new GoalMessage(game, gameActivity, layout.findViewById(R.id.game_goal_message)); goalMessage = new GoalMessage(game, gameActivity, layout.findViewById(R.id.game_goal_message));
countdown = new Countdown(game, gameActivity.getTypeface(), countdown = new Countdown(game, gameActivity.getSoundManager(), gameActivity.getTypeface(),
(TextView) layout.findViewById(R.id.game_countdown)); (TextView) layout.findViewById(R.id.game_countdown));
} }
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/guis_music_off" />
<item android:state_checked="true"
android:drawable="@drawable/guis_music_on" />
</selector>

View File

@ -13,14 +13,23 @@
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@drawable/backgrounds_menu_grasslands" android:layout_height="match_parent"
android:layout_height="match_parent"> android:background="@drawable/backgrounds_menu_grasslands">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:orientation="vertical" android:layout_marginLeft="20dp"
android:layout_marginLeft="20dp"> android:orientation="vertical">
<ToggleButton
android:id="@+id/settings_musictoggle"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/xml_selector_music"
android:textOff=""
android:textOn=""/>
<ToggleButton <ToggleButton
android:id="@+id/settings_soundtoggle" android:id="@+id/settings_soundtoggle"
@ -32,10 +41,10 @@
<Button <Button
android:id="@+id/settings_reset" android:id="@+id/settings_reset"
style="@style/GameButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
style="@style/GameButton"
android:text="@string/settings_reset"/> android:text="@string/settings_reset"/>
</LinearLayout> </LinearLayout>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.