Skip to content

Commit

Permalink
Build heal scene VFX and player healing
Browse files Browse the repository at this point in the history
  • Loading branch information
Turtyo committed Dec 29, 2024
1 parent 03658fe commit b003545
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 5 deletions.
45 changes: 42 additions & 3 deletions #Scenes/Events/heal/0.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://lsl3jisfwkv3"]
[gd_scene load_steps=10 format=3 uid="uid://lsl3jisfwkv3"]

[ext_resource type="Texture2D" uid="uid://l2inhsx8dlr5" path="res://Art/Background/0-0.heal_draft.jpg" id="1_61rka"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/HealScene.gd" id="1_isnfr"]
[ext_resource type="PackedScene" uid="uid://dfgne15xrjxj5" path="res://Entity/Player/Player_no_display.tscn" id="2_0yvlf"]
[ext_resource type="Texture2D" uid="uid://dyl73uovgv6b4" path="res://Art/Menus/button_cat_nap.png" id="2_yaj7y"]
[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="3_bfejb"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/HealEventButton.gd" id="3_wdecl"]
[ext_resource type="Script" path="res://UI/HealthLabel.gd" id="6_7jv0v"]

[sub_resource type="Gradient" id="Gradient_78fca"]

[sub_resource type="GradientTexture2D" id="GradientTexture2D_arntt"]
gradient = SubResource("Gradient_78fca")

[node name="Control" type="Control"]
layout_mode = 3
Expand All @@ -10,6 +20,9 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_isnfr")

[node name="Player_no_display" parent="." instance=ExtResource("2_0yvlf")]

[node name="BG" type="TextureRect" parent="."]
layout_mode = 1
Expand All @@ -28,12 +41,38 @@ anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -512.0
offset_top = -384.0
offset_top = -167.0
offset_right = 512.0
offset_bottom = 384.0
offset_bottom = 167.0
grow_horizontal = 2
grow_vertical = 2
texture_normal = ExtResource("2_yaj7y")
texture_pressed = ExtResource("2_yaj7y")
texture_hover = ExtResource("2_yaj7y")
texture_focused = ExtResource("2_yaj7y")
script = ExtResource("3_wdecl")

[node name="TopBarOverlay" parent="." instance=ExtResource("3_bfejb")]
layout_mode = 1
offset_bottom = -984.0

[node name="HealthLabel" type="Label" parent="."]
layout_mode = 0
offset_left = 107.0
offset_top = 59.0
offset_right = 471.0
offset_bottom = 255.0
theme_override_font_sizes/font_size = 120
text = "100/100"
script = ExtResource("6_7jv0v")

[node name="BlackOverlay" type="TextureRect" parent="."]
modulate = Color(0, 0, 0, 1)
custom_minimum_size = Vector2(1920, 1080)
layout_mode = 0
offset_right = 1920.0
offset_bottom = 1080.0
mouse_filter = 2
texture = SubResource("GradientTexture2D_arntt")

[connection signal="pressed" from="TextureButton" to="TextureButton" method="_on_pressed"]
28 changes: 28 additions & 0 deletions #Scenes/SceneScripts/HealEventButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extends TextureButton

var button_has_been_pressed: bool
@onready var black_overlay: TextureRect = $"../BlackOverlay"

func _ready() -> void:
black_overlay.modulate.a = 0
button_has_been_pressed = false

func _on_pressed() -> void:
var tween_to_black: Tween = get_tree().create_tween()
# turn screen black
tween_to_black.tween_property(black_overlay, "modulate:a", 1, 2)
var player_health_comp: HealthComponent = PlayerManager.player.get_health_component()
var max_health: int = player_health_comp.max_health
var heal_amount: int = ceil(max_health * 0.25)

# wait for screen to be black before healing
await tween_to_black.finished
player_health_comp.heal(heal_amount, null)
# wait a bit
await get_tree().create_timer(2).timeout

var tween_to_clear: Tween = get_tree().create_tween()
# remove black screen
tween_to_clear.tween_property(black_overlay, "modulate:a", 0, 3)
PlayerManager.player_room.room_event.on_event_ended()

1 change: 1 addition & 0 deletions #Scenes/SceneScripts/HealScene.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends Control

# If you are searching for the actual logic of the event, look at the script for the button
func _ready() -> void:
AudioManager.start_music(GlobalEnums.MusicTrack.HEAL)
SaveManager.execute_save()
4 changes: 2 additions & 2 deletions #Scenes/credits.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
[ext_resource type="AnimationLibrary" uid="uid://dfkng08hfjpdv" path="res://Art/Animation/credits/In.res" id="11_xdj82"]
[ext_resource type="AnimationLibrary" uid="uid://jlt8btc7fx2j" path="res://Art/Animation/credits/Out.res" id="12_8iix6"]

[sub_resource type="Gradient" id="Gradient_78fca"]
[sub_resource type="Gradient" id="Gradient_s6c1g"]

[sub_resource type="GradientTexture2D" id="GradientTexture2D_1cbhb"]
gradient = SubResource("Gradient_78fca")
gradient = SubResource("Gradient_s6c1g")

[sub_resource type="Animation" id="Animation_2v08l"]
length = 0.001
Expand Down
Binary file modified Art/Menus/button_cat_nap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Entity/Player/Player_no_display.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[gd_scene load_steps=6 format=3 uid="uid://dfgne15xrjxj5"]

[ext_resource type="Script" path="res://Entity/Player/Player.gd" id="1_hhmvh"]
[ext_resource type="Script" path="res://Entity/Components/StatComponent.gd" id="2_4y02h"]
[ext_resource type="Script" path="res://Entity/Components/StatusComponent.gd" id="3_2wp1t"]
[ext_resource type="Script" path="res://Entity/Components/HealthComponent.gd" id="4_kof7q"]
[ext_resource type="Script" path="res://Entity/Components/PartyComponent.gd" id="8_4i7ll"]

[node name="Player_no_display" type="Node2D"]
script = ExtResource("1_hhmvh")

[node name="StatComponent" type="Node" parent="."]
script = ExtResource("2_4y02h")

[node name="StatusComponent" type="Node" parent="."]
script = ExtResource("3_2wp1t")

[node name="HealthComponent" type="Node" parent="."]
script = ExtResource("4_kof7q")

[node name="PartyComponent" type="Node" parent="."]
script = ExtResource("8_4i7ll")
team = 1
3 changes: 3 additions & 0 deletions UI/HealthLabel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ extends Label


func _ready() -> void:
# default to showing player health
if health_component == null:
health_component = PlayerManager.player.get_health_component()
health_component.on_health_changed.connect(_set_health)
_set_health(health_component.current_health)

Expand Down

0 comments on commit b003545

Please sign in to comment.