diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index 50f9a90..927be40 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -24,6 +24,8 @@ const FREE_CAM_RETURN_TIME := 0.618 const BALL_RETURN_TIME := 0.618 const CAMERA_SNAP_TIME := 0.3 +const WASTED_BALL_RETURN_DELAY := 3.5 + ## In Driving Range mode, the ball can be retrieved in the shot phase. @export var driving_range := false @@ -61,6 +63,10 @@ var invert_pitch: bool = ProjectSettings.get_setting("game/config/controls/camer var control_disabled := false +var hud: ShotHUD: + get: + return world.ui.shot_hud if world and world.ui else null + var phase: Phase: set(value): if value != phase: @@ -75,6 +81,18 @@ var club: Club.Type: var shot_ref: Node3D +var shot_power: float: + set(value): + hud.power_bar.value = value + get: + return hud.power_bar.value + +var shot_curve: float: + set(value): + hud.curve_bar.value = value + get: + return hud.power_bar.value + var _free_camera: FreeCamera var _returning_free_camera := false @@ -97,12 +115,6 @@ var _tracking_camera: OrbitalCamera @onready var arrow_animation: AnimationPlayer = %ArrowAnimation @onready var shot_projection: ProjectileArc = %ShotProjection -@onready var power_bar: ProgressBar = %PowerBar -@onready var power_animation: AnimationPlayer = %PowerAnimation - -@onready var curve_bar: ProgressBar = %CurveBar -@onready var curve_animation: AnimationPlayer = %CurveAnimation - @onready var ball_point: Node3D = %BallPoint @onready var physics_ball: GameBall = %PhysicsBall @@ -115,13 +127,7 @@ var _tracking_camera: OrbitalCamera @onready var putt_ref: RayCast3D = %PuttRef @onready var putt_arrow: Node3D = %PuttArrow -@onready var club_selector: ClubSelector = %ClubSelector - -@onready var nice_animation: AnimationPlayer = %NiceAnimation -@onready var wasted_animation: AnimationPlayer = %WastedAnimation - -@onready var hud_state_machine: AnimationTree = %HUDStateMachine -@onready var hud_state: AnimationNodeStateMachinePlayback = hud_state_machine["parameters/playback"] +@onready var ball_return_timer: Timer = %BallReturnTimer @onready var ball_impulse_debug: Node3D = %BallImpulseDebug @@ -130,14 +136,20 @@ var _tracking_camera: OrbitalCamera @onready var phys_ball_scene := preload("res://src/player/physics_ball/physics_ball.tscn") +@onready var world: World = get_tree().get_first_node_in_group(World.group) + @onready var _target_rotation := Vector2(pitch.rotation.x, direction.rotation.y) -func _ready() -> void: +func _init_deferred() -> void: _on_phase_change(phase) club = initial_club +func _ready() -> void: + call_deferred("_init_deferred") + + func _set_camera_distance(value: float) -> void: var tween := get_tree().create_tween() tween.tween_property(zoom, "position:z", value, ZOOM_LENGTH).set_trans(Tween.TRANS_SINE) @@ -178,9 +190,9 @@ func get_shot_impulse(meter_pct: float) -> Vector3: func take_shot() -> void: - print_debug("WHACK!\nPower: ", power_bar.value, "\nCurve: ", curve_bar.value) + print_debug("WHACK!\nPower: ", shot_power, "\nCurve: ", shot_curve) - var impulse := get_shot_impulse(power_bar.value) + var impulse := get_shot_impulse(shot_power) print_debug("Shot impulse: ", impulse, "; ", impulse.length(), " N*s") ball_impulse_debug.transform = ( @@ -206,7 +218,7 @@ func _show_shot_projection() -> void: func insert_free_cam() -> void: arrow_animation.play("hide") _show_shot_projection() - hud_state.travel("hidden") + hud.hide_hud() _free_camera = FreeCamera.create(camera) add_sibling(_free_camera) control_disabled = true @@ -220,7 +232,7 @@ func return_free_cam() -> void: if not keep_projection: shot_projection.hide() - hud_state.travel("visible") + hud.show_hud() _free_camera.queue_free() _free_camera = null control_disabled = false @@ -275,7 +287,7 @@ func _on_club_change(new_club: Club.Type) -> void: iron_arrow.hide() putt_arrow.hide() physics_ball.iron_ball = false - club_selector.value = new_club + hud.club_selector.value = new_club match new_club: Club.Type.DRIVER: shot_ref = drive_ref @@ -309,42 +321,42 @@ func _on_club_change(new_club: Club.Type) -> void: func _on_phase_change(new_phase: Phase) -> void: match new_phase: Phase.AIM: - hud_state.travel("visible") + hud.show_hud() if not arrow.visible: arrow_animation.play("show") camera.make_current() - power_bar.hide() - curve_bar.hide() + hud.power_bar.hide() + hud.curve_bar.hide() character.reset() Phase.POWER_ADJUST: - curve_bar.hide() + hud.curve_bar.hide() - power_bar.show() - power_animation.stop() # Reset if needed + hud.power_bar.show() + hud.reset_power_bar() # Reset if needed Phase.CURVE_ADJUST: - curve_bar.show() - curve_animation.play("fill") + hud.curve_bar.show() + hud.start_curve_bar() Phase.DOWNSWING: - power_bar.hide() - curve_bar.hide() + hud.power_bar.hide() + hud.curve_bar.hide() character.downswing() shot_animation.play("swing_delay") # calls `take_shot` Phase.SHOT: - power_bar.hide() - curve_bar.hide() + hud.power_bar.hide() + hud.curve_bar.hide() - nice_animation.play("display") + hud.play_nice_animation() if not driving_range: shot_animation.play("shoot") arrow_animation.play("hide") - hud_state.travel("hidden") + hud.hide_hud() take_shot() Phase.FINISHED: - power_bar.hide() - curve_bar.hide() + hud.power_bar.hide() + hud.curve_bar.hide() travel_to_ball() @@ -420,19 +432,19 @@ func _process(delta: float) -> void: if Input.is_action_just_pressed("shot_accept"): # TODO set power gauge parameters if needed character.start_upswing() - power_animation.play("fill") + hud.start_power_bar() if Input.is_action_just_pressed("ui_cancel"): - power_animation.stop() + hud.reset_power_bar() phase = Phase.AIM - if Input.is_action_just_released("shot_accept") and power_bar.value > 0: - power_animation.pause() + if Input.is_action_just_released("shot_accept") and shot_power > 0: + hud.stop_power_bar() phase = Phase.CURVE_ADJUST Phase.CURVE_ADJUST: if Input.is_action_just_pressed("ui_cancel"): - curve_animation.stop() + hud.reset_curve_bar() phase = Phase.POWER_ADJUST if Input.is_action_just_pressed("shot_accept"): - curve_animation.pause() + hud.stop_curve_bar() phase = Phase.DOWNSWING Phase.SHOT: if driving_range and Input.is_action_just_pressed("shot_accept"): @@ -452,7 +464,8 @@ func _on_ball_entered_water() -> void: # Should only be possible during SHOT phase, but let's check just to be sure... if phase == Phase.SHOT: physics_ball.freeze = true - wasted_animation.play("display") + hud.play_wasted_animation() + ball_return_timer.start(WASTED_BALL_RETURN_DELAY) func _on_physics_ball_body_entered(_body: Node) -> void: @@ -466,3 +479,7 @@ func _on_physics_ball_body_entered(_body: Node) -> void: add_sibling(_free_camera) control_disabled = true camera.current = false + + +func _on_ball_return_timer_timeout() -> void: + return_ball() diff --git a/src/player/shot_setup/shot_setup.tscn b/src/player/shot_setup/shot_setup.tscn index 4a145dd..3cc14d0 100644 --- a/src/player/shot_setup/shot_setup.tscn +++ b/src/player/shot_setup/shot_setup.tscn @@ -1,13 +1,11 @@ -[gd_scene load_steps=42 format=3 uid="uid://cy7t2tc4y3b4"] +[gd_scene load_steps=17 format=3 uid="uid://cy7t2tc4y3b4"] [ext_resource type="Script" path="res://src/player/shot_setup/shot_setup.gd" id="1_r6ei4"] [ext_resource type="PackedScene" uid="uid://dfttci386ohip" path="res://src/player/physics_ball/physics_ball.tscn" id="2_1i5j5"] [ext_resource type="PackedScene" uid="uid://c2k88ns0h5ie1" path="res://src/ui/arrow/arrow.tscn" id="2_s70wl"] [ext_resource type="PackedScene" uid="uid://1s3gywmoi20e" path="res://src/characters/player_characters/gfolf_girl/gfolf_girl.tscn" id="3_e4aur"] -[ext_resource type="PackedScene" uid="uid://445qd7m4qe2j" path="res://src/player/shot_setup/club_selector/club_selector.tscn" id="4_56ape"] [ext_resource type="PackedScene" uid="uid://fht6j87o8ecr" path="res://src/ui/projectile_arc/projectile_arc.tscn" id="4_ry2ho"] [ext_resource type="PackedScene" uid="uid://dbdul15c4oblg" path="res://src/ui/projected_target.tscn" id="6_mynqj"] -[ext_resource type="Shader" path="res://src/shaders/canvas_retro.gdshader" id="7_h6c4m"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lnol1"] albedo_color = Color(0, 0.537255, 1, 1) @@ -205,441 +203,6 @@ _data = { "swing_delay": SubResource("Animation_u8k07") } -[sub_resource type="Animation" id="Animation_3xds6"] -resource_name = "RESET" -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".:visible_ratio") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [1.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath(".:rotation") -tracks/2/interp = 3 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [7.31612e-10] -} -tracks/3/type = "bezier" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath(".:anchor_top") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} -tracks/4/type = "bezier" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".:anchor_bottom") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_cwotn"] -resource_name = "display" -length = 2.4 -step = 0.1 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 2.4), -"transitions": PackedFloat32Array(1, 1), -"update": 1, -"values": [true, false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".:visible_ratio") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 0.2), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 1.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath(".:rotation") -tracks/2/interp = 3 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 2, 2.4), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [7.31612e-10, 7.31612e-10, 0.174533] -} -tracks/3/type = "bezier" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath(".:anchor_top") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"handle_modes": PackedInt32Array(0, 0, 0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.0548477, 0.5, -0.4, 0.0593877, 0.233401, -0.456136, 1.25, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0, 2, 2.4) -} -tracks/4/type = "bezier" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".:anchor_bottom") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"handle_modes": PackedInt32Array(0, 0, 0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.055, 0.5, -0.4, 0.059, 0.233, -0.456, 1.25, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0, 2, 2.4) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_2a0gn"] -_data = { -"RESET": SubResource("Animation_3xds6"), -"display": SubResource("Animation_cwotn") -} - -[sub_resource type="Animation" id="Animation_2gt87"] -resource_name = "RESET" -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".:visible_ratio") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [1.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath(".:rotation") -tracks/2/interp = 3 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [7.31612e-10] -} -tracks/3/type = "bezier" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath(".:anchor_top") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} -tracks/4/type = "bezier" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".:anchor_bottom") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_g52q7"] -resource_name = "display" -length = 3.4 -step = 0.1 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 3.4), -"transitions": PackedFloat32Array(1, 1), -"update": 1, -"values": [true, false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".:visible_ratio") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 0.4), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [0.0, 1.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath(".:rotation") -tracks/2/interp = 3 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 3, 3.4), -"transitions": PackedFloat32Array(1, 0.618, 1), -"update": 0, -"values": [7.31612e-10, 7.31612e-10, -2.96706] -} -tracks/3/type = "bezier" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath(".:anchor_top") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"handle_modes": PackedInt32Array(0, 0, 0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.0548477, 0.5, -0.4, 0.0593877, 0.233401, -0.456136, 1.25, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0, 3, 3.4) -} -tracks/4/type = "bezier" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".:anchor_bottom") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"handle_modes": PackedInt32Array(0, 0, 0), -"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.055, 0.5, -0.4, 0.059, 0.233, -0.456, 1.25, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0, 3, 3.4) -} -tracks/5/type = "method" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("../..") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/keys = { -"times": PackedFloat32Array(3.4), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": [], -"method": &"return_ball" -}] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_gbnnr"] -_data = { -"RESET": SubResource("Animation_2gt87"), -"display": SubResource("Animation_g52q7") -} - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_afsun"] -shader = ExtResource("7_h6c4m") -shader_parameter/change_color_depth = true -shader_parameter/target_color_depth = 3 -shader_parameter/dithering = true -shader_parameter/scale_resolution = true -shader_parameter/target_resolution_scale = 3 -shader_parameter/enable_recolor = false - -[sub_resource type="Animation" id="Animation_pk1s7"] -length = 0.001 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:value") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_67gmp"] -resource_name = "fill" -length = 1.618 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:value") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0, 0), -"points": PackedFloat32Array(0, -0.25, 0, 0.233333, 0.0884774, 1, -0.267469, -0.483539, 0.25, 0), -"times": PackedFloat32Array(0, 1.618) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_coah5"] -_data = { -"RESET": SubResource("Animation_pk1s7"), -"fill": SubResource("Animation_67gmp") -} - -[sub_resource type="Animation" id="Animation_noa0w"] -length = 0.001 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("%CurveBar:value") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_uo6s7"] -resource_name = "fill" -length = 0.618 -loop_mode = 2 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("%CurveBar:value") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0, 0), -"points": PackedFloat32Array(-1, -0.25, 0, 0.3, 0, 1, -0.3, 0, 0.25, 0), -"times": PackedFloat32Array(0, 0.618) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_dicse"] -_data = { -"RESET": SubResource("Animation_noa0w"), -"fill": SubResource("Animation_uo6s7") -} - -[sub_resource type="Animation" id="Animation_3cn2c"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("%ClubSelector:rotation") -tracks/0/interp = 4 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [0.0] -} - -[sub_resource type="Animation" id="Animation_dt1yq"] -resource_name = "hide" -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/interp = 4 -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": [0.0, 0.0872665, -1.5708] -} - -[sub_resource type="Animation" id="Animation_0maif"] -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/interp = 4 -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": [-1.5708, 0.0872665, 0.0] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_c3i4w"] -_data = { -"RESET": SubResource("Animation_3cn2c"), -"hide": SubResource("Animation_dt1yq"), -"show": SubResource("Animation_0maif") -} - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_8uxnp"] -animation = &"hide" - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_v05eu"] -animation = &"show" - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_28a4x"] -advance_mode = 2 - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_bj7v0"] -switch_mode = 2 - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xpwgd"] -switch_mode = 2 - -[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_osrbp"] -states/hidden/node = SubResource("AnimationNodeAnimation_8uxnp") -states/hidden/position = Vector2(592, 100) -states/visible/node = SubResource("AnimationNodeAnimation_v05eu") -states/visible/position = Vector2(364, 100) -transitions = ["Start", "visible", SubResource("AnimationNodeStateMachineTransition_28a4x"), "visible", "hidden", SubResource("AnimationNodeStateMachineTransition_bj7v0"), "hidden", "visible", SubResource("AnimationNodeStateMachineTransition_xpwgd")] -graph_offset = Vector2(-309, -132) - [node name="ShotSetup" type="Node3D"] script = ExtResource("1_r6ei4") @@ -793,187 +356,11 @@ libraries = { "": SubResource("AnimationLibrary_u78hq") } -[node name="ShotUI" type="Control" parent="."] -top_level = true -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 1 - -[node name="WoahNiceFeedback" type="RichTextLabel" parent="ShotUI"] -visible = false -custom_minimum_size = Vector2(1200, 0) -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -350.0 -offset_top = -66.0 -offset_right = 350.0 -offset_bottom = 66.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -theme_type_variation = &"ShotFeedback" -bbcode_enabled = true -text = "[center][wave amp=64][rainbow]woah nice[/rainbow][/wave][/center]" -fit_content = true -autowrap_mode = 0 -visible_characters_behavior = 1 - -[node name="NiceAnimation" type="AnimationPlayer" parent="ShotUI/WoahNiceFeedback"] +[node name="BallReturnTimer" type="Timer" parent="."] unique_name_in_owner = true -libraries = { -"": SubResource("AnimationLibrary_2a0gn") -} - -[node name="WastedFeedback" type="RichTextLabel" parent="ShotUI"] -visible = false -custom_minimum_size = Vector2(1400, 0) -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -350.0 -offset_top = -66.0 -offset_right = 350.0 -offset_bottom = 66.0 -grow_horizontal = 2 -grow_vertical = 2 -pivot_offset = Vector2(100, 115) -mouse_filter = 2 -theme_type_variation = &"ShotFeedback" -bbcode_enabled = true -text = "[center][tornado radius=16][color=powder_blue]wasted[/color][/tornado][/center]" -fit_content = true -autowrap_mode = 0 -visible_characters_behavior = 1 - -[node name="WastedAnimation" type="AnimationPlayer" parent="ShotUI/WastedFeedback"] -unique_name_in_owner = true -libraries = { -"": SubResource("AnimationLibrary_gbnnr") -} - -[node name="ColorRect" type="ColorRect" parent="ShotUI"] -visible = false -material = SubResource("ShaderMaterial_afsun") -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 - -[node name="ShotGauges" type="Control" parent="ShotUI"] -layout_mode = 1 -anchor_left = 0.4 -anchor_top = 0.3 -anchor_right = 0.6 -anchor_bottom = 0.85 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 1 - -[node name="PowerGauge" type="Control" parent="ShotUI/ShotGauges"] -layout_mode = 1 -anchor_left = 0.5 -anchor_top = 0.382 -anchor_right = 0.5 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 1 - -[node name="PowerBar" type="ProgressBar" parent="ShotUI/ShotGauges/PowerGauge"] -unique_name_in_owner = true -visible = false -custom_minimum_size = Vector2(30, 0) -layout_mode = 1 -anchors_preset = 13 -anchor_left = 0.5 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -2.0 -offset_right = 2.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 1 -max_value = 1.0 -fill_mode = 2 - -[node name="PowerAnimation" type="AnimationPlayer" parent="ShotUI/ShotGauges/PowerGauge"] -unique_name_in_owner = true -root_node = NodePath("../PowerBar") -libraries = { -"": SubResource("AnimationLibrary_coah5") -} - -[node name="CurveGauge" type="Control" parent="ShotUI/ShotGauges"] -layout_mode = 1 -anchor_top = 0.25 -anchor_right = 1.0 -anchor_bottom = 0.25 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 1 - -[node name="CurveBar" type="ProgressBar" parent="ShotUI/ShotGauges/CurveGauge"] -unique_name_in_owner = true -visible = false -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -13.5 -offset_bottom = 13.5 -grow_horizontal = 2 -grow_vertical = 2 -min_value = -1.0 -max_value = 1.0 - -[node name="CurveAnimation" type="AnimationPlayer" parent="ShotUI/ShotGauges/CurveGauge"] -unique_name_in_owner = true -libraries = { -"": SubResource("AnimationLibrary_dicse") -} - -[node name="GaugeFlasher" type="AnimationPlayer" parent="ShotUI/ShotGauges"] -unique_name_in_owner = true - -[node name="ClubSelector" parent="ShotUI" instance=ExtResource("4_56ape")] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = 0 -anchor_right = 0.0 -anchor_bottom = 0.0 -offset_left = 50.0 -offset_top = 50.0 -offset_right = 50.0 -offset_bottom = 50.0 -grow_horizontal = 1 -grow_vertical = 1 -pivot_offset = Vector2(-400, 0) - -[node name="HUDAnimation" type="AnimationPlayer" parent="ShotUI"] -libraries = { -"": SubResource("AnimationLibrary_c3i4w") -} - -[node name="HUDStateMachine" type="AnimationTree" parent="ShotUI"] -unique_name_in_owner = true -root_node = NodePath("%HUDStateMachine/..") -tree_root = SubResource("AnimationNodeStateMachine_osrbp") -anim_player = NodePath("../HUDAnimation") +one_shot = true [connection signal="body_entered" from="BallPoint/PhysicsBall" to="." method="_on_physics_ball_body_entered"] [connection signal="entered_water" from="BallPoint/PhysicsBall" to="." method="_on_ball_entered_water"] [connection signal="sleeping_state_changed" from="BallPoint/PhysicsBall" to="." method="_on_physics_ball_sleeping_state_changed"] +[connection signal="timeout" from="BallReturnTimer" to="." method="_on_ball_return_timer_timeout"] diff --git a/src/ui/shot_hud/shot_hud.gd b/src/ui/shot_hud/shot_hud.gd new file mode 100644 index 0000000..2c4a3d4 --- /dev/null +++ b/src/ui/shot_hud/shot_hud.gd @@ -0,0 +1,57 @@ +class_name ShotHUD extends Control +## HUD for main gameplay loop + +@onready var power_bar: ProgressBar = %PowerBar +@onready var curve_bar: ProgressBar = %CurveBar + +@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 _state: AnimationNodeStateMachinePlayback = hud_state_machine["parameters/playback"] + + +func show_hud() -> void: + _state.travel("visible") + + +func hide_hud() -> void: + _state.travel("hidden") + + +func start_power_bar() -> void: + _power_animation.play("fill") + + +func stop_power_bar() -> void: + _power_animation.pause() + + +func reset_power_bar() -> void: + _power_animation.stop() + + +func start_curve_bar() -> void: + _curve_animation.play("fill") + + +func stop_curve_bar() -> void: + _curve_animation.pause() + + +func reset_curve_bar() -> void: + _curve_animation.stop() + + +func play_nice_animation() -> void: + _nice_animation.play("display") + + +func play_wasted_animation() -> void: + _wasted_animation.play("display") diff --git a/src/ui/shot_hud/shot_hud.tscn b/src/ui/shot_hud/shot_hud.tscn new file mode 100644 index 0000000..ee2d902 --- /dev/null +++ b/src/ui/shot_hud/shot_hud.tscn @@ -0,0 +1,605 @@ +[gd_scene load_steps=27 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"] +[ext_resource type="PackedScene" uid="uid://445qd7m4qe2j" path="res://src/player/shot_setup/club_selector/club_selector.tscn" id="2_1hdub"] + +[sub_resource type="Animation" id="Animation_3xds6"] +resource_name = "RESET" +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:visible_ratio") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [1.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:rotation") +tracks/2/interp = 3 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [7.31612e-10] +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:anchor_top") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath(".:anchor_bottom") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_cwotn"] +resource_name = "display" +length = 2.4 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 2.4), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:visible_ratio") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.2), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 1.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:rotation") +tracks/2/interp = 3 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 2, 2.4), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [7.31612e-10, 7.31612e-10, 0.174533] +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:anchor_top") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.0548477, 0.5, -0.4, 0.0593877, 0.233401, -0.456136, 1.25, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 2, 2.4) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath(".:anchor_bottom") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.055, 0.5, -0.4, 0.059, 0.233, -0.456, 1.25, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 2, 2.4) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_2a0gn"] +_data = { +"RESET": SubResource("Animation_3xds6"), +"display": SubResource("Animation_cwotn") +} + +[sub_resource type="Animation" id="Animation_2gt87"] +resource_name = "RESET" +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:visible_ratio") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [1.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:rotation") +tracks/2/interp = 3 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [7.31612e-10] +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:anchor_top") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath(".:anchor_bottom") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_g52q7"] +resource_name = "display" +length = 3.4 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 3.4), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:visible_ratio") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 1.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:rotation") +tracks/2/interp = 3 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 3, 3.4), +"transitions": PackedFloat32Array(1, 0.618, 1), +"update": 0, +"values": [7.31612e-10, 7.31612e-10, -2.96706] +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:anchor_top") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.0548477, 0.5, -0.4, 0.0593877, 0.233401, -0.456136, 1.25, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 3, 3.4) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath(".:anchor_bottom") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0.5, -0.25, 0, 0.5, -0.055, 0.5, -0.4, 0.059, 0.233, -0.456, 1.25, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 3, 3.4) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_gbnnr"] +_data = { +"RESET": SubResource("Animation_2gt87"), +"display": SubResource("Animation_g52q7") +} + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_afsun"] +shader = ExtResource("1_ybxxp") +shader_parameter/change_color_depth = true +shader_parameter/target_color_depth = 3 +shader_parameter/dithering = true +shader_parameter/scale_resolution = true +shader_parameter/target_resolution_scale = 3 +shader_parameter/enable_recolor = false + +[sub_resource type="Animation" id="Animation_pk1s7"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:value") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_67gmp"] +resource_name = "fill" +length = 1.618 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:value") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.233333, 0.0884774, 1, -0.267469, -0.483539, 0.25, 0), +"times": PackedFloat32Array(0, 1.618) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_coah5"] +_data = { +"RESET": SubResource("Animation_pk1s7"), +"fill": SubResource("Animation_67gmp") +} + +[sub_resource type="Animation" id="Animation_noa0w"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("CurveBar:value") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_uo6s7"] +resource_name = "fill" +length = 0.618 +loop_mode = 2 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("CurveBar:value") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(-1, -0.25, 0, 0.3, 0, 1, -0.3, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.618) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_dicse"] +_data = { +"RESET": SubResource("Animation_noa0w"), +"fill": SubResource("Animation_uo6s7") +} + +[sub_resource type="Animation" id="Animation_3cn2c"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ClubSelector:rotation") +tracks/0/interp = 4 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="Animation" id="Animation_dt1yq"] +resource_name = "hide" +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/interp = 4 +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": [0.0, 0.0872665, -1.5708] +} + +[sub_resource type="Animation" id="Animation_0maif"] +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/interp = 4 +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": [-1.5708, 0.0872665, 0.0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_c3i4w"] +_data = { +"RESET": SubResource("Animation_3cn2c"), +"hide": SubResource("Animation_dt1yq"), +"show": SubResource("Animation_0maif") +} + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_8uxnp"] +animation = &"hide" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_v05eu"] +animation = &"show" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_28a4x"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_bj7v0"] +switch_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xpwgd"] +switch_mode = 2 + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_osrbp"] +states/hidden/node = SubResource("AnimationNodeAnimation_8uxnp") +states/hidden/position = Vector2(592, 100) +states/visible/node = SubResource("AnimationNodeAnimation_v05eu") +states/visible/position = Vector2(364, 100) +transitions = ["Start", "visible", SubResource("AnimationNodeStateMachineTransition_28a4x"), "visible", "hidden", SubResource("AnimationNodeStateMachineTransition_bj7v0"), "hidden", "visible", SubResource("AnimationNodeStateMachineTransition_xpwgd")] +graph_offset = Vector2(-309, -132) + +[node name="ShotHUD" type="Control"] +top_level = true +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +script = ExtResource("1_x5b4c") + +[node name="WoahNiceFeedback" type="RichTextLabel" parent="."] +visible = false +custom_minimum_size = Vector2(1200, 0) +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -350.0 +offset_top = -66.0 +offset_right = 350.0 +offset_bottom = 66.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_type_variation = &"ShotFeedback" +bbcode_enabled = true +text = "[center][wave amp=64][rainbow]woah nice[/rainbow][/wave][/center]" +fit_content = true +autowrap_mode = 0 +visible_characters_behavior = 1 + +[node name="NiceAnimation" type="AnimationPlayer" parent="WoahNiceFeedback"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_2a0gn") +} + +[node name="WastedFeedback" type="RichTextLabel" parent="."] +visible = false +custom_minimum_size = Vector2(1400, 0) +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -350.0 +offset_top = -66.0 +offset_right = 350.0 +offset_bottom = 66.0 +grow_horizontal = 2 +grow_vertical = 2 +pivot_offset = Vector2(100, 115) +mouse_filter = 2 +theme_type_variation = &"ShotFeedback" +bbcode_enabled = true +text = "[center][tornado radius=16][color=powder_blue]wasted[/color][/tornado][/center]" +fit_content = true +autowrap_mode = 0 +visible_characters_behavior = 1 + +[node name="WastedAnimation" type="AnimationPlayer" parent="WastedFeedback"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_gbnnr") +} + +[node name="ColorRect" type="ColorRect" parent="."] +visible = false +material = SubResource("ShaderMaterial_afsun") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="ShotGauges" type="Control" parent="."] +layout_mode = 1 +anchor_left = 0.4 +anchor_top = 0.3 +anchor_right = 0.6 +anchor_bottom = 0.85 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 + +[node name="PowerGauge" type="Control" parent="ShotGauges"] +layout_mode = 1 +anchor_left = 0.5 +anchor_top = 0.382 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 + +[node name="PowerBar" type="ProgressBar" parent="ShotGauges/PowerGauge"] +unique_name_in_owner = true +visible = false +custom_minimum_size = Vector2(30, 0) +layout_mode = 1 +anchors_preset = 13 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -2.0 +offset_right = 2.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +max_value = 1.0 +fill_mode = 2 + +[node name="PowerAnimation" type="AnimationPlayer" parent="ShotGauges/PowerGauge"] +unique_name_in_owner = true +root_node = NodePath("../PowerBar") +libraries = { +"": SubResource("AnimationLibrary_coah5") +} + +[node name="CurveGauge" type="Control" parent="ShotGauges"] +layout_mode = 1 +anchor_top = 0.25 +anchor_right = 1.0 +anchor_bottom = 0.25 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 + +[node name="CurveBar" type="ProgressBar" parent="ShotGauges/CurveGauge"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -13.5 +offset_bottom = 13.5 +grow_horizontal = 2 +grow_vertical = 2 +min_value = -1.0 +max_value = 1.0 + +[node name="CurveAnimation" type="AnimationPlayer" parent="ShotGauges/CurveGauge"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_dicse") +} + +[node name="ClubSelector" parent="." instance=ExtResource("2_1hdub")] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 0 +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_left = 50.0 +offset_top = 50.0 +offset_right = 50.0 +offset_bottom = 50.0 +grow_horizontal = 1 +grow_vertical = 1 +pivot_offset = Vector2(-400, 0) + +[node name="HUDAnimation" type="AnimationPlayer" parent="."] +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") diff --git a/src/ui/world_ui.gd b/src/ui/world_ui.gd new file mode 100644 index 0000000..6f4f80e --- /dev/null +++ b/src/ui/world_ui.gd @@ -0,0 +1,4 @@ +class_name WorldUI extends Control +## Container & accessor for the world UI. + +@onready var shot_hud: ShotHUD = %ShotHUD diff --git a/src/world/world.gd b/src/world/world.gd index 8365fec..97b2cca 100644 --- a/src/world/world.gd +++ b/src/world/world.gd @@ -7,7 +7,9 @@ class_name World extends Node @export var initial_level: PackedScene = preload("res://levels/debug_level/debug_level.tscn") @onready var level: Node3D = %Level -@onready var ui: Control = %UI +@onready var ui: WorldUI = %UI + +static var group := "WorldGroup" func _ready() -> void: @@ -25,3 +27,4 @@ func load_level(level_scene: PackedScene) -> void: # Load the level var instance: Node3D = level_scene.instantiate() level.add_child(instance) + instance.reparent(level) diff --git a/src/world/world.tscn b/src/world/world.tscn index 1eeb712..5473099 100644 --- a/src/world/world.tscn +++ b/src/world/world.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=2 format=3 uid="uid://cwnwcd8kushl3"] +[gd_scene load_steps=4 format=3 uid="uid://cwnwcd8kushl3"] [ext_resource type="Script" path="res://src/world/world.gd" id="1_ybjyx"] +[ext_resource type="PackedScene" uid="uid://c4ifdiohng830" path="res://src/ui/shot_hud/shot_hud.tscn" id="2_5b7qb"] +[ext_resource type="Script" path="res://src/ui/world_ui.gd" id="2_imewa"] [node name="World" type="Node" groups=["WorldGroup"]] script = ExtResource("1_ybjyx") @@ -17,3 +19,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 1 +script = ExtResource("2_imewa") + +[node name="ShotHUD" parent="UI" instance=ExtResource("2_5b7qb")] +unique_name_in_owner = true +layout_mode = 1