diff --git a/asset_dev/balls/ball_icons.xcf b/asset_dev/balls/ball_icons.xcf deleted file mode 100644 index d706fed..0000000 Binary files a/asset_dev/balls/ball_icons.xcf and /dev/null differ diff --git a/assets/ui/ball_icons/basic_icon.png b/assets/ui/ball_icons/basic_icon.png deleted file mode 100644 index 4675760..0000000 --- a/assets/ui/ball_icons/basic_icon.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f31c37793ded0f1d51ec4dba68a5d50602af6e0b18a2f6d7e50735cd29600f70 -size 2402 diff --git a/assets/ui/ball_icons/basic_icon.png.import b/assets/ui/ball_icons/basic_icon.png.import deleted file mode 100644 index 3b82c5b..0000000 --- a/assets/ui/ball_icons/basic_icon.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://tancoet1lih5" -path="res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://assets/ui/ball_icons/basic_icon.png" -dest_files=["res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index 2e9c7e3..6382ac2 100644 --- a/project.godot +++ b/project.godot @@ -182,16 +182,6 @@ pause={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } -ball_next={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) -] -} -ball_previous={ -"deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) -] -} [layer_names] diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index aaec4f7..9f8f685 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -1,16 +1,8 @@ class_name GameBall extends RigidBody3D ## Base class for all gfolf balls -## Fired as soon as this ball enters a water hazard signal entered_water -## Types of game balls -enum Type { - NONE, - BASIC, - PLASMA, -} - const TERRAIN_DAMPING_EPSILON := 1e-6 const IRON_DAMPING := 9999.0 @@ -97,7 +89,6 @@ func get_reoriented_basis() -> Basis: func _on_sleeping_state_changed() -> void: - print("SLEEPING STATE: ", sleeping) if sleeping: # Trigger to reassign on wake _awake = false diff --git a/src/equipment/balls/plasma_ball/plasma_ball.gd b/src/equipment/balls/plasma_ball/plasma_ball.gd index ac86964..50316e0 100644 --- a/src/equipment/balls/plasma_ball/plasma_ball.gd +++ b/src/equipment/balls/plasma_ball/plasma_ball.gd @@ -8,9 +8,9 @@ func _on_body_entered(_body: Node) -> void: print_debug("Plasma ball stuck to ", _body) # Freeze physics as soon as we hit something freeze = true + sleeping = true manual_sleep_timer.start() func _fire_sleep_signal() -> void: - sleeping = true sleeping_state_changed.emit() diff --git a/src/player/debug_player.tres b/src/player/debug_player.tres index 9083234..8eaef6f 100644 --- a/src/player/debug_player.tres +++ b/src/player/debug_player.tres @@ -8,14 +8,9 @@ [resource] script = ExtResource("4_8ybyj") -life = 100.0 name = "DEBUG Gfolfer" -color = Color(1, 0.439216, 0.439216, 1) +life = 100.0 driver = ExtResource("1_sn8fd") iron = ExtResource("2_piku2") wedge = ExtResource("5_wm4ae") putter = ExtResource("3_tytwr") -_balls = { -1: -1, -2: 5 -} diff --git a/src/player/shot_setup/ball_point.gd b/src/player/shot_setup/ball_point.gd deleted file mode 100644 index 318f2d6..0000000 --- a/src/player/shot_setup/ball_point.gd +++ /dev/null @@ -1,42 +0,0 @@ -class_name BallPoint extends Node3D -## Ball spawn point & origin. I.E. the "tee". - -## Emitted when a new ball is placed. -signal ball_changed(ball: GameBall) - -## Scenes for each type of ball. -const SCENE_MAP: Dictionary = { - GameBall.Type.BASIC: preload("res://src/equipment/balls/physics_ball/physics_ball.tscn"), - GameBall.Type.PLASMA: preload("res://src/equipment/balls/plasma_ball/plasma_ball.tscn"), -} - -@export var ball: GameBall: - set(value): - ball = value - ball_changed.emit(ball) - - -## Get a new instance of a ball of the given type. -## Returns null if the type can't be instantiated (e.g. NONE type) -func get_instance(type: GameBall.Type) -> GameBall: - if type in SCENE_MAP: - var scene: PackedScene = SCENE_MAP.get(type) - return scene.instantiate() as GameBall - return null - - -## Clear any existing ball, instantiate a new one of the given type, and place it at the ball point. -func spawn_ball(type: GameBall.Type) -> void: - # Clear existing ball - if is_instance_valid(ball): - ball.queue_free() - - ball = get_instance(type) - if is_instance_valid(ball): - add_child(ball) - snap() - - -## Snap the ball back to the ball point. -func snap() -> void: - ball.global_transform = global_transform diff --git a/src/player/shot_setup/hitbox.gd b/src/player/shot_setup/hitbox.gd index 63cb687..40fa049 100644 --- a/src/player/shot_setup/hitbox.gd +++ b/src/player/shot_setup/hitbox.gd @@ -3,12 +3,13 @@ extends Area3D signal ball_collision(ball: GameBall) +@export var ignored_balls: Array[GameBall] = [] + @onready var shot_setup: ShotSetup = $".." func _on_ball_entered(ball: GameBall) -> void: - # TODO generalize this in the future if we have multiple players on teams - if ball != shot_setup.game_ball: + if not ball in ignored_balls: ball_collision.emit(ball) diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index e4a4082..3e9cea3 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -41,9 +41,6 @@ const WATER_DAMAGE := 10.0 ## Initially-selected club @export var initial_club: Club.Type = Club.Type.DRIVER -## Initially-selected ball type -@export var initial_ball: GameBall.Type = GameBall.Type.BASIC - @export_category("Shot Parameters") @export var base_power := 2.5 @export var base_curve := 0.0 @@ -89,13 +86,6 @@ var club: Club.Type: _on_club_change(value) club = value -var ball_type: GameBall.Type: - set(value): - if value != ball_type: - hud.ball_selector.value = value - ball_point.spawn_ball(value) - ball_type = value - var shot_ref: Node3D var shot_power: float: @@ -110,10 +100,6 @@ var shot_curve: float: get: return hud.power_bar.value -var game_ball: GameBall: - get: - return ball_point.ball - var _free_camera: FreeCamera var _returning_free_camera := false var _restart_queued := false @@ -137,7 +123,9 @@ var _tracking_camera: OrbitalCamera @onready var arrow_animation: AnimationPlayer = %ArrowAnimation @onready var shot_projection: ProjectileArc = %ShotProjection -@onready var ball_point: BallPoint = %BallPoint +@onready var ball_point: Node3D = %BallPoint +# @onready var game_ball: GameBall = %PhysicsBall +@onready var game_ball: GameBall = %PlasmaBall @onready var drive_ref: RayCast3D = %DriveRef @onready var drive_arrow: Node3D = %DriveArrow @@ -150,6 +138,8 @@ var _tracking_camera: OrbitalCamera @onready var ball_return_timer: Timer = %BallReturnTimer +@onready var ball_impulse_debug: Node3D = %BallImpulseDebug + @onready var camera_distance := zoom.position.z: set = _set_camera_distance @@ -165,7 +155,6 @@ func _ready() -> void: # Create & set up HUD hud = ShotHUD.create(player) world.ui.add_player_hud(hud) - ball_type = initial_ball club = initial_club @@ -234,20 +223,16 @@ func take_shot() -> void: var impulse := get_shot_impulse(shot_power) print_debug("Shot impulse: ", impulse, "; ", impulse.length(), " N*s") - if game_ball: - game_ball.freeze = false - game_ball.apply_central_impulse(impulse) + ball_impulse_debug.transform = ( + Transform3D.IDENTITY.scaled(Vector3.ONE * impulse.length()).looking_at(impulse) + ) - # Use a ball if a limited type is selected - if player.get_balls(ball_type) > 0: - player.mutate_balls(ball_type, -1) + game_ball.freeze = false + game_ball.apply_central_impulse(impulse) ## Make the shot projection widget visible, with animated transition func _show_shot_projection() -> void: - if not game_ball: - return - shot_projection.initial_speed = 1 shot_projection.basis = shot_ref.basis.orthonormalized() var shot_speed := get_shot_impulse(1.0).length() / game_ball.mass @@ -287,9 +272,6 @@ func return_free_cam() -> void: func return_ball() -> void: - if not game_ball: - return - game_ball.freeze = true var tween := get_tree().create_tween() ( @@ -306,9 +288,6 @@ func return_ball() -> void: func travel_to_ball() -> void: - if not game_ball: - return - game_ball.freeze = true global_position = game_ball.global_position @@ -317,14 +296,12 @@ func travel_to_ball() -> void: direction.rotation.y = 0 _target_rotation.y = 0 global_basis = game_ball.get_reoriented_basis() + print_debug("REORIENTED BASIS: ", global_basis) - ball_point.snap() + game_ball.global_transform = ball_point.global_transform func start_shot_track() -> void: - if not game_ball: - return - if phase == Phase.SHOT: _tracking_camera = OrbitalCamera.create(game_ball) _tracking_camera.rotation.y = randf_range(0.0, TAU) @@ -354,8 +331,7 @@ func _on_club_change(new_club_type: Club.Type) -> void: wedge_arrow.hide() iron_arrow.hide() putt_arrow.hide() - if game_ball: - game_ball.iron_ball = false + game_ball.iron_ball = false hud.club_selector.value = new_club_type # TODO club change animation character.hold_right(new_club.get_model()) @@ -372,8 +348,7 @@ func _on_club_change(new_club_type: Club.Type) -> void: Club.Type.IRON: shot_ref = iron_ref iron_arrow.show() - if game_ball: - game_ball.iron_ball = true + game_ball.iron_ball = true Club.Type.SPECIAL: # TODO figure this out shot_ref = drive_ref @@ -383,6 +358,7 @@ func _on_club_change(new_club_type: Club.Type) -> void: ## Called immediately before `phase` is mutated. func _on_phase_change(new_phase: Phase) -> void: + print_debug("Player ", player.name, ": change to ", Phase.keys()[new_phase]) match new_phase: Phase.AIM: hud.show_hud() @@ -424,18 +400,7 @@ func _on_phase_change(new_phase: Phase) -> void: finished.emit(self) -func _on_game_ball_changed(ball: GameBall) -> void: - if ball: - ball.iron_ball = (club == Club.Type.IRON) - ball.entered_water.connect(_on_ball_entered_water) - ball.sleeping_state_changed.connect(_on_ball_sleeping_state_changed) - - func _process(delta: float) -> void: - # REMOVEME - if Input.is_action_just_pressed("ui_menu"): - print("Debugging...") - ## Visual updates # Rotation direction.rotation.y = lerp_angle( @@ -491,12 +456,6 @@ func _process(delta: float) -> void: if Input.is_action_just_pressed("select_putter"): club = Club.Type.PUTTER - # Ball select - if Input.is_action_just_pressed("ball_next"): - ball_type = player.next_ball(ball_type) - if Input.is_action_just_pressed("ball_previous"): - ball_type = player.prev_ball(ball_type) - # Switch to free cam if ( Input.is_action_just_pressed("camera_back") @@ -508,10 +467,7 @@ func _process(delta: float) -> void: # Advance to next phase if Input.is_action_just_pressed("shot_accept"): - if player.get_balls(ball_type) != 0: - # Check that player has enough of the selected ball (<0 means unlimited) - phase = Phase.POWER_ADJUST - # TODO play UI bonk if player doesn't have balls (lmao) + phase = Phase.POWER_ADJUST Phase.POWER_ADJUST: if Input.is_action_just_pressed("shot_accept"): # TODO set power gauge parameters if needed diff --git a/src/player/shot_setup/shot_setup.tscn b/src/player/shot_setup/shot_setup.tscn index 8ba1607..7c76b69 100644 --- a/src/player/shot_setup/shot_setup.tscn +++ b/src/player/shot_setup/shot_setup.tscn @@ -1,13 +1,22 @@ -[gd_scene load_steps=17 format=3 uid="uid://cy7t2tc4y3b4"] +[gd_scene load_steps=19 format=3 uid="uid://cy7t2tc4y3b4"] [ext_resource type="Script" path="res://src/player/shot_setup/shot_setup.gd" id="1_r6ei4"] -[ext_resource type="Script" path="res://src/player/shot_setup/ball_point.gd" id="2_e6i3g"] [ext_resource type="PackedScene" uid="uid://c2k88ns0h5ie1" path="res://src/ui/3d/arrow/arrow.tscn" id="2_s70wl"] +[ext_resource type="PackedScene" uid="uid://dcqxlbsrubapk" path="res://src/equipment/balls/plasma_ball/plasma_ball.tscn" id="3_8dte7"] [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://fht6j87o8ecr" path="res://src/ui/3d/projectile_arc/projectile_arc.tscn" id="4_ry2ho"] [ext_resource type="PackedScene" uid="uid://dbdul15c4oblg" path="res://src/ui/3d/projected_target.tscn" id="6_mynqj"] [ext_resource type="Script" path="res://src/player/shot_setup/hitbox.gd" id="7_uh8kn"] +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lnol1"] +albedo_color = Color(0, 0.537255, 1, 1) + +[sub_resource type="CylinderMesh" id="CylinderMesh_ql2ui"] +material = SubResource("StandardMaterial3D_lnol1") +top_radius = 0.02 +bottom_radius = 0.02 +height = 1.0 + [sub_resource type="Animation" id="Animation_ug2a7"] length = 0.001 tracks/0/type = "value" @@ -204,7 +213,18 @@ script = ExtResource("1_r6ei4") [node name="BallPoint" type="Node3D" parent="."] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.08, 0) -script = ExtResource("2_e6i3g") + +[node name="PlasmaBall" parent="BallPoint" instance=ExtResource("3_8dte7")] +unique_name_in_owner = true + +[node name="BallImpulseDebug" type="Node3D" parent="BallPoint"] +unique_name_in_owner = true +visible = false + +[node name="MeshInstance3D" type="MeshInstance3D" parent="BallPoint/BallImpulseDebug"] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -0.5) +mesh = SubResource("CylinderMesh_ql2ui") +skeleton = NodePath("../..") [node name="PlayerPivot" type="Node3D" parent="."] unique_name_in_owner = true @@ -323,13 +343,14 @@ visible = false transform = Transform3D(0.2, 0, 0, 0, -1.74846e-08, 0.2, 0, -0.4, -8.74228e-09, 0, 0, -1) loop_animation = 1 -[node name="ShotProjection" parent="ArrowPivot" instance=ExtResource("4_ry2ho")] +[node name="ShotProjection" parent="ArrowPivot" node_paths=PackedStringArray("excluded_bodies") instance=ExtResource("4_ry2ho")] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 0.707107, -0.707107, 0, 0.707107, 0.707107, 0, -0.02, 0) visible = false initial_speed = 50.0 time_step = 0.01 max_steps = 800 +excluded_bodies = [NodePath("../../BallPoint/PlasmaBall")] [node name="ProjectedTarget" parent="ArrowPivot/ShotProjection" instance=ExtResource("6_mynqj")] @@ -344,13 +365,15 @@ libraries = { unique_name_in_owner = true one_shot = true -[node name="Hitbox" type="Area3D" parent="."] +[node name="Hitbox" type="Area3D" parent="." node_paths=PackedStringArray("ignored_balls")] script = ExtResource("7_uh8kn") +ignored_balls = [NodePath("../BallPoint/PlasmaBall")] [node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"] shape = SubResource("SphereShape3D_xvvdi") -[connection signal="ball_changed" from="BallPoint" to="." method="_on_game_ball_changed"] +[connection signal="entered_water" from="BallPoint/PlasmaBall" to="." method="_on_ball_entered_water"] +[connection signal="sleeping_state_changed" from="BallPoint/PlasmaBall" to="." method="_on_ball_sleeping_state_changed"] [connection signal="timeout" from="BallReturnTimer" to="." method="_on_ball_return_timer_timeout"] [connection signal="ball_collision" from="Hitbox" to="." method="_on_hitbox_ball_collision"] [connection signal="body_entered" from="Hitbox" to="Hitbox" method="_on_body_entered"] diff --git a/src/player/world_player.gd b/src/player/world_player.gd index 0b6df77..ace2d5d 100644 --- a/src/player/world_player.gd +++ b/src/player/world_player.gd @@ -2,7 +2,6 @@ class_name WorldPlayer extends Resource ## Container for the state of the player within the world. signal on_life_changed(new_value: float) -signal on_balls_changed(type: GameBall.Type, new_value: int) @export_range(0, 100) var life: float = 100.0: set(value): @@ -22,13 +21,6 @@ signal on_balls_changed(type: GameBall.Type, new_value: int) @export var putter: Club @export var special: Club -## Count of each type of ball the player possesses. -## A count of less than zero indicates unlimited quantity. -@export var _balls := { - GameBall.Type.BASIC: -1, - GameBall.Type.PLASMA: -1, -} - # TODO balls, pickups, etc var shot_setup: ShotSetup: @@ -56,39 +48,6 @@ func get_club(type: Club.Type) -> Club: return null -## Get the quantity of a ball type -func get_balls(type: GameBall.Type) -> int: - return _balls.get(type, 0) - - -## Set the quantity of a ball type -func set_balls(type: GameBall.Type, value: int) -> void: - _balls[type] = value - on_balls_changed.emit(type, value) - - -## Change the quantity of a ball type -func mutate_balls(type: GameBall.Type, delta: int) -> void: - _balls[type] = _balls.get(type, 0) + delta - on_balls_changed.emit(type, _balls[type]) - - -## Get next slotted ball type -func next_ball(type: GameBall.Type) -> GameBall.Type: - var keys := _balls.keys() - var i := keys.find(type) - var j := (i + 1) % len(keys) if i >= 0 else 0 - return keys[j] - - -## Get previous slotted ball type -func prev_ball(type: GameBall.Type) -> GameBall.Type: - var keys := _balls.keys() - var i := keys.find(type) - var j := (i - 1) % len(keys) if i >= 0 else 0 - return keys[j] - - ## Create a debug player instance static func create_debug() -> WorldPlayer: var instance := WorldPlayer.new() diff --git a/src/ui/main_theme.tres b/src/ui/main_theme.tres index 3adf3ae..5d28770 100644 --- a/src/ui/main_theme.tres +++ b/src/ui/main_theme.tres @@ -28,11 +28,6 @@ PauseMenuButton/colors/font_outline_color = Color(0, 0, 0, 1) PauseMenuButton/constants/outline_size = 6 PauseMenuButton/font_sizes/font_size = 32 PauseMenuButton/fonts/font = ExtResource("2_5ty6u") -QuantityLabel/base_type = &"Label" -QuantityLabel/colors/font_color = Color(0.819608, 0.196078, 0.196078, 1) -QuantityLabel/colors/font_outline_color = Color(1, 0.901961, 0.509804, 1) -QuantityLabel/constants/outline_size = 6 -QuantityLabel/font_sizes/font_size = 22 ShotFeedback/base_type = &"RichTextLabel" ShotFeedback/colors/font_shadow_color = Color(0, 0, 0, 1) ShotFeedback/constants/shadow_offset_x = 6 diff --git a/src/ui/shot_hud/ball_selector/ball_icon.gd b/src/ui/shot_hud/ball_selector/ball_icon.gd deleted file mode 100644 index e363aaf..0000000 --- a/src/ui/shot_hud/ball_selector/ball_icon.gd +++ /dev/null @@ -1,51 +0,0 @@ -@tool -class_name BallIcon extends Control -## HUD icon for a ball type - -const BASE_MODULATE := Color.WHITE -const EMPTY_MODULATE := Color.DIM_GRAY - -@export var text: String: - set(value): - text = value - if ball_label: - ball_label.text = value - -@export var quantity: int: - set = _set_quantity -@export var empty: bool: - set(value): - if value: - quantity = 0 - elif not quantity: - quantity = 1 - get: - return quantity == 0 -@export var unlimited: bool: - set(value): - quantity = -1 if value else 0 - get: - return quantity < 0 - -@onready var ball_label: Label = %BallLabel -@onready var quantity_container: HBoxContainer = %QuantityContainer -@onready var quantity_label: Label = %QuantityLabel - - -func _ready() -> void: - text = text - quantity = quantity - - -func _set_quantity(value: int) -> void: - # TODO play effect on gain/loss - quantity = value - if not quantity_label: - return - quantity_label.text = str(quantity) - - # Quantity is not visible if we're empty or unlimited - quantity_container.visible = quantity > 0 - - # Grey out when empty - ball_label.modulate = EMPTY_MODULATE if quantity == 0 else BASE_MODULATE diff --git a/src/ui/shot_hud/ball_selector/ball_icon.tscn b/src/ui/shot_hud/ball_selector/ball_icon.tscn deleted file mode 100644 index 7a92367..0000000 --- a/src/ui/shot_hud/ball_selector/ball_icon.tscn +++ /dev/null @@ -1,68 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://cc8a55ly7ybhy"] - -[ext_resource type="Script" path="res://src/ui/shot_hud/ball_selector/ball_icon.gd" id="1_p0p8j"] -[ext_resource type="FontFile" uid="uid://b6gxwgomstkgu" path="res://assets/fonts/Geo/Geo-Italic.ttf" id="2_bu42i"] - -[node name="BallIcon" type="Control"] -custom_minimum_size = Vector2(0, 27) -layout_mode = 3 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -grow_horizontal = 2 -grow_vertical = 2 -size_flags_horizontal = 4 -script = ExtResource("1_p0p8j") -quantity = -1 -unlimited = true - -[node name="BallLabel" type="Label" parent="."] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -46.5 -offset_top = -13.5 -offset_right = 46.5 -offset_bottom = 13.5 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/outline_size = 10 -theme_override_fonts/font = ExtResource("2_bu42i") -theme_override_font_sizes/font_size = 25 -horizontal_alignment = 2 - -[node name="QuantityContainer" type="HBoxContainer" parent="BallLabel"] -unique_name_in_owner = true -visible = false -layout_mode = 1 -anchors_preset = -1 -anchor_left = 1.0 -anchor_top = 0.8 -anchor_right = 1.0 -anchor_bottom = 0.8 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/separation = 0 - -[node name="Label" type="Label" parent="BallLabel/QuantityContainer"] -layout_mode = 2 -size_flags_horizontal = 8 -size_flags_vertical = 8 -theme_type_variation = &"QuantityLabel" -theme_override_font_sizes/font_size = 22 -text = "×" - -[node name="QuantityLabel" type="Label" parent="BallLabel/QuantityContainer"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 8 -size_flags_vertical = 8 -theme_type_variation = &"QuantityLabel" -theme_override_font_sizes/font_size = 22 -text = "-1" diff --git a/src/ui/shot_hud/ball_selector/ball_selector.gd b/src/ui/shot_hud/ball_selector/ball_selector.gd deleted file mode 100644 index bd7d292..0000000 --- a/src/ui/shot_hud/ball_selector/ball_selector.gd +++ /dev/null @@ -1,54 +0,0 @@ -@tool -class_name BallSelector extends Control - -const TWEEN_TIME := 0.2 - -const Y_OFFSET := { - GameBall.Type.NONE: 50, - GameBall.Type.BASIC: 18, - GameBall.Type.PLASMA: -14, -} - -@export var value: GameBall.Type: - set = _set_value - -@onready var ball_list: VBoxContainer = %BallList -@onready var basic_icon: BallIcon = %BasicIcon -@onready var plasma_icon: BallIcon = %PlasmaIcon - - -func _ready() -> void: - value = value - - -## Set ball quantities based on player's state -func set_state_for_player(player: WorldPlayer) -> void: - basic_icon.quantity = player.get_balls(GameBall.Type.BASIC) - plasma_icon.quantity = player.get_balls(GameBall.Type.PLASMA) - if player.shot_setup: - value = player.shot_setup.ball_type - player.on_balls_changed.connect(_set_quantity) - - -func _get_icon(type: GameBall.Type) -> BallIcon: - match type: - GameBall.Type.BASIC: - return basic_icon - GameBall.Type.PLASMA: - return plasma_icon - return null - - -func _set_value(new_value: GameBall.Type) -> void: - if not ball_list: - return - - var tween := get_tree().create_tween() - tween.tween_property(ball_list, "position:y", Y_OFFSET[new_value], TWEEN_TIME).set_trans( - Tween.TRANS_EXPO - ) - value = new_value - - -func _set_quantity(type: GameBall.Type, new_value: int) -> void: - _get_icon(type).quantity = new_value diff --git a/src/ui/shot_hud/ball_selector/ball_selector.tscn b/src/ui/shot_hud/ball_selector/ball_selector.tscn deleted file mode 100644 index d8336f8..0000000 --- a/src/ui/shot_hud/ball_selector/ball_selector.tscn +++ /dev/null @@ -1,66 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://b0yr0w0xv8cm5"] - -[ext_resource type="PackedScene" uid="uid://cc8a55ly7ybhy" path="res://src/ui/shot_hud/ball_selector/ball_icon.tscn" id="1_1v8xg"] -[ext_resource type="Script" path="res://src/ui/shot_hud/ball_selector/ball_selector.gd" id="1_b7gkp"] - -[sub_resource type="Gradient" id="Gradient_3vqut"] -interpolation_mode = 2 -offsets = PackedFloat32Array(0, 0.382, 0.618, 1) -colors = PackedColorArray(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) - -[sub_resource type="GradientTexture2D" id="GradientTexture2D_tm61r"] -gradient = SubResource("Gradient_3vqut") -fill_to = Vector2(0, 1) -metadata/_snap_enabled = true - -[node name="BallSelector" type="Control"] -custom_minimum_size = Vector2(120, 27) -layout_mode = 3 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -60.0 -offset_top = -13.5 -offset_right = 60.0 -offset_bottom = 13.5 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_b7gkp") - -[node name="GradientMask" type="TextureRect" parent="."] -clip_children = 1 -custom_minimum_size = Vector2(120, 32) -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -texture = SubResource("GradientTexture2D_tm61r") - -[node name="BallList" type="VBoxContainer" parent="GradientMask"] -unique_name_in_owner = true -custom_minimum_size = Vector2(120, 0) -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = 50.0 -offset_bottom = 50.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/separation = 5 - -[node name="BasicIcon" parent="GradientMask/BallList" instance=ExtResource("1_1v8xg")] -unique_name_in_owner = true -custom_minimum_size = Vector2(120, 27) -layout_mode = 2 -text = "BASIC" - -[node name="PlasmaIcon" parent="GradientMask/BallList" instance=ExtResource("1_1v8xg")] -unique_name_in_owner = true -custom_minimum_size = Vector2(120, 27) -layout_mode = 2 -text = "PLASMA" diff --git a/src/ui/shot_hud/shot_hud.gd b/src/ui/shot_hud/shot_hud.gd index 4098c8e..463e126 100644 --- a/src/ui/shot_hud/shot_hud.gd +++ b/src/ui/shot_hud/shot_hud.gd @@ -13,7 +13,6 @@ var player: WorldPlayer @onready var life_bar: TextureProgressBar = %LifeBar @onready var club_selector: ClubSelector = %ClubSelector -@onready var ball_selector: BallSelector = %BallSelector @onready var _curve_animation: AnimationPlayer = %CurveAnimation @onready var _power_animation: AnimationPlayer = %PowerAnimation @@ -33,7 +32,6 @@ static var scene: PackedScene = preload("res://src/ui/shot_hud/shot_hud.tscn") func _ready() -> void: club_selector.set_state_for_player(player) - ball_selector.set_state_for_player(player) _player_name.text = player.name life_bar.value = player.life life_bar.tint_progress = player.color diff --git a/src/ui/shot_hud/shot_hud.tscn b/src/ui/shot_hud/shot_hud.tscn index c0359af..ef91dfc 100644 --- a/src/ui/shot_hud/shot_hud.tscn +++ b/src/ui/shot_hud/shot_hud.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=34 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"] @@ -7,9 +7,7 @@ [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"] [ext_resource type="Texture2D" uid="uid://4a8tvjgwegv3" path="res://assets/ui/power_gauge_tab.png" id="6_sw48q"] -[ext_resource type="PackedScene" uid="uid://b0yr0w0xv8cm5" path="res://src/ui/shot_hud/ball_selector/ball_selector.tscn" id="8_b2302"] [ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="8_bejx4"] -[ext_resource type="Texture2D" uid="uid://tancoet1lih5" path="res://assets/ui/ball_icons/basic_icon.png" id="8_tt8i3"] [ext_resource type="PackedScene" uid="uid://dmciuk3pbjsae" path="res://src/ui/shot_hud/life_bar/life_bar.tscn" id="9_w1fiw"] [sub_resource type="Animation" id="Animation_3xds6"] @@ -492,35 +490,6 @@ tracks/1/keys = { "values": [false] } -[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="Animation" id="Animation_nicro"] resource_name = "show_life_bar" length = 0.4 @@ -550,6 +519,35 @@ tracks/1/keys = { "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"), @@ -758,30 +756,15 @@ libraries = { "": SubResource("AnimationLibrary_5nauw") } -[node name="TextureRect" type="TextureRect" parent="ClubSelector"] -texture_filter = 1 -layout_mode = 0 -offset_right = 128.0 -offset_bottom = 128.0 -texture = ExtResource("8_tt8i3") - -[node name="BallSelector" parent="ClubSelector/TextureRect" instance=ExtResource("8_b2302")] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.7 -anchor_right = 0.7 -offset_right = 108.0 -grow_horizontal = 1 - [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 = -98.0 +offset_top = 20.0 offset_right = 40.0 +offset_bottom = 118.0 grow_vertical = 0 theme_override_constants/margin_left = 16 theme_override_constants/margin_bottom = 16