generated from krampus/template-godot4
Play SFX & animate life bar on heal
This commit is contained in:
parent
45c8194bbd
commit
967db4a303
|
@ -126,3 +126,11 @@ Asset credits
|
|||
*** Author: soneproject
|
||||
|
||||
*** License: CC BY 3.0
|
||||
|
||||
** heal.wav
|
||||
|
||||
*** Retrieved from https://freesound.org/people/lulyc/sounds/346116/
|
||||
|
||||
*** Author: lulyc
|
||||
|
||||
*** License CC0
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://csbrinugqepk3"
|
||||
path="res://.godot/imported/heal.wav-f1b0fa8bf42c414c0e735c123bc00fea.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/player/heal.wav"
|
||||
dest_files=["res://.godot/imported/heal.wav-f1b0fa8bf42c414c0e735c123bc00fea.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
|
@ -7,11 +7,16 @@ const NICE_ALERT_SCENE := preload("res://src/ui/shot_hud/nice_alert.tscn")
|
|||
const LIFE_BAR_DAMAGE_RUMBLE_SCALE := 0.2
|
||||
## Time it takes to dampen the life bar rumble on taking damage, in seconds
|
||||
const LIFE_BAR_DAMAGE_RUMBLE_TIME := 0.2
|
||||
## Time from restoring health to starting to fill the life bar, in seconds
|
||||
const LIFE_BAR_HEAL_DELAY := 0.8
|
||||
## Time it takes the life bar to fill when restoring life, in seconds
|
||||
const LIFE_BAR_HEAL_TIME := 1.0
|
||||
|
||||
var player: WorldPlayer
|
||||
|
||||
@onready var power_bar: TextureProgressBar = %PowerBar
|
||||
@onready var curve_bar: CurveBar = %CurveBar
|
||||
|
||||
@onready var life_bar: TextureProgressBar = %LifeBar
|
||||
@onready var life_particles: HUDParticles = %LifeParticles
|
||||
|
||||
|
@ -34,6 +39,8 @@ var player: WorldPlayer
|
|||
|
||||
@onready var _life_bar_rumbler: Rumbler = %LifeBarRumbler
|
||||
|
||||
@onready var _heal_sfx: AudioStreamPlayer = %HealSFX
|
||||
|
||||
static var scene: PackedScene = preload("res://src/ui/shot_hud/shot_hud.tscn")
|
||||
|
||||
|
||||
|
@ -126,11 +133,15 @@ func set_life_value(new_value: float) -> void:
|
|||
. tween_property(_life_bar_rumbler, "intensity", 0, LIFE_BAR_DAMAGE_RUMBLE_TIME)
|
||||
. set_trans(Tween.TRANS_CUBIC)
|
||||
)
|
||||
life_bar.value = new_value
|
||||
elif difference > 0:
|
||||
# Restoring health
|
||||
# TODO: something for this?
|
||||
pass
|
||||
life_bar.value = new_value
|
||||
var tween := get_tree().create_tween()
|
||||
tween.tween_interval(LIFE_BAR_HEAL_DELAY)
|
||||
tween.tween_callback(_heal_sfx.play)
|
||||
tween.tween_property(life_bar, "value", new_value, LIFE_BAR_HEAL_TIME).set_trans(
|
||||
Tween.TRANS_CUBIC
|
||||
)
|
||||
|
||||
|
||||
static func create(_player: WorldPlayer) -> ShotHUD:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=45 format=3 uid="uid://c4ifdiohng830"]
|
||||
[gd_scene load_steps=46 format=3 uid="uid://c4ifdiohng830"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/shot_hud/shot_hud.gd" id="1_x5b4c"]
|
||||
[ext_resource type="Shader" path="res://src/shaders/canvas_retro.gdshader" id="1_ybxxp"]
|
||||
|
@ -16,6 +16,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://dtsdecae83ah3" path="res://assets/sprites/particles/ball.png" id="12_fdbqt"]
|
||||
[ext_resource type="PackedScene" uid="uid://b47goj32i6sdh" path="res://src/ui/elements/input_prompt/input_prompt.tscn" id="14_ik4gg"]
|
||||
[ext_resource type="Texture2D" uid="uid://y07v10c8r1s6" path="res://assets/sprites/particles/health.png" id="15_eyqdi"]
|
||||
[ext_resource type="AudioStream" uid="uid://csbrinugqepk3" path="res://assets/sound/sfx/player/heal.wav" id="16_pub5c"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2gt87"]
|
||||
resource_name = "RESET"
|
||||
|
@ -813,6 +814,12 @@ grow_vertical = 2
|
|||
unique_name_in_owner = true
|
||||
texture = ExtResource("15_eyqdi")
|
||||
|
||||
[node name="HealSFX" type="AudioStreamPlayer" parent="SouthWest/VBoxContainer/MarginContainer/LifeBarRumbler/LifeBar"]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("16_pub5c")
|
||||
volume_db = -8.0
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="SWAnimation" type="AnimationPlayer" parent="SouthWest"]
|
||||
unique_name_in_owner = true
|
||||
root_node = NodePath("../..")
|
||||
|
|
|
@ -2,6 +2,7 @@ class_name PlayManager extends Resource
|
|||
## Abstract base type for strategies to manage the flow of gameplay
|
||||
|
||||
## Emitted at the start of each new turn
|
||||
@warning_ignore("unused_signal")
|
||||
signal turn_started(player: WorldPlayer)
|
||||
|
||||
## List of game player instances
|
||||
|
|
Loading…
Reference in New Issue