diff --git a/game/Scenes/HUD.tscn b/game/Scenes/HUD.tscn index d58d34f..19ee18c 100644 --- a/game/Scenes/HUD.tscn +++ b/game/Scenes/HUD.tscn @@ -10,85 +10,38 @@ [ext_resource path="res://Assets/Fonts/font_size_24.tres" type="DynamicFont" id=8] [sub_resource type="DynamicFont" id=1] - size = 72 -use_mipmaps = false -use_filter = false font_data = ExtResource( 3 ) -_sections_unfolded = [ "Font", "Settings" ] [sub_resource type="DynamicFont" id=2] - size = 40 -use_mipmaps = false -use_filter = false font_data = ExtResource( 3 ) -_sections_unfolded = [ "Font", "Settings" ] [sub_resource type="DynamicFont" id=3] - size = 20 -use_mipmaps = false -use_filter = false font_data = ExtResource( 3 ) -_sections_unfolded = [ "Font", "Settings" ] [node name="HUD" type="CanvasLayer"] - -layer = 1 -offset = Vector2( 0, 0 ) -rotation = 0.0 -scale = Vector2( 1, 1 ) -transform = Transform2D( 1, 0, 0, 1, 0, 0 ) script = ExtResource( 1 ) -[node name="Name" type="Label" parent="." index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Name" type="Label" parent="."] margin_left = 35.0 margin_top = 12.0 margin_right = 314.0 margin_bottom = 60.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_fonts/font = ExtResource( 2 ) text = "rospo mare b" uppercase = true -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_fonts" ] - -[node name="Money" type="Label" parent="." index="1"] +[node name="Money" type="Label" parent="."] anchor_left = 1.0 -anchor_top = 0.0 anchor_right = 1.0 -anchor_bottom = 0.0 margin_left = -383.0 margin_bottom = 99.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) text = "10000 €" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_fonts" ] - -[node name="GasLevel" type="TextureProgress" parent="." index="2"] +[node name="GasLevel" type="TextureProgress" parent="."] anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 @@ -97,166 +50,69 @@ margin_left = -99.0 margin_top = -261.0 margin_right = -54.0 margin_bottom = -71.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -min_value = 0.0 -max_value = 100.0 step = 0.0 -page = 0.0 -value = 0.0 -exp_edit = false -rounded = false texture_under = ExtResource( 4 ) -texture_over = null texture_progress = ExtResource( 5 ) fill_mode = 3 -radial_fill_degrees = 360.0 -radial_center_offset = Vector2( 0, 0 ) -nine_patch_stretch = false -_sections_unfolded = [ "Margin", "Rect", "Textures" ] - -[node name="HealthBar" type="TextureProgress" parent="." index="3"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="HealthBar" type="TextureProgress" parent="."] margin_left = 35.0 margin_top = 60.0 margin_right = 225.0 margin_bottom = 109.0 rect_scale = Vector2( 2, 1 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -min_value = 0.0 -max_value = 100.0 -step = 1.0 -page = 0.0 value = 100.0 -exp_edit = false -rounded = false texture_under = ExtResource( 6 ) -texture_over = null texture_progress = ExtResource( 7 ) -radial_fill_degrees = 360.0 -radial_center_offset = Vector2( 0, 0 ) -nine_patch_stretch = false -_sections_unfolded = [ "Textures" ] - -[node name="GasTimer" type="Timer" parent="." index="4"] -process_mode = 1 -wait_time = 1.0 -one_shot = false +[node name="GasTimer" type="Timer" parent="."] autostart = true -[node name="GasLabel" type="Label" parent="." index="5"] - -anchor_left = 0.0 +[node name="GasLabel" type="Label" parent="."] anchor_top = 1.0 -anchor_right = 0.0 anchor_bottom = 1.0 margin_left = 1809.0 margin_top = -62.0 margin_right = 1898.0 margin_bottom = -25.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 size_flags_vertical = 1 custom_fonts/font = ExtResource( 8 ) text = "00 %" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Rect", "Size Flags", "custom_fonts" ] -[node name="Weather" type="Node" parent="." index="6"] +[node name="Weather" type="Node" parent="."] -[node name="Generic" type="Label" parent="Weather" index="0"] - -anchor_left = 0.0 +[node name="Generic" type="Label" parent="Weather"] anchor_top = 1.0 -anchor_right = 0.0 anchor_bottom = 1.0 margin_left = 30.0 margin_top = -77.0 margin_right = 557.0 margin_bottom = -4.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_fonts/font = SubResource( 2 ) -text = "connessione fallita" +text = "API error" uppercase = true -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Hint", "Size Flags", "custom_fonts" ] - -[node name="Wind" type="Label" parent="Weather" index="1"] -anchor_left = 0.0 +[node name="Wind" type="Label" parent="Weather"] anchor_top = 1.0 -anchor_right = 0.0 anchor_bottom = 1.0 margin_left = 30.0 margin_top = -138.0 margin_right = 219.0 margin_bottom = -107.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_fonts/font = SubResource( 3 ) text = "VENTO 8 km/h" uppercase = true -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Rect" ] -[node name="Humidity" type="Label" parent="Weather" index="2"] - -anchor_left = 0.0 +[node name="Humidity" type="Label" parent="Weather"] anchor_top = 1.0 -anchor_right = 0.0 anchor_bottom = 1.0 margin_left = 30.0 margin_top = -106.0 margin_right = 200.0 margin_bottom = -75.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_fonts/font = SubResource( 3 ) text = "umidità 70 %" uppercase = true -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Rect" ] [connection signal="value_changed" from="HealthBar" to="." method="_on_HealthBar_value_changed"] - [connection signal="timeout" from="GasTimer" to="." method="_on_GasTimer_timeout"] - - diff --git a/game/Scenes/TurretPopup.tscn b/game/Scenes/TurretPopup.tscn index 22c81ae..136b3a4 100644 --- a/game/Scenes/TurretPopup.tscn +++ b/game/Scenes/TurretPopup.tscn @@ -9,17 +9,10 @@ [ext_resource path="res://Assets/Sfx/select.wav" type="AudioStream" id=7] [node name="TurretPopup" type="CanvasLayer"] - layer = 100 -offset = Vector2( 0, 0 ) -rotation = 0.0 -scale = Vector2( 1, 1 ) -transform = Transform2D( 1, 0, 0, 1, 0, 0 ) script = ExtResource( 1 ) -[node name="PanelContainer" type="MarginContainer" parent="." index="0"] - -editor/display_folded = true +[node name="PanelContainer" type="MarginContainer" parent="."] anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 @@ -28,297 +21,112 @@ margin_left = -320.0 margin_top = -128.0 margin_right = 320.0 margin_bottom = 128.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -_sections_unfolded = [ "Rect" ] -[node name="Turrets" type="HBoxContainer" parent="PanelContainer" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 8.0 +[node name="Turrets" type="HBoxContainer" parent="PanelContainer"] margin_right = 640.0 margin_bottom = 256.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_constants/separation = 70 alignment = 1 -[node name="Small" type="VBoxContainer" parent="PanelContainer/Turrets" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 63.0 -margin_right = 185.0 +[node name="Small" type="VBoxContainer" parent="PanelContainer/Turrets"] +margin_left = 67.0 +margin_right = 189.0 margin_bottom = 256.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_constants/separation = 30 alignment = 1 -[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Small" index="0"] - +[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Small"] modulate = Color( 1, 0.585938, 0.585938, 1 ) -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_top = 16.0 margin_right = 122.0 margin_bottom = 166.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 -size_flags_vertical = 1 toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) stretch_mode = 3 -_sections_unfolded = [ "Textures", "Visibility" ] -[node name="Price" type="Button" parent="PanelContainer/Turrets/Small" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Price" type="Button" parent="PanelContainer/Turrets/Small"] margin_top = 196.0 margin_right = 122.0 margin_bottom = 239.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_fonts/font = ExtResource( 4 ) disabled = true -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "100" -flat = false -align = 1 - -[node name="Medium" type="VBoxContainer" parent="PanelContainer/Turrets" index="1"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 255.0 -margin_right = 377.0 +[node name="Medium" type="VBoxContainer" parent="PanelContainer/Turrets"] +margin_left = 259.0 +margin_right = 381.0 margin_bottom = 256.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_constants/separation = 30 alignment = 1 -[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Medium" index="0"] - +[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Medium"] modulate = Color( 1, 0.857666, 0.585938, 1 ) -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_top = 16.0 margin_right = 122.0 margin_bottom = 166.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 -size_flags_vertical = 1 toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) stretch_mode = 3 -_sections_unfolded = [ "Textures", "Visibility" ] -[node name="Price" type="Button" parent="PanelContainer/Turrets/Medium" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Price" type="Button" parent="PanelContainer/Turrets/Medium"] margin_top = 196.0 margin_right = 122.0 margin_bottom = 239.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_fonts/font = ExtResource( 4 ) disabled = true -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "400" -flat = false -align = 1 - -[node name="Big" type="VBoxContainer" parent="PanelContainer/Turrets" index="2"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 447.0 -margin_right = 569.0 +[node name="Big" type="VBoxContainer" parent="PanelContainer/Turrets"] +margin_left = 451.0 +margin_right = 573.0 margin_bottom = 256.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_constants/separation = 30 alignment = 1 -[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Big" index="0"] - +[node name="Type" type="TextureButton" parent="PanelContainer/Turrets/Big"] modulate = Color( 0.664062, 0.937012, 1, 1 ) -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_top = 16.0 margin_right = 122.0 margin_bottom = 166.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 -size_flags_vertical = 1 toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) -_sections_unfolded = [ "Size Flags", "Textures", "Visibility" ] - -[node name="Price" type="Button" parent="PanelContainer/Turrets/Big" index="1"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Price" type="Button" parent="PanelContainer/Turrets/Big"] margin_top = 196.0 margin_right = 122.0 margin_bottom = 239.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_fonts/font = ExtResource( 4 ) disabled = true -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "1000" -flat = false -align = 1 -[node name="CloseButton" type="Button" parent="PanelContainer" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 8.0 -margin_right = 44.0 +[node name="CloseButton" type="Button" parent="PanelContainer"] +margin_right = 36.0 margin_bottom = 54.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 2 size_flags_vertical = 2 custom_fonts/font = ExtResource( 5 ) -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "x" -flat = false -align = 1 -_sections_unfolded = [ "Size Flags", "custom_colors", "custom_fonts" ] - -[node name="Error" type="AudioStreamPlayer" parent="." index="1"] +[node name="Error" type="AudioStreamPlayer" parent="."] stream = ExtResource( 6 ) -volume_db = 0.0 -pitch_scale = 1.0 -autoplay = false -mix_target = 0 -bus = "Master" - -[node name="PressedSound" type="AudioStreamPlayer" parent="." index="2"] +[node name="PressedSound" type="AudioStreamPlayer" parent="."] stream = ExtResource( 7 ) volume_db = -5.0 -pitch_scale = 1.0 -autoplay = false -mix_target = 0 -bus = "Master" [connection signal="pressed" from="PanelContainer/Turrets/Small/Type" to="." method="_on_small_pressed"] - [connection signal="pressed" from="PanelContainer/Turrets/Small/Price" to="." method="_on_Small_Price_pressed"] - [connection signal="pressed" from="PanelContainer/Turrets/Medium/Type" to="." method="_on_medium_pressed"] - [connection signal="pressed" from="PanelContainer/Turrets/Medium/Price" to="." method="_on_Medium_Price_pressed"] - [connection signal="pressed" from="PanelContainer/Turrets/Big/Type" to="." method="_on_big_pressed"] - [connection signal="pressed" from="PanelContainer/Turrets/Big/Price" to="." method="_on_Big_Price_pressed"] - [connection signal="pressed" from="PanelContainer/CloseButton" to="." method="_on_CloseButton_pressed"] - - diff --git a/game/Scenes/TurretSlot.tscn b/game/Scenes/TurretSlot.tscn index c900c7e..608753b 100644 --- a/game/Scenes/TurretSlot.tscn +++ b/game/Scenes/TurretSlot.tscn @@ -5,44 +5,19 @@ [ext_resource path="res://Scripts/TurretSlot.gd" type="Script" id=3] [ext_resource path="res://Assets/Sfx/select.wav" type="AudioStream" id=4] -[node name="TurretSlot" type="TextureButton" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="TurretSlot" type="TextureButton"] margin_right = 75.0 margin_bottom = 72.0 rect_min_size = Vector2( 75, 72 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 1 ) texture_hover = ExtResource( 2 ) script = ExtResource( 3 ) -_sections_unfolded = [ "Rect", "Textures" ] - -[node name="Pivot" type="Position2D" parent="." index="0"] +[node name="Pivot" type="Position2D" parent="."] position = Vector2( 39.0421, 35.0809 ) -[node name="PressedSound" type="AudioStreamPlayer" parent="." index="1"] - +[node name="PressedSound" type="AudioStreamPlayer" parent="."] stream = ExtResource( 4 ) volume_db = -5.0 -pitch_scale = 1.0 -autoplay = false -mix_target = 0 -bus = "Master" [connection signal="pressed" from="." to="." method="_on_TurretSlot_pressed"] - - diff --git a/game/Scenes/WeatherRequest.tscn b/game/Scenes/WeatherRequest.tscn index a8939a4..d87ee57 100644 --- a/game/Scenes/WeatherRequest.tscn +++ b/game/Scenes/WeatherRequest.tscn @@ -3,16 +3,9 @@ [ext_resource path="res://Scripts/WeatherRequest.gd" type="Script" id=1] [node name="WeatherRequest" type="Node"] - script = ExtResource( 1 ) -[node name="HTTPRequest" type="HTTPRequest" parent="." index="0"] - +[node name="HTTPRequest" type="HTTPRequest" parent="."] download_file = "res://Data/weather.json" -use_threads = false -body_size_limit = -1 -max_redirects = 8 [connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] - - diff --git a/game/Scripts/Enemy.gd b/game/Scripts/Enemy.gd index c318c8a..8156226 100644 --- a/game/Scripts/Enemy.gd +++ b/game/Scripts/Enemy.gd @@ -47,10 +47,10 @@ func _physics_process(delta): else: queue_free() -func hit(damage): +func hit(_damage): # check remaining life - if life > damage: - life -= damage + if life > _damage: + life -= _damage Global.money += 2 else: life = 0 @@ -58,12 +58,12 @@ func hit(damage): func explode(): $ExplosionSound.play() - $CollisionShape2D.disabled = true + $CollisionShape2D.set_deferred("disabled", true) speed = 0 $AnimationPlayer.play("explode") Global.money += points -func _on_AnimationPlayer_animation_finished(anim_name): +func _on_AnimationPlayer_animation_finished(_anim_name): queue_free() func _on_HealthBar_value_changed(value): diff --git a/game/Scripts/GameOver.gd b/game/Scripts/GameOver.gd index 93bd214..d4873d8 100644 --- a/game/Scripts/GameOver.gd +++ b/game/Scripts/GameOver.gd @@ -49,11 +49,11 @@ func _ready(): func _on_Menu_pressed(): restore_values() - get_tree().change_scene("res://Scenes/MainMenu.tscn") + var _e = get_tree().change_scene("res://Scenes/MainMenu.tscn") func _on_Retry_pressed(): restore_values() - get_tree().change_scene("res://Scenes/Map.tscn") + var _e = get_tree().change_scene("res://Scenes/Map.tscn") func restore_values(): $PressedSound.play() diff --git a/game/Scripts/Global.gd b/game/Scripts/Global.gd index a7e7495..b389d53 100644 --- a/game/Scripts/Global.gd +++ b/game/Scripts/Global.gd @@ -30,4 +30,4 @@ func decrease_money(value): return true else: print("Insufficient money!") - return false \ No newline at end of file + return false diff --git a/game/Scripts/HUD.gd b/game/Scripts/HUD.gd index dd291c5..0cd33fa 100644 --- a/game/Scripts/HUD.gd +++ b/game/Scripts/HUD.gd @@ -54,7 +54,7 @@ func fill_weather_info(): # close the file file.close() -func _process(delta): +func _process(_delta): $Money.text = String(Global.money) + " €" $HealthBar.value = Global.platform_life $GasLabel.text = "%d %%" % Global.gas_percentage @@ -73,4 +73,4 @@ func _on_GasTimer_timeout(): if $GasLevel.value >= 100: var g = GameOver.instance() g.victory = true - add_child(g) \ No newline at end of file + add_child(g) diff --git a/game/Scripts/LevelSelection.gd b/game/Scripts/LevelSelection.gd index 45853cb..f40efca 100644 --- a/game/Scripts/LevelSelection.gd +++ b/game/Scripts/LevelSelection.gd @@ -1,13 +1,9 @@ extends Node + var textures = ["res://Assets/Art/UI/platforms/pixel_small_platform.png", "res://Assets/Art/UI/platforms/pixel_platform.png", "res://Assets/Art/UI/platforms/pixel_big_platform.png"] -onready var columns = $UI/Rows/Second/Platforms -onready var page = $UI/Rows/First/Labels/Page -onready var platform_infos = $UI/Rows/Third/HBoxContainer/PlatformInfos -onready var play = $UI/Rows/Third/HBoxContainer/Play -onready var map = "res://Scenes/Map.tscn" var number = 0 var platforms = [] var buttons = [] @@ -15,6 +11,13 @@ var cur_page = 1 var pages = 0 var cur_id = 0 +onready var columns = $UI/Rows/Second/Platforms +onready var page = $UI/Rows/First/Labels/Page +onready var platform_infos = $UI/Rows/Third/HBoxContainer/PlatformInfos +onready var play = $UI/Rows/Third/HBoxContainer/Play +onready var map = "res://Scenes/Map.tscn" + + func _ready(): # zone label text $UI/Rows/First/Labels/Zone.text = "Zona %s" % Global.cur_zone[1] @@ -47,6 +50,7 @@ func _ready(): cur_id = int(platforms[0]["ccodice"]) platform_infos.show_info(cur_id) + func fill_row(): var sizes = [] # find 5 platforms in the json @@ -78,6 +82,7 @@ func fill_row(): # display the correct info platform_infos.show_info(buttons[0].platform_id) + func _on_BtnRight_pressed(): # play the animation $AnimationPlayer.play("swipe") @@ -99,6 +104,7 @@ func _on_BtnRight_pressed(): buttons[b].connect("pressed", platform_infos, "show_info", [buttons[b].platform_id]) + func _on_BtnLeft_pressed(): # play the animation $AnimationPlayer.play("swipe") @@ -120,9 +126,11 @@ func _on_BtnLeft_pressed(): buttons[b].connect("pressed", platform_infos, "show_info", [buttons[b].platform_id]) + func _on_Play_pressed(): $PlaySound.play() + func _on_PlaySound_finished(): # find the pressed button for b in buttons.size(): @@ -130,12 +138,4 @@ func _on_PlaySound_finished(): cur_id = buttons[b].platform_id # switch to the game scene Global.platform_id = cur_id - get_tree().change_scene(map) - - - - - - - - + var _e = get_tree().change_scene(map) diff --git a/game/Scripts/Map.gd b/game/Scripts/Map.gd index 440c867..6e91895 100644 --- a/game/Scripts/Map.gd +++ b/game/Scripts/Map.gd @@ -65,9 +65,3 @@ func _on_HUD_weather_acquired(weather): else: $Camera2D/WeatherEffects/Rain.emitting = false $TileMap.modulate = Color(1.0, 1.0, 1.0, 1.0) - - - - - - diff --git a/game/Scripts/Platform.gd b/game/Scripts/Platform.gd index ab8c9a2..93453e9 100644 --- a/game/Scripts/Platform.gd +++ b/game/Scripts/Platform.gd @@ -1,5 +1,6 @@ extends Area2D + signal platform_initialized var GameOver = preload("res://Scenes/GameOver.tscn") @@ -7,7 +8,7 @@ var textures = ["res://Assets/Art/Platforms/pixel_small_platform.png", "res://Assets/Art/Platforms/pixel_platform.png", "res://Assets/Art/Platforms/pixel_big_platform.png"] # platform's id -var id +var id: int var producting_pits var inactive_pits var size @@ -27,11 +28,9 @@ var info_dict = { "Dimensions" : 0 } + func _ready(): id = Global.platform_id - init(id) - -func init(id): ## init the info dictionary info_dict.Name = DataHandler.get_value(id, "cdenominazione__") # get and format the Year @@ -56,7 +55,6 @@ func init(id): info_dict.Altitude = DataHandler.get_value(id, "caltezza_slm__m_") info_dict.Depth = DataHandler.get_value(id, "cprofondit__fondale__m_") info_dict.Dimensions = DataHandler.get_value(id, "cdimensioni") - ## init game values # location var lat = DataHandler.get_value(id, "clatitudine__wgs84__") @@ -77,10 +75,10 @@ func init(id): # pits producting_pits = DataHandler.get_value(id, "cpozzi_in_produzione").to_int() inactive_pits = DataHandler.get_value(id, "cpozzi_produttivi_non_eroganti").to_int() - Global.platform_info = info_dict emit_signal("platform_initialized", location) + func hit(damage): $HitSound.play() # check remaining life @@ -90,27 +88,21 @@ func hit(damage): Global.platform_life = 0 game_over() + func _on_Platform_body_entered(body): if body.is_in_group("enemies"): self.hit(body.damage) body.queue_free() + func game_over(): $CollisionShape2D.disabled = true # play the explosion $AnimationPlayer.play("explode") -func _on_AnimationPlayer_animation_finished(anim_name): + +func _on_AnimationPlayer_animation_finished(_anim_name): # display gameover var g = GameOver.instance() g.victory = false get_parent().get_node("Camera2D/HUD").add_child(g) - - - - - - - - - diff --git a/game/Scripts/Turret.gd b/game/Scripts/Turret.gd index a5ed7e0..1ba8aaa 100644 --- a/game/Scripts/Turret.gd +++ b/game/Scripts/Turret.gd @@ -33,7 +33,7 @@ func set_size(new_size): $Sprite.modulate = Color("a9eeff") damage += (damage / 2) -func _physics_process(delta): +func _physics_process(_delta): update() if targets.size() > 0: if can_shoot: diff --git a/game/Scripts/WeatherRequest.gd b/game/Scripts/WeatherRequest.gd index e8a1339..de24524 100644 --- a/game/Scripts/WeatherRequest.gd +++ b/game/Scripts/WeatherRequest.gd @@ -1,10 +1,14 @@ extends Node + const DATA_PATH = "res://Data/my_data.json" + var data + onready var platform = get_tree().root.get_node("Map/Platform") onready var file + func _ready(): # try to load the file file = File.new() @@ -22,15 +26,16 @@ func _ready(): if check_time(): platform.connect("platform_initialized", self, "make_request") + func make_request(location): var params = [str(location.x), str(location.y), str(Global.my_token)] var req = "http://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&units=metric&appid=%s&lang=it" % params $HTTPRequest.request(req) + func check_time(): var cur_datetime = OS.get_datetime() var minute_interval = 1 - # if value is > than current datetime we're sure it can make a request, # otherwise if = we need to perform more checks if cur_datetime.year > int(data["last_req"].year): @@ -47,19 +52,18 @@ func check_time(): elif cur_datetime.hour == int(data["last_req"].hour): if cur_datetime.minute > (int(data["last_req"].minute) + minute_interval) % 60: return true - return false -func _on_HTTPRequest_request_completed(result, response_code, headers, body): - var json = JSON.parse(body.get_string_from_utf8()) + +func _on_HTTPRequest_request_completed(result, response_code, _headers, _body): if result != 0: print("HTTPRequest Error: ", result, " ", response_code) Global.conn_error = true return - Global.conn_error = false write_last_request() + func write_last_request(): var cur_datetime = OS.get_datetime() # write current time in JSON @@ -73,6 +77,3 @@ func write_last_request(): file.open(DATA_PATH, File.WRITE) file.store_string(JSON.print(data, " ", true)) file.close() - - -