diff --git a/godot/Game.gd b/godot/Game.gd index ba9359a0fd1d0a384ec747d9df50702c57f8275a..355a9f3b65a05ae29359b42a3b53c28d6f58b3cc 100644 --- a/godot/Game.gd +++ b/godot/Game.gd @@ -8,8 +8,10 @@ onready var transition = $Overlays/TransitionColor onready var local_map = $LocalMap onready var party = $Party as Party onready var music_player = $MusicPlayer +onready var game_over_interface : = $GameOverInterface var transitioning = false +var combat_arena : CombatArena func _ready(): local_map.visible = true @@ -27,9 +29,10 @@ func enter_battle(formation: Formation): transitioning = true yield(transition.fade_to_color(), "completed") remove_child(local_map) - var combat_arena = combat_arena_scene.instance() + combat_arena = combat_arena_scene.instance() add_child(combat_arena) combat_arena.connect("victory", self, "_on_CombatArena_player_victory") + combat_arena.connect("gameover", self, "_on_combat_gameover") combat_arena.initialize(formation, party.get_active_members()) yield(transition.fade_from_color(), "completed") transitioning = false @@ -52,3 +55,16 @@ func enter_battle(formation: Formation): func _on_CombatArena_player_victory(): music_player.play_victory_fanfare() + +func _on_combat_gameover() -> void: + transitioning = true + yield(transition.fade_to_color(), "completed") + game_over_interface.display(GameOverInterface.Reason.PARTY_DEFEATED) + yield(transition.fade_from_color(), "completed") + transitioning = false + +func _on_GameOverInterface_restart_requested(): + game_over_interface.hide() + var formation = combat_arena.initial_formation + combat_arena.queue_free() + enter_battle(formation) diff --git a/godot/Game.tscn b/godot/Game.tscn index 30c91ab111126f770c6650da1f4f663a91d65198..afa4a636b47586cc3ff8576fc6bf0a2d9aa55cc5 100644 --- a/godot/Game.tscn +++ b/godot/Game.tscn @@ -1,11 +1,12 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://Game.gd" type="Script" id=1] [ext_resource path="res://party/Party.tscn" type="PackedScene" id=2] [ext_resource path="res://local_map/LocalMap.tscn" type="PackedScene" id=3] [ext_resource path="res://assets/shaders/TransitionColor.tscn" type="PackedScene" id=4] -[ext_resource path="res://assets/audio/bgm/battle_theme.ogg" type="AudioStream" id=5] -[ext_resource path="res://core/MusicPlayer.gd" type="Script" id=6] +[ext_resource path="res://interface/game_over/GameOverInterface.tscn" type="PackedScene" id=5] +[ext_resource path="res://assets/audio/bgm/battle_theme.ogg" type="AudioStream" id=6] +[ext_resource path="res://core/MusicPlayer.gd" type="Script" id=7] [node name="Game" type="Node"] script = ExtResource( 1 ) @@ -22,10 +23,14 @@ margin_left = -3.0 margin_right = -3.0 mouse_filter = 2 +[node name="GameOverInterface" parent="." instance=ExtResource( 5 )] +layer = 0 + [node name="MusicPlayer" type="AudioStreamPlayer" parent="."] -stream = ExtResource( 5 ) +stream = ExtResource( 6 ) bus = "Music" -script = ExtResource( 6 ) +script = ExtResource( 7 ) [connection signal="combat_finished" from="." to="LocalMap" method="_on_Game_combat_finished"] [connection signal="enemies_encountered" from="LocalMap" to="." method="enter_battle"] +[connection signal="restart_requested" from="GameOverInterface" to="." method="_on_GameOverInterface_restart_requested"] diff --git a/godot/assets/fonts/default_theme/montserrat_eb_128.tres b/godot/assets/fonts/default_theme/montserrat_eb_128.tres new file mode 100644 index 0000000000000000000000000000000000000000..ba1030cbabbec674fdeab4bc5a23c6e041d7e0a2 --- /dev/null +++ b/godot/assets/fonts/default_theme/montserrat_eb_128.tres @@ -0,0 +1,10 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://assets/fonts/default_theme/Montserrat-ExtraBold.ttf" type="DynamicFontData" id=1] + +[resource] + +size = 128 +use_filter = true +font_data = ExtResource( 1 ) + diff --git a/godot/assets/fonts/default_theme/montserrat_eb_48.tres b/godot/assets/fonts/default_theme/montserrat_eb_48.tres new file mode 100644 index 0000000000000000000000000000000000000000..3a70299d933598eb65a1f895cc001c92dcaaa815 --- /dev/null +++ b/godot/assets/fonts/default_theme/montserrat_eb_48.tres @@ -0,0 +1,10 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://assets/fonts/default_theme/Montserrat-ExtraBold.ttf" type="DynamicFontData" id=1] + +[resource] + +size = 48 +use_filter = true +font_data = ExtResource( 1 ) + diff --git a/godot/assets/fonts/default_theme/montserrat_eb_64.tres b/godot/assets/fonts/default_theme/montserrat_eb_64.tres new file mode 100644 index 0000000000000000000000000000000000000000..6106df3715c708686de03da1f06fd6e96d950d69 --- /dev/null +++ b/godot/assets/fonts/default_theme/montserrat_eb_64.tres @@ -0,0 +1,10 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://assets/fonts/default_theme/Montserrat-ExtraBold.ttf" type="DynamicFontData" id=1] + +[resource] + +size = 64 +use_filter = true +font_data = ExtResource( 1 ) + diff --git a/godot/assets/sprites/battlers/godette_portrait_256.png.import b/godot/assets/sprites/battlers/godette_portrait_256.png.import new file mode 100644 index 0000000000000000000000000000000000000000..6115a5601afe0463babfcc3532ad84930a4d0a46 --- /dev/null +++ b/godot/assets/sprites/battlers/godette_portrait_256.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/godette_portrait_256.png-05321e088e0867fcb2ebe27adcb2d002.stex" + +[deps] + +source_file="res://assets/sprites/battlers/godette_portrait_256.png" +dest_files=[ "res://.import/godette_portrait_256.png-05321e088e0867fcb2ebe27adcb2d002.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/assets/sprites/battlers/porcupine_portrait_256.png.import b/godot/assets/sprites/battlers/porcupine_portrait_256.png.import new file mode 100644 index 0000000000000000000000000000000000000000..c39dd23dfd61ffe2a1e926ec3712eea999230c73 --- /dev/null +++ b/godot/assets/sprites/battlers/porcupine_portrait_256.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/porcupine_portrait_256.png-a1412bc3f2808cdfb5aeda2a4ae00c23.stex" + +[deps] + +source_file="res://assets/sprites/battlers/porcupine_portrait_256.png" +dest_files=[ "res://.import/porcupine_portrait_256.png-a1412bc3f2808cdfb5aeda2a4ae00c23.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/assets/sprites/battlers/robi_portrait_256.png.import b/godot/assets/sprites/battlers/robi_portrait_256.png.import new file mode 100644 index 0000000000000000000000000000000000000000..b1f8a133a451f61e8813326f55dc95b443d0c6ad --- /dev/null +++ b/godot/assets/sprites/battlers/robi_portrait_256.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/robi_portrait_256.png-d86fee246dc6e3b4032b47db1ab50863.stex" + +[deps] + +source_file="res://assets/sprites/battlers/robi_portrait_256.png" +dest_files=[ "res://.import/robi_portrait_256.png-d86fee246dc6e3b4032b47db1ab50863.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/combat/CombatArena.gd b/godot/combat/CombatArena.gd index 89cf337433f8a5ac66b2797dcf9a65b423e7cd1f..b4b3329bf889d6b3f3daede8e1fc373d8f0aaaac 100644 --- a/godot/combat/CombatArena.gd +++ b/godot/combat/CombatArena.gd @@ -10,6 +10,7 @@ onready var rewards = $Rewards var active : bool = false var party : Array = [] +var initial_formation : Formation # sent when the battler is starting to end (before battle_ended) signal battle_ends @@ -20,6 +21,7 @@ signal victory signal gameover func initialize(formation : Formation, party : Array): + initial_formation = formation ready_field(formation, party) # reparent the enemy battlers into the turn queue @@ -92,7 +94,6 @@ func battle_end(): yield(rewards.on_battle_completed(), "completed") emit_signal("battle_ended", self.party) else: - emit_signal("battle_ended", self.party) emit_signal("gameover") func play_turn(): diff --git a/godot/combat/CombatArena.tscn b/godot/combat/CombatArena.tscn index a8bb3f4f42c3adbce5e757b0a949bb10c03ce2dd..a588ee5da6ffef1e1a44bffd0c509965b0ebca12 100644 --- a/godot/combat/CombatArena.tscn +++ b/godot/combat/CombatArena.tscn @@ -33,13 +33,8 @@ z_index = 10 [node name="CombatInterface" type="CanvasLayer" parent="." groups=[ "interface", ]] -layer = 100 -offset = Vector2( 0, 0 ) -rotation = 0.0 -scale = Vector2( 1, 1 ) -transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +editor/display_folded = true script = ExtResource( 3 ) -buttons_offset = null [node name="PopUpHandler" parent="CombatInterface" instance=ExtResource( 4 )] @@ -59,10 +54,7 @@ transform = Transform2D( 1, 0, 0, 1, 0, 0 ) script = ExtResource( 8 ) [node name="Panel" type="Panel" parent="Rewards"] -anchor_left = 0.0 -anchor_top = 0.0 anchor_right = 1.0 -anchor_bottom = 0.0 margin_bottom = 160.0 rect_min_size = Vector2( 0, 160 ) rect_pivot_offset = Vector2( 0, 0 ) @@ -74,22 +66,11 @@ size_flags_vertical = 1 theme = ExtResource( 9 ) [node name="Label" type="Label" parent="Rewards/Panel"] -anchor_left = 0.0 -anchor_top = 0.0 anchor_right = 1.0 anchor_bottom = 1.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 text = "EXP Earned" align = 1 valign = 1 -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 [node name="Grasslands" parent="." instance=ExtResource( 10 )] diff --git a/godot/combat/interface/bars/StatBar.gd b/godot/combat/interface/bars/StatBar.gd index f9740765d24515559456971013c34461d22e7c18..d26fa7f198f9c2880a4f36a06bf2fb6292788243 100644 --- a/godot/combat/interface/bars/StatBar.gd +++ b/godot/combat/interface/bars/StatBar.gd @@ -23,6 +23,8 @@ func set_value(new_value) -> void: value = new_value bar.value = new_value label.display(new_value, max_value) + if HIDE_ON_DEPLETED and value == 0: + hide() func initialize(battler : Battler) -> void: _connect_value_signals(battler) diff --git a/godot/combat/interface/bars/manabar/HookableManaBar.tscn b/godot/combat/interface/bars/manabar/HookableManaBar.tscn index 64b3f163f81e5915da02213852098b8a810155c3..ef2fdfa12c22d85967b54852ce65da3bc7a5e28a 100644 --- a/godot/combat/interface/bars/manabar/HookableManaBar.tscn +++ b/godot/combat/interface/bars/manabar/HookableManaBar.tscn @@ -4,11 +4,13 @@ [ext_resource path="res://combat/interface/bars/manabar/ManaBar.gd" type="Script" id=2] [ext_resource path="res://combat/interface/bars/manabar/fill.png" type="Texture" id=3] -[node name="HookableManaBar" instance=ExtResource( 1 )] +[node name="HookableManaBar" index="0" instance=ExtResource( 1 )] script = ExtResource( 2 ) -LABEL_ABOVE = null -HIDE_ON_DEPLETED = true +HIDE_ON_DEPLETED = false [node name="TextureProgress" parent="Column" index="0"] texture_progress = ExtResource( 3 ) +[node name="LifeLabel" parent="Column" index="1"] +margin_bottom = 52.0 + diff --git a/godot/combat/interface/turn_order/CombatPortrait.gd b/godot/combat/interface/turn_order/CombatPortrait.gd index efa4706bd9dd4704911bd0384b1f562bbf218d3e..4648b0e73134057e4b6e67cfeeebb33176301470 100644 --- a/godot/combat/interface/turn_order/CombatPortrait.gd +++ b/godot/combat/interface/turn_order/CombatPortrait.gd @@ -3,6 +3,7 @@ extends Control class_name CombatPortrait onready var battler : Battler +onready var tween : Tween = $Tween onready var animation_player : AnimationPlayer = $AnimationPlayer onready var icon : TextureRect = $Background/Icon @@ -12,6 +13,7 @@ func initialize(battler : Battler, play_animation : bool = true) -> void: self.battler = battler icon.texture = battler.turn_order_icon + _appear(1.0) # When a portrait is initialized, we must not play the reduce animaiton # if it corresponds to first playing battler. The highlight animation # will be automatically played instead. @@ -42,5 +44,15 @@ func disable() -> void: """ animation_player.play('disable') +func _appear(alpha): + """Tween the modulation alpha to make the portrait appear.""" + var from : Color = modulate + var to : Color = modulate + + to.a = alpha + tween.interpolate_property(self, 'modulate', from, to, 0.3, + Tween.TRANS_LINEAR, Tween.EASE_OUT) + tween.start() + func _on_health_depleted(): disable() diff --git a/godot/combat/interface/turn_order/CombatPortrait.tscn b/godot/combat/interface/turn_order/CombatPortrait.tscn index 3e6cff405f228c1b33585c2bc24bf7705792f23b..f83b11102f94b7c3d4d01533d046eb68cfa751ae 100644 --- a/godot/combat/interface/turn_order/CombatPortrait.tscn +++ b/godot/combat/interface/turn_order/CombatPortrait.tscn @@ -10,8 +10,6 @@ resource_name = "disable" length = 0.2 -loop = false -step = 0.1 tracks/0/type = "value" tracks/0/path = NodePath(".:modulate") tracks/0/interp = 1 @@ -28,8 +26,6 @@ tracks/0/keys = { [sub_resource type="Animation" id=2] length = 0.3 -loop = false -step = 0.1 tracks/0/type = "value" tracks/0/path = NodePath("Border:texture") tracks/0/interp = 1 @@ -54,25 +50,11 @@ tracks/1/keys = { "update": 0, "values": [ Vector2( 0.66, 0.66 ), Vector2( 1, 1 ) ] } -tracks/2/type = "value" -tracks/2/path = NodePath(".:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.3 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] -} [sub_resource type="Animation" id=3] resource_name = "reduce" length = 0.4 -loop = false -step = 0.1 tracks/0/type = "value" tracks/0/path = NodePath("Border:texture") tracks/0/interp = 1 @@ -97,24 +79,10 @@ tracks/1/keys = { "update": 0, "values": [ Vector2( 1, 1 ), Vector2( 0.66, 0.66 ) ] } -tracks/2/type = "value" -tracks/2/path = NodePath(".:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.4 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] -} [sub_resource type="Animation" id=4] length = 0.3 -loop = false -step = 0.1 tracks/0/type = "value" tracks/0/path = NodePath("Border:texture") tracks/0/interp = 1 @@ -142,10 +110,6 @@ tracks/1/keys = { [node name="CombatPortrait" type="Control"] modulate = Color( 1, 1, 1, 0 ) -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_left = -14.0 margin_top = -14.0 margin_right = 104.0 @@ -154,80 +118,38 @@ grow_horizontal = 2 grow_vertical = 2 rect_min_size = Vector2( 124, 124 ) rect_scale = Vector2( 0.66, 0.66 ) -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 script = ExtResource( 1 ) [node name="Border" type="TextureRect" parent="."] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_left = -72.0 margin_top = -72.0 margin_right = 72.0 margin_bottom = 72.0 grow_horizontal = 2 grow_vertical = 2 -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 texture = ExtResource( 2 ) -stretch_mode = 0 [node name="Background" type="TextureRect" parent="."] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_left = -64.0 margin_top = -64.0 margin_right = 64.0 margin_bottom = 64.0 grow_horizontal = 2 grow_vertical = 2 -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 texture = ExtResource( 3 ) -stretch_mode = 0 [node name="Icon" type="TextureRect" parent="Background"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_right = 128.0 margin_bottom = 128.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 texture = ExtResource( 4 ) expand = true stretch_mode = 5 +[node name="Tween" type="Tween" parent="."] + [node name="AnimationPlayer" type="AnimationPlayer" parent="."] -root_node = NodePath("..") -autoplay = "" -playback_process_mode = 1 -playback_default_blend_time = 0.0 -playback_speed = 1.0 anims/disable = SubResource( 1 ) anims/highlight = SubResource( 2 ) anims/reduce = SubResource( 3 ) anims/wait = SubResource( 4 ) -blend_times = [ ] diff --git a/godot/combat/interface/turn_order/background-inactive.png.import b/godot/combat/interface/turn_order/background-inactive.png.import new file mode 100644 index 0000000000000000000000000000000000000000..5963cee759fe7ab67ffc66533e40185a4e155a44 --- /dev/null +++ b/godot/combat/interface/turn_order/background-inactive.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/background-inactive.png-f365e960ed0f4d93eebd349f2b1ab1bd.stex" + +[deps] + +source_file="res://combat/interface/turn_order/background-inactive.png" +dest_files=[ "res://.import/background-inactive.png-f365e960ed0f4d93eebd349f2b1ab1bd.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/combat/interface/turn_order/background-selected.png.import b/godot/combat/interface/turn_order/background-selected.png.import new file mode 100644 index 0000000000000000000000000000000000000000..96c536ba08bd604a3d3db4139593b0ecf91dd851 --- /dev/null +++ b/godot/combat/interface/turn_order/background-selected.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/background-selected.png-56d93b531adc5bdc99b80a90643ae2b9.stex" + +[deps] + +source_file="res://combat/interface/turn_order/background-selected.png" +dest_files=[ "res://.import/background-selected.png-56d93b531adc5bdc99b80a90643ae2b9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/combat/interface/turn_order/circle.png.import b/godot/combat/interface/turn_order/circle.png.import new file mode 100644 index 0000000000000000000000000000000000000000..1c542b8ad3d987aae7b2ae7ed03a6d104ec04b17 --- /dev/null +++ b/godot/combat/interface/turn_order/circle.png.import @@ -0,0 +1,31 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/circle.png-a7461eb0295c721ff12c3413354218a2.stex" + +[deps] + +source_file="res://combat/interface/turn_order/circle.png" +dest_files=[ "res://.import/circle.png-a7461eb0295c721ff12c3413354218a2.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/godot/interface/game_over/GameOverInterface.gd b/godot/interface/game_over/GameOverInterface.gd new file mode 100644 index 0000000000000000000000000000000000000000..46ee624c060a31d9f4aa7fc38d11d13f9e9ff0ff --- /dev/null +++ b/godot/interface/game_over/GameOverInterface.gd @@ -0,0 +1,70 @@ +extends CanvasLayer +class_name GameOverInterface + +signal restart_requested() + +onready var panel : = $Panel as Panel +onready var tween : = $Tween as Tween +onready var selection_arrow : = $Panel/SelectionArrow as Control +onready var message_label : = $Panel/VBoxContainer/Message as Label +onready var try_again_button : = $Panel/VBoxContainer/Options/TryAgain as Button +onready var options : = $Panel/VBoxContainer/Options + +enum Reason { PARTY_DEFEATED } + +const MESSAGES = { + 'party_defeated': 'Your party was defeated!' +} + +var buttons = [] +var selected_button_index : = 0 + +func _ready() -> void: + buttons = options.get_children() + _move_arrow() + +func _unhandled_input(event) -> void: + if not panel.visible: + return + if event.is_action_pressed("ui_up"): + selected_button_index = max(selected_button_index - 1, 0) + _move_arrow() + elif event.is_action_pressed("ui_down"): + selected_button_index = min(selected_button_index + 1, buttons.size() - 1) + _move_arrow() + elif event.is_action_pressed("ui_accept"): + buttons[selected_button_index].emit_signal("pressed") + +func _move_arrow() -> void: + var move_to = _get_arrow_position(selected_button_index) + tween.interpolate_property(selection_arrow, + "rect_global_position", + selection_arrow.rect_global_position, + move_to, + 0.1, + Tween.TRANS_QUART, + Tween.EASE_OUT + ) + tween.start() + +func display(reason) -> void: + match reason: + Reason.PARTY_DEFEATED: + message_label.text = MESSAGES['party_defeated'] + panel.show() + +func hide() -> void: + panel.hide() + +func _on_Exit_pressed() -> void: + get_tree().quit() + +func _on_TryAgain_pressed(): + emit_signal("restart_requested") + +func _on_Load_pressed(): + print("IMPLEMENT LOAD GAME FUNCTIONALITY") + +func _get_arrow_position(button_index : int = 0) -> Vector2: + return buttons[button_index].get_global_rect().position + \ No newline at end of file diff --git a/godot/interface/game_over/GameOverInterface.tscn b/godot/interface/game_over/GameOverInterface.tscn new file mode 100644 index 0000000000000000000000000000000000000000..7fdf9cd8467060480ea3c155f5252a366c8041a7 --- /dev/null +++ b/godot/interface/game_over/GameOverInterface.tscn @@ -0,0 +1,124 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://interface/game_over/GameOverInterface.gd" type="Script" id=1] +[ext_resource path="res://assets/fonts/default_theme/montserrat_eb_128.tres" type="DynamicFont" id=2] +[ext_resource path="res://assets/fonts/default_theme/montserrat_eb_64.tres" type="DynamicFont" id=3] +[ext_resource path="res://assets/fonts/default_theme/montserrat_eb_48.tres" type="DynamicFont" id=4] +[ext_resource path="res://assets/sprites/select_arrow.png" type="Texture" id=5] + +[sub_resource type="Animation" id=1] + +resource_name = "wiggle" +length = 0.5 +loop = true +step = 0.05 +tracks/0/type = "value" +tracks/0/path = NodePath("TextureRect:rect_position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.25, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( -80, 0 ), Vector2( -120, 0 ), Vector2( -80, 0 ) ] +} + +[node name="GameOverInterface" type="CanvasLayer"] +layer = 2 +script = ExtResource( 1 ) + +[node name="Panel" type="Panel" parent="."] +visible = false +self_modulate = Color( 0.203922, 0.0470588, 0.0470588, 0.870588 ) +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="Panel"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 25.0 +margin_top = 25.0 +margin_right = -25.0 +margin_bottom = -25.0 + +[node name="GameOver" type="Label" parent="Panel/VBoxContainer"] +margin_top = 91.0 +margin_right = 1870.0 +margin_bottom = 248.0 +size_flags_vertical = 6 +custom_fonts/font = ExtResource( 2 ) +text = "GAME OVER" +align = 1 +valign = 1 +uppercase = true + +[node name="Message" type="Label" parent="Panel/VBoxContainer"] +margin_top = 344.0 +margin_right = 1870.0 +margin_bottom = 423.0 +size_flags_vertical = 2 +custom_fonts/font = ExtResource( 3 ) +text = "Your party was defeated" +align = 1 +valign = 1 +uppercase = true + +[node name="Options" type="VBoxContainer" parent="Panel/VBoxContainer"] +margin_top = 688.0 +margin_right = 1870.0 +margin_bottom = 1030.0 +size_flags_vertical = 3 + +[node name="TryAgain" type="Button" parent="Panel/VBoxContainer/Options"] +margin_left = 788.0 +margin_right = 1081.0 +margin_bottom = 66.0 +size_flags_horizontal = 6 +size_flags_vertical = 0 +custom_fonts/font = ExtResource( 4 ) +text = "TRY AGAIN" +flat = true + +[node name="Load" type="Button" parent="Panel/VBoxContainer/Options"] +margin_left = 771.0 +margin_top = 70.0 +margin_right = 1098.0 +margin_bottom = 136.0 +size_flags_horizontal = 6 +size_flags_vertical = 0 +custom_fonts/font = ExtResource( 4 ) +text = "LOAD GAME" +flat = true + +[node name="Exit" type="Button" parent="Panel/VBoxContainer/Options"] +margin_left = 872.0 +margin_top = 140.0 +margin_right = 997.0 +margin_bottom = 206.0 +size_flags_horizontal = 6 +size_flags_vertical = 0 +custom_fonts/font = ExtResource( 4 ) +text = "EXIT" +flat = true + +[node name="SelectionArrow" type="Control" parent="Panel"] +editor/display_folded = true + +[node name="TextureRect" type="TextureRect" parent="Panel/SelectionArrow"] +margin_left = -90.4984 +margin_right = -29.4984 +margin_bottom = 61.0 +rect_pivot_offset = Vector2( 30, 30 ) +texture = ExtResource( 5 ) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Panel/SelectionArrow"] +autoplay = "wiggle" +anims/wiggle = SubResource( 1 ) + +[node name="Tween" type="Tween" parent="."] + +[connection signal="pressed" from="Panel/VBoxContainer/Options/TryAgain" to="." method="_on_TryAgain_pressed"] +[connection signal="pressed" from="Panel/VBoxContainer/Options/Load" to="." method="_on_Load_pressed"] +[connection signal="pressed" from="Panel/VBoxContainer/Options/Exit" to="." method="_on_Exit_pressed"] diff --git a/godot/project.godot b/godot/project.godot index 8cfab9ae5e473234ffac42e5d4313756456e06cf..c563e931e71de3db66f771e36af5729bc4bfc37a 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -84,6 +84,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://local_map/grid/GameBoard.gd" }, { +"base": "CanvasLayer", +"class": "GameOverInterface", +"language": "GDScript", +"path": "res://interface/game_over/GameOverInterface.gd" +}, { "base": "Resource", "class": "GrowthStats", "language": "GDScript", @@ -210,6 +215,7 @@ _global_script_class_icons={ "Equipment": "", "Formation": "", "GameBoard": "", +"GameOverInterface": "", "GrowthStats": "", "Hit": "", "InteractivePawn": "",