Peek at life bar when damaged

This commit is contained in:
Rob Kelly 2024-11-19 22:25:45 -07:00
parent 70da540e25
commit be07ce40ed
3 changed files with 148 additions and 75 deletions

View File

@ -401,7 +401,6 @@ func _on_phase_change(new_phase: Phase) -> void:
Phase.FINISHED:
hud.power_bar.hide()
hud.curve_bar.hide()
travel_to_ball()
finished.emit(self)
@ -503,6 +502,7 @@ func _process(delta: float) -> void:
func _on_ball_sleeping_state_changed() -> void:
if game_ball.sleeping and phase == Phase.SHOT:
travel_to_ball()
end_shot_track()

View File

@ -14,20 +14,19 @@ var player: WorldPlayer
@onready var club_selector: ClubSelector = %ClubSelector
@onready var hud_state_machine: AnimationTree = %HUDStateMachine
@onready var _curve_animation: AnimationPlayer = %CurveAnimation
@onready var _power_animation: AnimationPlayer = %PowerAnimation
@onready var _nice_animation: AnimationPlayer = %NiceAnimation
@onready var _wasted_animation: AnimationPlayer = %WastedAnimation
@onready var _club_selector_animation: AnimationPlayer = %ClubSelectorAnimation
@onready var _sw_animation: AnimationPlayer = %SWAnimation
@onready var _player_name: Label = %PlayerName
@onready var _life_bar_rumbler: Rumbler = %LifeBarRumbler
@onready var _state: AnimationNodeStateMachinePlayback = hud_state_machine["parameters/playback"]
static var scene: PackedScene = preload("res://src/ui/shot_hud/shot_hud.tscn")
@ -43,11 +42,17 @@ func _ready() -> void:
func show_hud() -> void:
_state.travel("visible")
_club_selector_animation.play("show")
_sw_animation.play("show")
func hide_hud() -> void:
_state.travel("hidden")
_club_selector_animation.play("hide")
_sw_animation.play("hide")
func peek_life_bar() -> void:
_sw_animation.play("peek")
func start_power_bar() -> void:
@ -89,6 +94,7 @@ func set_life_value(new_value: float) -> void:
var difference := new_value - life_bar.value
if difference < 0:
# Taking damage
peek_life_bar()
_life_bar_rumbler.intensity = LIFE_BAR_DAMAGE_RUMBLE_SCALE * abs(difference)
var tween := get_tree().create_tween()
(

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=33 format=3 uid="uid://c4ifdiohng830"]
[gd_scene load_steps=32 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"]
@ -376,12 +376,13 @@ _data = {
"fill": SubResource("Animation_uo6s7")
}
[sub_resource type="Animation" id="Animation_3cn2c"]
[sub_resource type="Animation" id="Animation_4h8gq"]
resource_name = "RESET"
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("ClubSelector:rotation")
tracks/0/path = NodePath(".:rotation")
tracks/0/interp = 4
tracks/0/loop_wrap = true
tracks/0/keys = {
@ -390,27 +391,15 @@ tracks/0/keys = {
"update": 0,
"values": [0.0]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 982)]
}
[sub_resource type="Animation" id="Animation_dt1yq"]
resource_name = "hide"
[sub_resource type="Animation" id="Animation_w7dmn"]
resource_name = "hide_selector"
length = 0.4
step = 0.02
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("ClubSelector:rotation")
tracks/0/path = NodePath(".:rotation")
tracks/0/interp = 4
tracks/0/loop_wrap = true
tracks/0/keys = {
@ -419,27 +408,15 @@ tracks/0/keys = {
"update": 0,
"values": [0.0, 0.0872665, -1.5708]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:position")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.4),
"transitions": PackedFloat32Array(1.618, 1.618, 1),
"update": 0,
"values": [Vector2(0, 982), Vector2(0, 960), Vector2(0, 1100)]
}
[sub_resource type="Animation" id="Animation_0maif"]
[sub_resource type="Animation" id="Animation_x6kyr"]
resource_name = "show"
length = 0.4
step = 0.02
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("ClubSelector:rotation")
tracks/0/path = NodePath(".:rotation")
tracks/0/interp = 4
tracks/0/loop_wrap = true
tracks/0/keys = {
@ -448,49 +425,137 @@ tracks/0/keys = {
"update": 0,
"values": [-1.5708, 0.0872665, 0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5nauw"]
_data = {
"RESET": SubResource("Animation_4h8gq"),
"hide": SubResource("Animation_w7dmn"),
"show": SubResource("Animation_x6kyr")
}
[sub_resource type="Animation" id="Animation_3cn2c"]
resource_name = "RESET"
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("SouthWest:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 982)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:position")
tracks/1/interp = 2
tracks/1/path = NodePath("SouthWest:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_yis4x"]
resource_name = "hide_health_bar"
length = 0.4
step = 0.02
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("SouthWest:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.4),
"transitions": PackedFloat32Array(1.618, 1.618, 1),
"update": 0,
"values": [Vector2(0, 982), Vector2(0, 960), Vector2(0, 1100)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.4),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="Animation" id="Animation_nicro"]
resource_name = "show_life_bar"
length = 0.4
step = 0.02
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("SouthWest:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.34, 0.4),
"transitions": PackedFloat32Array(1.618, 1.618, 1),
"update": 0,
"values": [Vector2(0, 1100), Vector2(0, 960), Vector2(0, 982)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_jugqx"]
resource_name = "peek"
length = 2.4
step = 0.02
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("SouthWest:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 2.3, 2.4),
"transitions": PackedFloat32Array(1.618, 1, 1.618, 1),
"update": 0,
"values": [Vector2(0, 1100), Vector2(0, 982), Vector2(0, 982), Vector2(0, 1100)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("SouthWest:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 2.4),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_c3i4w"]
_data = {
"RESET": SubResource("Animation_3cn2c"),
"hide": SubResource("Animation_dt1yq"),
"show": SubResource("Animation_0maif")
"hide": SubResource("Animation_yis4x"),
"peek": SubResource("Animation_jugqx"),
"show": SubResource("Animation_nicro")
}
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_8uxnp"]
animation = &"hide"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_v05eu"]
animation = &"show"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_bj7v0"]
switch_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xpwgd"]
switch_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_3o88y"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_osrbp"]
states/hidden/node = SubResource("AnimationNodeAnimation_8uxnp")
states/hidden/position = Vector2(378, 100)
states/visible/node = SubResource("AnimationNodeAnimation_v05eu")
states/visible/position = Vector2(597, 100)
transitions = ["visible", "hidden", SubResource("AnimationNodeStateMachineTransition_bj7v0"), "hidden", "visible", SubResource("AnimationNodeStateMachineTransition_xpwgd"), "Start", "hidden", SubResource("AnimationNodeStateMachineTransition_3o88y")]
graph_offset = Vector2(-309, -132)
[node name="ShotHUD" type="Control"]
layout_mode = 3
anchors_preset = 15
@ -685,15 +750,21 @@ grow_horizontal = 1
grow_vertical = 1
pivot_offset = Vector2(-400, 0)
[node name="ClubSelectorAnimation" type="AnimationPlayer" parent="ClubSelector"]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_5nauw")
}
[node name="SouthWest" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_top = 1.0
anchor_right = 0.333
anchor_bottom = 1.0
offset_top = 18.6812
offset_top = 20.0
offset_right = 40.0
offset_bottom = 116.681
offset_bottom = 118.0
grow_vertical = 0
theme_override_constants/margin_left = 16
theme_override_constants/margin_bottom = 16
@ -735,13 +806,9 @@ script = ExtResource("3_6groq")
unique_name_in_owner = true
layout_mode = 1
[node name="HUDAnimation" type="AnimationPlayer" parent="."]
[node name="SWAnimation" type="AnimationPlayer" parent="SouthWest"]
unique_name_in_owner = true
root_node = NodePath("../..")
libraries = {
"": SubResource("AnimationLibrary_c3i4w")
}
[node name="HUDStateMachine" type="AnimationTree" parent="."]
unique_name_in_owner = true
root_node = NodePath("%HUDStateMachine/..")
tree_root = SubResource("AnimationNodeStateMachine_osrbp")
anim_player = NodePath("../HUDAnimation")