generated from krampus/template-godot4
HUD starts hidden & fewer redundant initializations
This commit is contained in:
parent
db78cec5a5
commit
0952cd7486
|
@ -103,6 +103,7 @@ var club: Club:
|
|||
var ball_type: GameBall.Type:
|
||||
set(value):
|
||||
if value != ball_type:
|
||||
if hud:
|
||||
hud.ball_selector.value = value
|
||||
ball_point.spawn_ball(value)
|
||||
ball_type = value
|
||||
|
@ -180,10 +181,11 @@ func _ready() -> void:
|
|||
player.on_life_changed.connect(_on_life_changed)
|
||||
|
||||
# Create & set up HUD
|
||||
hud = ShotHUD.create(player)
|
||||
world.ui.add_player_hud(hud)
|
||||
ball_type = initial_ball
|
||||
club_type = initial_club_type
|
||||
|
||||
hud = ShotHUD.create(player)
|
||||
world.ui.add_player_hud(hud)
|
||||
character.set_color(player.color)
|
||||
|
||||
# Set up player 3D label
|
||||
|
@ -191,7 +193,7 @@ func _ready() -> void:
|
|||
player_label.modulate = player.color
|
||||
player_label.outline_modulate = ColorTools.get_bg_color(player.color)
|
||||
|
||||
_on_phase_change(phase)
|
||||
#_on_phase_change(phase)
|
||||
|
||||
|
||||
func _on_tree_exiting() -> void:
|
||||
|
@ -443,6 +445,7 @@ func _set_club_type(new_club_type: Club.Type) -> void:
|
|||
wedge_arrow.hide()
|
||||
iron_arrow.hide()
|
||||
putt_arrow.hide()
|
||||
if hud:
|
||||
hud.club_selector.value = new_club_type
|
||||
# TODO club change animation
|
||||
character.hold_right(new_club.get_model())
|
||||
|
|
|
@ -28,6 +28,7 @@ var _force_visible := false
|
|||
|
||||
func _init(force_visible_signal: Variant = null) -> void:
|
||||
if force_visible_signal is Signal:
|
||||
@warning_ignore("unsafe_cast")
|
||||
(force_visible_signal as Signal).connect(_set_force_visible)
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class_name ShotHUD extends Control
|
||||
## HUD for main gameplay loop
|
||||
|
||||
const NICE_ALERT_SCENE := preload("res://src/ui/shot_hud/nice_alert.tscn")
|
||||
|
||||
## Scale factor for the life bar rumble intensity on taking damage
|
||||
const LIFE_BAR_DAMAGE_RUMBLE_SCALE := 0.2
|
||||
## Time it takes to dampen the life bar rumble on taking damage, in seconds
|
||||
|
@ -12,6 +10,8 @@ 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
|
||||
|
||||
@export var nice_alert_scene: PackedScene
|
||||
|
||||
var player: WorldPlayer
|
||||
|
||||
@onready var power_bar: TextureProgressBar = %PowerBar
|
||||
|
@ -103,7 +103,7 @@ func gauge_flourish() -> void:
|
|||
|
||||
|
||||
func play_nice_animation() -> void:
|
||||
_alert_container.add_child(NICE_ALERT_SCENE.instantiate())
|
||||
_alert_container.add_child(nice_alert_scene.instantiate())
|
||||
|
||||
|
||||
func play_wasted_animation() -> void:
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=46 format=3 uid="uid://c4ifdiohng830"]
|
||||
[gd_scene load_steps=47 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/ui/shot_hud/club_selector/club_selector.tscn" id="2_1hdub"]
|
||||
[ext_resource type="PackedScene" uid="uid://g8yw4bersece" path="res://src/ui/shot_hud/nice_alert.tscn" id="2_rnndf"]
|
||||
[ext_resource type="Script" path="res://src/ui/decorations/rumbler.gd" id="3_6groq"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5812y3pmmgg5" path="res://assets/ui/gauge_patch.png" id="4_5kcpe"]
|
||||
[ext_resource type="Texture2D" uid="uid://76fjx2ukavqe" path="res://assets/ui/power_gauge_fill.png" id="5_3i1yq"]
|
||||
|
@ -266,7 +267,7 @@ tracks/0/keys = {
|
|||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
"values": [-1.5708]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_w7dmn"]
|
||||
|
@ -334,26 +335,14 @@ length = 0.001
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SouthWest:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/path = NodePath("SouthWest:offset_top")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("SouthWest:offset_top")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [-98.0]
|
||||
"values": [20.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_yis4x"]
|
||||
|
@ -363,22 +352,10 @@ step = 0.02
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SouthWest:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/path = NodePath("SouthWest:offset_top")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.4),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("SouthWest:offset_top")
|
||||
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,
|
||||
|
@ -392,22 +369,10 @@ step = 0.02
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SouthWest:visible")
|
||||
tracks/0/path = NodePath("SouthWest:offset_top")
|
||||
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("SouthWest:offset_top")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 2.3, 2.4),
|
||||
"transitions": PackedFloat32Array(1.618, 1, 1.618, 1),
|
||||
"update": 0,
|
||||
|
@ -421,22 +386,10 @@ step = 0.02
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SouthWest:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/path = NodePath("SouthWest:offset_top")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("SouthWest:offset_top")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.34, 0.4),
|
||||
"transitions": PackedFloat32Array(1.618, 1.618, 1),
|
||||
"update": 0,
|
||||
|
@ -568,6 +521,7 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_x5b4c")
|
||||
nice_alert_scene = ExtResource("2_rnndf")
|
||||
|
||||
[node name="WastedFeedback" type="RichTextLabel" parent="."]
|
||||
visible = false
|
||||
|
@ -642,6 +596,7 @@ script = ExtResource("3_6groq")
|
|||
|
||||
[node name="PowerBar" type="TextureProgressBar" parent="ShotGauges/PowerGauge/Rumbler"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(64, 0)
|
||||
layout_mode = 1
|
||||
|
@ -691,6 +646,7 @@ mouse_filter = 1
|
|||
|
||||
[node name="CurveBar" parent="ShotGauges/CurveGauge" instance=ExtResource("7_kqi7w")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="CurveAnimation" type="AnimationPlayer" parent="ShotGauges/CurveGauge"]
|
||||
|
@ -712,6 +668,7 @@ offset_right = 50.0
|
|||
offset_bottom = 50.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
rotation = 4.71239
|
||||
pivot_offset = Vector2(-400, 0)
|
||||
|
||||
[node name="ClubSelectorAnimation" type="AnimationPlayer" parent="ClubSelector"]
|
||||
|
@ -756,7 +713,7 @@ anchors_preset = -1
|
|||
anchor_top = 1.0
|
||||
anchor_right = 0.333
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -98.0
|
||||
offset_top = 20.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 278.665
|
||||
grow_vertical = 0
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
class_name PlayManager extends Resource
|
||||
## Abstract base type for strategies to manage the flow of gameplay
|
||||
|
||||
## Emitted when a player should be spawned in the world
|
||||
@warning_ignore("unused_signal")
|
||||
signal spawning(player: WorldPlayer)
|
||||
|
||||
## Emitted at the start of each new turn
|
||||
@warning_ignore("unused_signal")
|
||||
signal turn_started(player: WorldPlayer)
|
||||
|
|
|
@ -9,15 +9,18 @@ var player: WorldPlayer:
|
|||
|
||||
|
||||
func on_initialization() -> void:
|
||||
# Spawn practice player
|
||||
spawning.emit(player)
|
||||
|
||||
# Set first player as active
|
||||
player.shot_setup.phase = ShotSetup.Phase.AIM
|
||||
|
||||
|
||||
func on_turn_finished(source: ShotSetup) -> void:
|
||||
func on_turn_finished(_source: ShotSetup) -> void:
|
||||
player.shot_setup.queue_restart()
|
||||
turn_started.emit(player)
|
||||
|
||||
|
||||
func on_player_death(player: WorldPlayer) -> void:
|
||||
func on_player_death(source: WorldPlayer) -> void:
|
||||
# TODO game over screen
|
||||
winner.emit(player)
|
||||
winner.emit(source)
|
||||
|
|
|
@ -3,6 +3,11 @@ class_name RoundRobinManager extends PlayManager
|
|||
|
||||
|
||||
func on_initialization() -> void:
|
||||
# Spawn all players
|
||||
for p: WorldPlayer in players:
|
||||
print("Emitting spawn signal for player ", p)
|
||||
spawning.emit(p)
|
||||
|
||||
# Set first player as active
|
||||
players[0].shot_setup.phase = ShotSetup.Phase.AIM
|
||||
|
||||
|
|
|
@ -27,16 +27,13 @@ static var group := "WorldGroup"
|
|||
func _ready() -> void:
|
||||
load_level(initial_level)
|
||||
|
||||
# Spawn players in the level
|
||||
for player: WorldPlayer in manager.players:
|
||||
_spawn_player(player)
|
||||
manager.spawning.connect(_spawn_player)
|
||||
manager.winner.connect(_on_winner)
|
||||
|
||||
manager.initialize()
|
||||
if not manager.players:
|
||||
push_warning("Warning: Starting game world with no players!")
|
||||
|
||||
manager.winner.connect(_on_winner)
|
||||
|
||||
|
||||
func _random_spawn() -> Node3D:
|
||||
# Get random spawn point
|
||||
|
@ -50,6 +47,7 @@ func _random_spawn() -> Node3D:
|
|||
|
||||
|
||||
func _spawn_player(player: WorldPlayer) -> void:
|
||||
print_debug("Spawning player: ", player)
|
||||
var spawn_point := _random_spawn()
|
||||
var shot_setup := player.shot_setup
|
||||
shot_setup.global_transform = spawn_point.global_transform
|
||||
|
|
Loading…
Reference in New Issue