Add victory/lose panel
This commit is contained in:
parent
47e5caf3d3
commit
9a28f39d21
|
@ -57,6 +57,12 @@ var additional_attacks = 0
|
|||
@onready var gui_collected_upgrades = $GUILayer/GUI/CollectedUpgrades
|
||||
@onready var item_container = preload("res://Player/GUI/item_container.tscn")
|
||||
|
||||
@onready var death_panel = $GUILayer/GUI/DeathPanel
|
||||
@onready var result_label = $GUILayer/GUI/DeathPanel/ResultLabel
|
||||
@onready var victory_sound = $GUILayer/GUI/DeathPanel/VictorySound
|
||||
@onready var lose_sound = $GUILayer/GUI/DeathPanel/LoseSound
|
||||
|
||||
|
||||
func _ready():
|
||||
# Give character an initial attack.
|
||||
upgrade_character("icespear1")
|
||||
|
@ -108,6 +114,8 @@ func _on_hurt_box_hurt(damage, _angle, _knockback):
|
|||
hp -= clamp(damage - armor, 1, 999)
|
||||
health_bar.max_value = max_hp
|
||||
health_bar.value = hp
|
||||
if hp <= 0:
|
||||
death()
|
||||
|
||||
|
||||
func _on_ice_spear_timer_timeout():
|
||||
|
@ -364,3 +372,16 @@ func adjust_gui_collection(upgrade):
|
|||
gui_collected_weapons.add_child(new_item)
|
||||
"upgrade":
|
||||
gui_collected_upgrades.add_child(new_item)
|
||||
|
||||
|
||||
func death():
|
||||
death_panel.visible = true
|
||||
get_tree().paused = true
|
||||
var tween = death_panel.create_tween()
|
||||
tween.tween_property(death_panel, "position", Vector2(220, 50), 3).set_trans(Tween.TRANS_QUINT).set_ease(Tween.EASE_OUT)
|
||||
if time >= 300:
|
||||
result_label.text = "You Win"
|
||||
victory_sound.play()
|
||||
else:
|
||||
result_label.text = "You Lose"
|
||||
lose_sound.play()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://c7beni84qxntd"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://c7beni84qxntd"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c5w583adbgw1w" path="res://Textures/Player/player_sprite.png" id="1_0ulfs"]
|
||||
[ext_resource type="Script" path="res://Player/player.gd" id="1_jhdom"]
|
||||
|
@ -9,6 +9,9 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bess15ttkhhnm" path="res://Textures/GUI/healthbar.png" id="7_2c0tk"]
|
||||
[ext_resource type="AudioStream" uid="uid://dolvyolpvfqd0" path="res://Audio/SoundEffect/levelup.ogg" id="7_hhoj0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkn7xe4wxv5dt" path="res://Textures/GUI/health.png" id="8_yql0v"]
|
||||
[ext_resource type="AudioStream" uid="uid://bt28qxqanolo2" path="res://Audio/SoundEffect/Victory.wav" id="10_oirqa"]
|
||||
[ext_resource type="AudioStream" uid="uid://dp0oh17n8q8ca" path="res://Audio/SoundEffect/Lose.ogg" id="11_xkbpw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl40punn4yr8d" path="res://Utility/basic_button.tscn" id="12_go8l1"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_fj6pd"]
|
||||
radius = 4.0
|
||||
|
@ -156,6 +159,40 @@ offset_bottom = 100.0
|
|||
stream = ExtResource("7_hhoj0")
|
||||
volume_db = -10.0
|
||||
|
||||
[node name="DeathPanel" type="Panel" parent="GUILayer/GUI"]
|
||||
process_mode = 2
|
||||
layout_mode = 0
|
||||
offset_left = 220.0
|
||||
offset_top = -335.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = -85.0
|
||||
|
||||
[node name="ResultLabel" type="Label" parent="GUILayer/GUI/DeathPanel"]
|
||||
layout_mode = 0
|
||||
offset_top = 1.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 51.0
|
||||
theme_override_fonts/font = ExtResource("6_4p8au")
|
||||
text = "Result"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="VictorySound" type="AudioStreamPlayer" parent="GUILayer/GUI/DeathPanel"]
|
||||
stream = ExtResource("10_oirqa")
|
||||
volume_db = -10.0
|
||||
|
||||
[node name="LoseSound" type="AudioStreamPlayer" parent="GUILayer/GUI/DeathPanel"]
|
||||
stream = ExtResource("11_xkbpw")
|
||||
volume_db = -10.0
|
||||
|
||||
[node name="MenuButton" parent="GUILayer/GUI/DeathPanel" instance=ExtResource("12_go8l1")]
|
||||
layout_mode = 0
|
||||
offset_left = 60.0
|
||||
offset_top = 200.0
|
||||
offset_right = 140.0
|
||||
offset_bottom = 230.0
|
||||
text = "Menu"
|
||||
|
||||
[node name="TimerLabel" type="Label" parent="GUILayer/GUI"]
|
||||
layout_mode = 0
|
||||
offset_left = 280.0
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
extends Button
|
||||
|
||||
signal click_end()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_mouse_entered():
|
||||
$HoverSound.play()
|
||||
|
||||
|
||||
func _on_pressed():
|
||||
$ClickSound.play()
|
||||
|
||||
|
||||
func _on_click_sound_finished():
|
||||
click_end.emit()
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://dl40punn4yr8d"]
|
||||
|
||||
[ext_resource type="Script" path="res://Utility/basic_button.gd" id="1_du0tm"]
|
||||
[ext_resource type="FontFile" uid="uid://c0h5wipmbmg66" path="res://Font/tenderness.otf" id="1_r717l"]
|
||||
[ext_resource type="AudioStream" uid="uid://bdjrp6d7yc077" path="res://Audio/GUI/hover.wav" id="1_ughvv"]
|
||||
[ext_resource type="AudioStream" uid="uid://cafrvl7mvkc4g" path="res://Audio/GUI/click.wav" id="2_7iq3u"]
|
||||
|
||||
[node name="BasicButton" type="Button"]
|
||||
custom_minimum_size = Vector2(80, 30)
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
theme_override_fonts/font = ExtResource("1_r717l")
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "Example"
|
||||
script = ExtResource("1_du0tm")
|
||||
|
||||
[node name="HoverSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("1_ughvv")
|
||||
|
||||
[node name="ClickSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("2_7iq3u")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="pressed" from="." to="." method="_on_pressed"]
|
||||
[connection signal="finished" from="ClickSound" to="." method="_on_click_sound_finished"]
|
Loading…
Reference in New Issue