generated from krampus/template-godot4
Player can deposit grunk back at the ship
This commit is contained in:
parent
a9c5ef65df
commit
24e3ee209f
BIN
asset_dev/level/player_ship/tank_facade.ubpd
Normal file
BIN
asset_dev/level/player_ship/tank_facade.ubpd
Normal file
Binary file not shown.
BIN
asset_dev/level/player_ship/tank_facade_OLD.ubpd
Normal file
BIN
asset_dev/level/player_ship/tank_facade_OLD.ubpd
Normal file
Binary file not shown.
BIN
assets/level/player_ship/tank_facade_C.png
(Stored with Git LFS)
Normal file
BIN
assets/level/player_ship/tank_facade_C.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/level/player_ship/tank_facade_C.png.import
Normal file
34
assets/level/player_ship/tank_facade_C.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cg6dpd6dhcowu"
|
||||
path="res://.godot/imported/tank_facade_C.png-c86c9212ea4759bbe5d5c9896385e07f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/level/player_ship/tank_facade_C.png"
|
||||
dest_files=["res://.godot/imported/tank_facade_C.png-c86c9212ea4759bbe5d5c9896385e07f.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=true
|
||||
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=0
|
BIN
assets/level/player_ship/tank_facade_M.png
(Stored with Git LFS)
Normal file
BIN
assets/level/player_ship/tank_facade_M.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/level/player_ship/tank_facade_M.png.import
Normal file
34
assets/level/player_ship/tank_facade_M.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://duo8ph784g4gd"
|
||||
path="res://.godot/imported/tank_facade_M.png-3f212fa045ec180dff9cc23799ddbbbc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/level/player_ship/tank_facade_M.png"
|
||||
dest_files=["res://.godot/imported/tank_facade_M.png-3f212fa045ec180dff9cc23799ddbbbc.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=true
|
||||
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=0
|
BIN
assets/level/player_ship/tank_facade_N.png
(Stored with Git LFS)
Normal file
BIN
assets/level/player_ship/tank_facade_N.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/level/player_ship/tank_facade_N.png.import
Normal file
34
assets/level/player_ship/tank_facade_N.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ccnk8eicahcw8"
|
||||
path="res://.godot/imported/tank_facade_N.png-7efe4ebd4db33a472bd36e6ace4b7085.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/level/player_ship/tank_facade_N.png"
|
||||
dest_files=["res://.godot/imported/tank_facade_N.png-7efe4ebd4db33a472bd36e6ace4b7085.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=1
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=1
|
||||
roughness/src_normal="res://assets/level/player_ship/tank_facade_N.png"
|
||||
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=0
|
BIN
assets/level/player_ship/tank_facade_R.png
(Stored with Git LFS)
Normal file
BIN
assets/level/player_ship/tank_facade_R.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/level/player_ship/tank_facade_R.png.import
Normal file
34
assets/level/player_ship/tank_facade_R.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dv2876ywyq6rf"
|
||||
path="res://.godot/imported/tank_facade_R.png-4365597d2ff20861b61d667c956e7f0e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/level/player_ship/tank_facade_R.png"
|
||||
dest_files=["res://.godot/imported/tank_facade_R.png-4365597d2ff20861b61d667c956e7f0e.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=true
|
||||
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=0
|
19
levels/ghost_ship/player_ship/player_ship.gd
Normal file
19
levels/ghost_ship/player_ship/player_ship.gd
Normal file
@ -0,0 +1,19 @@
|
||||
extends Node3D
|
||||
# The player's ship, a safe zone where they can deposit grunk, save their game, and relax.
|
||||
|
||||
@onready var tank_interactor: Interactive = %TankInteractor
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Game.manager.grunk_collected.connect(_enable_tank)
|
||||
|
||||
|
||||
func _enable_tank(_delta: float) -> void:
|
||||
tank_interactor.enabled = true
|
||||
|
||||
|
||||
## Called when the player interacts with the grunk tank.
|
||||
func deposit_grunk() -> void:
|
||||
# Tank is disabled until the player collects more grunk.
|
||||
tank_interactor.enabled = false
|
||||
Game.manager.deposit_tank()
|
1
levels/ghost_ship/player_ship/player_ship.gd.uid
Normal file
1
levels/ghost_ship/player_ship/player_ship.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://lfd36ps52xgk
|
@ -1,6 +1,12 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://oowut88kr2ox"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://oowut88kr2ox"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://lfd36ps52xgk" path="res://levels/ghost_ship/player_ship/player_ship.gd" id="1_0r2ng"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dq4aj5ph31rce" path="res://assets/level/player_ship/player_ship.obj" id="1_nafoa"]
|
||||
[ext_resource type="Texture2D" uid="uid://cg6dpd6dhcowu" path="res://assets/level/player_ship/tank_facade_C.png" id="2_xgclp"]
|
||||
[ext_resource type="Texture2D" uid="uid://duo8ph784g4gd" path="res://assets/level/player_ship/tank_facade_M.png" id="3_e4hmc"]
|
||||
[ext_resource type="Texture2D" uid="uid://ccnk8eicahcw8" path="res://assets/level/player_ship/tank_facade_N.png" id="4_0r2ng"]
|
||||
[ext_resource type="Texture2D" uid="uid://dv2876ywyq6rf" path="res://assets/level/player_ship/tank_facade_R.png" id="5_22nd2"]
|
||||
[ext_resource type="Script" uid="uid://deg5xd87cy8rg" path="res://src/props/interactive.gd" id="6_e4hmc"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nafoa"]
|
||||
albedo_color = Color(0.129412, 0.184314, 0.207843, 1)
|
||||
@ -10,7 +16,13 @@ albedo_color = Color(0.439216, 0.647059, 0.756863, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xpsdy"]
|
||||
transparency = 1
|
||||
albedo_color = Color(0.223529, 0.627451, 0.929412, 0.470588)
|
||||
albedo_texture = ExtResource("2_xgclp")
|
||||
metallic = 1.0
|
||||
metallic_texture = ExtResource("3_e4hmc")
|
||||
roughness_texture = ExtResource("5_22nd2")
|
||||
normal_enabled = true
|
||||
normal_texture = ExtResource("4_0r2ng")
|
||||
texture_filter = 2
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nbws3"]
|
||||
albedo_color = Color(0.243137, 0.231373, 0.219608, 1)
|
||||
@ -18,7 +30,11 @@ albedo_color = Color(0.243137, 0.231373, 0.219608, 1)
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_nafoa"]
|
||||
data = PackedVector3Array(2.5, 1, 5.5, 2.5, 1, -4.5001, 2.5, 2, 5.5, 2.5, 2, 5.5, 2.5, 1, -4.5001, 2.5, 2, -4.5001, 1.5, 3, 4.4999, 1.5, 3, -4.5001, -1.5, 3, 4.4999, -1.5, 3, 4.4999, 1.5, 3, -4.5001, -1.5, 3, -4.5001, -1.5, 3, -4.5001, 1.5, 3, -4.5001, -0.625, 3, -4.5001, -0.625, 3, -4.5001, 1.5, 3, -4.5001, 0.625, 3, -4.5001, -2.5, 1, -4.5001, -2.5, 1, 5.5, -2.5, 2, -4.5001, -2.5, 2, -4.5001, -2.5, 1, 5.5, -2.5, 2, 5.5, 2.5, 1, -4.5001, 1.5, 0, -4.5001, 2.5, 2, -4.5001, 2.5, 2, -4.5001, 1.5, 0, -4.5001, 1.5, 3, -4.5001, 0.625, 0, -4.5001, 1.5, 3, -4.5001, 1.5, 0, -4.5001, 0.625, 2.5, -4.5001, 1.5, 3, -4.5001, 0.625, 0, -4.5001, 0.625, 3, -4.5001, 1.5, 3, -4.5001, 0.625, 2.5, -4.5001, 0.625, 2.5, -4.5001, -0.625, 2.5, -4.5001, 0.625, 3, -4.5001, 0.625, 3, -4.5001, -0.625, 2.5, -4.5001, -0.625, 3, -4.5001, -0.625, 3, -4.5001, -0.625, 2.5, -4.5001, -1.5, 3, -4.5001, -1.5, 3, -4.5001, -0.625, 2.5, -4.5001, -1.5, 0, -4.5001, -1.5, 0, -4.5001, -0.625, 2.5, -4.5001, -0.625, 0, -4.5001, -1.5, 0, -4.5001, -2.5, 1, -4.5001, -1.5, 3, -4.5001, -1.5, 3, -4.5001, -2.5, 1, -4.5001, -2.5, 2, -4.5001, -2.5, 1, -4.5001, -1.5, 0, -4.5001, -2.5, 1, 5.5, -2.5, 1, 5.5, -1.5, 0, -4.5001, -1.5, 0, 4.4999, -2.5, 2, 5.5, -1.5, 3, 4.4999, -2.5, 2, -4.5001, -2.5, 2, -4.5001, -1.5, 3, 4.4999, -1.5, 3, -4.5001, 2.5, 1, 5.5, 1.5, 0, 4.4999, 2.5, 1, -4.5001, 2.5, 1, -4.5001, 1.5, 0, 4.4999, 1.5, 0, -4.5001, 2.5, 2, -4.5001, 1.5, 3, -4.5001, 2.5, 2, 5.5, 2.5, 2, 5.5, 1.5, 3, -4.5001, 1.5, 3, 4.4999, -1.5, 0, 4.4999, -1.5, 0, -4.5001, 1.5, 0, 4.4999, 1.5, 0, 4.4999, -1.5, 0, -4.5001, 1.5, 0, -4.5001, 1.5, 0, -4.5001, -1.5, 0, -4.5001, 0.625, 0, -4.5001, 0.625, 0, -4.5001, -1.5, 0, -4.5001, -0.625, 0, -4.5001, 0.625, 0, -4.5001, -0.625, 0, -4.5001, 0.625, 0, -4.75, 0.625, 0, -4.75, -0.625, 0, -4.5001, -0.625, 0, -4.75, -0.625, 2.5, -4.5001, 0.625, 2.5, -4.5001, -0.625, 2.5, -4.75, -0.625, 2.5, -4.75, 0.625, 2.5, -4.5001, 0.625, 2.5, -4.75, -0.625, 0, -4.5001, -0.625, 2.5, -4.5001, -0.625, 0, -4.75, -0.625, 0, -4.75, -0.625, 2.5, -4.5001, -0.625, 2.5, -4.75, 0.625, 2.5, -4.5001, 0.625, 0, -4.5001, 0.625, 2.5, -4.75, 0.625, 2.5, -4.75, 0.625, 0, -4.5001, 0.625, 0, -4.75, -1.5, 3, 4.5, -2.5, 2, 5.5, -1.5, 3, 7.5, -1.5, 3, 7.5, -2.5, 2, 5.5, -2.5, 2, 7.5, -1.5, 0, 7.5, 1.5, 0, 7.5, -2.5, 1, 7.5, -2.5, 1, 7.5, 1.5, 0, 7.5, -2.5, 2, 7.5, -2.5, 2, 7.5, 1.5, 0, 7.5, -1.5, 3, 7.5, -1.5, 3, 7.5, 1.5, 0, 7.5, 1.5, 3, 7.5, 1.5, 3, 7.5, 1.5, 0, 7.5, 2.5, 2, 7.5, 2.5, 2, 7.5, 1.5, 0, 7.5, 2.5, 1, 7.5, -2.5, 1, 5.5, -1.5, 0, 4.5, -2.5, 1, 7.5, -2.5, 1, 7.5, -1.5, 0, 4.5, -1.5, 0, 7.5, 2.5, 1, 5.5, 2.5, 2, 5.5, 2.5, 1, 7.5, 2.5, 1, 7.5, 2.5, 2, 5.5, 2.5, 2, 7.5, -2.5, 2, 5.5, -2.5, 1, 5.5, -2.5, 2, 7.5, -2.5, 2, 7.5, -2.5, 1, 5.5, -2.5, 1, 7.5, 2.5, 2, 5.5, 1.5, 3, 4.5, 2.5, 2, 7.5, 2.5, 2, 7.5, 1.5, 3, 4.5, 1.5, 3, 7.5, 1.5, 3, 4.5, -1.5, 3, 4.5, 1.5, 3, 7.5, 1.5, 3, 7.5, -1.5, 3, 4.5, -1.5, 3, 7.5, 1.5, 0, 4.5, 2.5, 1, 5.5, 1.5, 0, 7.5, 1.5, 0, 7.5, 2.5, 1, 5.5, 2.5, 1, 7.5, -1.5, 0, 4.5, 1.5, 0, 4.5, -1.5, 0, 7.5, -1.5, 0, 7.5, 1.5, 0, 4.5, 1.5, 0, 7.5, 1.5, 3, 4.5, 1.5, 0, 4.5, 2.5, 2, 5.5, 2.5, 2, 5.5, 1.5, 0, 4.5, 2.5, 1, 5.5, -2.5, 1, 5.5, -1.5, 0, 4.5, -2.5, 2, 5.5, -2.5, 2, 5.5, -1.5, 0, 4.5, -1.5, 3, 4.5, -1.5, 0, 4.5, 1.5, 0, 4.5, -1.5, 3, 4.5, -1.5, 3, 4.5, 1.5, 0, 4.5, 1.5, 3, 4.5, 1.25, 2.5, -4.75, 1.25, 3, -4.75, 0.625, 2.5, -4.75, 0.625, 2.5, -4.75, 0.625, 0, -4.75, 1.25, 2.5, -4.75, 1.25, 2.5, -4.75, 0.625, 0, -4.75, 1.25, 0, -4.75, 0.625, 2.5, -4.75, 1.25, 3, -4.75, -0.625, 2.5, -4.75, -0.625, 2.5, -4.75, 1.25, 3, -4.75, -1.25, 2.5, -4.75, -1.25, 2.5, -4.75, 1.25, 3, -4.75, -1.25, 3, -4.75, -1.25, 0, -4.75, -0.625, 2.5, -4.75, -1.25, 2.5, -4.75, -0.625, 0, -4.75, -0.625, 2.5, -4.75, -1.25, 0, -4.75, -1.25, 2.5, -4.75, -1.25, 3, -4.75, -1.25, 0, -4.75, -1.25, 0, -4.75, -1.25, 3, -4.75, -1.25, 0, -6.75, -1.25, 0, -6.75, -1.25, 3, -4.75, -1.25, 3, -6.75, -1.25, 3, -4.75, 1.25, 3, -4.75, -1.25, 3, -6.75, -1.25, 3, -6.75, 1.25, 3, -4.75, 1.25, 3, -6.75, 1.25, 0, -4.75, 0.625, 0, -4.75, 1.25, 0, -6.75, 1.25, 0, -6.75, 0.625, 0, -4.75, -1.25, 0, -6.75, -1.25, 0, -6.75, 0.625, 0, -4.75, -1.25, 0, -4.75, -1.25, 0, -4.75, 0.625, 0, -4.75, -0.625, 0, -4.75, 1.25, 2.5, -4.75, 1.25, 0, -4.75, 1.25, 3, -4.75, 1.25, 3, -4.75, 1.25, 0, -4.75, 1.25, 3, -6.75, 1.25, 3, -6.75, 1.25, 0, -4.75, 1.25, 0, -6.75)
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_e4hmc"]
|
||||
radius = 0.3
|
||||
|
||||
[node name="PlayerShip" type="Node3D"]
|
||||
script = ExtResource("1_0r2ng")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
collision_layer = 5
|
||||
@ -31,5 +47,19 @@ surface_material_override/2 = SubResource("StandardMaterial3D_xpsdy")
|
||||
surface_material_override/3 = SubResource("StandardMaterial3D_nbws3")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
visible = false
|
||||
shape = SubResource("ConcavePolygonShape3D_nafoa")
|
||||
|
||||
[node name="TankInteractor" type="StaticBody3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
script = ExtResource("6_e4hmc")
|
||||
label = "GRUNK TANK"
|
||||
verb = "deposit"
|
||||
metadata/_custom_type_script = "uid://deg5xd87cy8rg"
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TankInteractor"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.85, 1.35, 4.5)
|
||||
shape = SubResource("SphereShape3D_e4hmc")
|
||||
|
||||
[connection signal="activated" from="TankInteractor" to="." method="deposit_grunk"]
|
||||
|
@ -4,6 +4,9 @@ class_name GameManagerType extends Node
|
||||
## Emitted just after `delta` is added to the player's grunk tank.
|
||||
signal grunk_collected(delta: float)
|
||||
|
||||
## Emitted just after the grunk tank is emptied, where `amount` is how much had been collected.
|
||||
signal grunk_emptied(amount: float)
|
||||
|
||||
## Emitted just before the alert level is raised to `new_value`.
|
||||
signal alert_raised(new_value: int)
|
||||
|
||||
@ -12,8 +15,13 @@ signal alert_cleared
|
||||
|
||||
const MAX_ALERT := 6
|
||||
|
||||
## Amount of grunk the player is currently carrying.
|
||||
var grunk_tank := 0.0
|
||||
|
||||
## Total amount of grunk that has been deposited by the player.
|
||||
var grunk_vault := 0.0
|
||||
|
||||
## Level of grunk agressiveness, raised whenever the player messes up.
|
||||
var alert_level := 0
|
||||
|
||||
|
||||
@ -23,6 +31,19 @@ func collect_grunk(delta: float) -> void:
|
||||
grunk_collected.emit(delta)
|
||||
|
||||
|
||||
## Empty the player's grunk tank, e.g. when depositing grunk.
|
||||
func empty_tank() -> void:
|
||||
var amount := grunk_tank
|
||||
grunk_tank = 0.0
|
||||
grunk_emptied.emit(amount)
|
||||
|
||||
|
||||
## Deposit the player's grunk in the vault, emptying the player's tank.
|
||||
func deposit_tank() -> void:
|
||||
grunk_vault += grunk_tank
|
||||
empty_tank()
|
||||
|
||||
|
||||
## Raise the alert level, if possible.
|
||||
func raise_alert(delta: int) -> void:
|
||||
var new_value := clampi(alert_level + delta, 0, MAX_ALERT)
|
||||
|
@ -4,6 +4,8 @@ class_name Interactive extends StaticBody3D
|
||||
signal activated
|
||||
|
||||
@export var enabled := false
|
||||
@export var label := ""
|
||||
@export var verb := "use"
|
||||
|
||||
|
||||
func activate() -> void:
|
||||
|
@ -1,13 +1,15 @@
|
||||
extends HBoxContainer
|
||||
## Does a funky lil bump when you collect tha grunk
|
||||
|
||||
const COUNTER_BUMP_RATE := 0.3
|
||||
const COUNTER_BUMP_RATE := 0.15
|
||||
const COUNTER_SPINDOWN_TIME := 0.4
|
||||
|
||||
@onready var counter: Label = %Counter
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Game.manager.grunk_collected.connect(on_grunk_collected)
|
||||
Game.manager.grunk_emptied.connect(on_grunk_emptied)
|
||||
counter.pivot_offset = Vector2(0, counter.size.y)
|
||||
|
||||
|
||||
@ -16,5 +18,17 @@ func on_grunk_collected(delta: float) -> void:
|
||||
counter.scale = Vector2.ONE + Vector2.ONE * clampf(delta / 128.0, 0.1, 1.0)
|
||||
|
||||
|
||||
func on_grunk_emptied(amount: float) -> void:
|
||||
create_tween().tween_method(_set_counter, int(amount), 0, COUNTER_SPINDOWN_TIME).set_trans(
|
||||
Tween.TRANS_EXPO
|
||||
)
|
||||
|
||||
|
||||
## Used with the spindown tween from `on_grunk_emptied`
|
||||
func _set_counter(value: int) -> void:
|
||||
counter.text = str(value)
|
||||
counter.scale = Vector2.ONE * 2.0
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
counter.scale = counter.scale.lerp(Vector2.ONE, COUNTER_BUMP_RATE)
|
||||
|
41
src/ui/hud/interact_hud.gd
Normal file
41
src/ui/hud/interact_hud.gd
Normal file
@ -0,0 +1,41 @@
|
||||
class_name InteractHUD extends Control
|
||||
# Pops up when the player is looking at something interactable.
|
||||
|
||||
const TRANSITION_TIME := 0.06
|
||||
|
||||
const COLOR_VISIBLE := Color("#ffffffee")
|
||||
const COLOR_DISABLED := Color("#cccccc44")
|
||||
const COLOR_INVISIBLE := Color("#ffffff00")
|
||||
|
||||
@onready var interact_name: Label = %InteractName
|
||||
@onready var interact_verb: Label = %InteractVerb
|
||||
|
||||
|
||||
func _transition_color(color: Color) -> void:
|
||||
create_tween().tween_property(self, "modulate", color, TRANSITION_TIME).set_trans(
|
||||
Tween.TRANS_CUBIC
|
||||
)
|
||||
|
||||
|
||||
func _to_visible() -> void:
|
||||
_transition_color(COLOR_VISIBLE)
|
||||
|
||||
|
||||
func _to_disabled() -> void:
|
||||
_transition_color(COLOR_DISABLED)
|
||||
|
||||
|
||||
func _to_invisible() -> void:
|
||||
_transition_color(COLOR_INVISIBLE)
|
||||
|
||||
|
||||
func set_prop(prop: Interactive) -> void:
|
||||
if prop:
|
||||
interact_name.text = prop.label
|
||||
interact_verb.text = prop.verb
|
||||
if prop.enabled:
|
||||
_to_visible()
|
||||
else:
|
||||
_to_disabled()
|
||||
else:
|
||||
_to_invisible()
|
1
src/ui/hud/interact_hud.gd.uid
Normal file
1
src/ui/hud/interact_hud.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bdsv404evn4fk
|
@ -1,12 +1,6 @@
|
||||
class_name PlayerHUD extends Control
|
||||
|
||||
const TRANSITION_TIME := 0.06
|
||||
|
||||
const COLOR_VISIBLE := Color("#ffffffee")
|
||||
const COLOR_DISABLED := Color("#cccccc44")
|
||||
const COLOR_INVISIBLE := Color("#ffffff00")
|
||||
|
||||
@onready var interact_hud: Control = %InteractHUD
|
||||
@onready var interact_hud: InteractHUD = %InteractHUD
|
||||
|
||||
@onready var alert_player: AnimationPlayer = %AlertPlayer
|
||||
|
||||
@ -15,32 +9,8 @@ func _ready() -> void:
|
||||
Game.manager.alert_raised.connect(_on_raise_alert)
|
||||
|
||||
|
||||
func _transition_color(element: CanvasItem, color: Color) -> void:
|
||||
create_tween().tween_property(element, "modulate", color, TRANSITION_TIME).set_trans(
|
||||
Tween.TRANS_CUBIC
|
||||
)
|
||||
|
||||
|
||||
func _to_visible(element: Control) -> void:
|
||||
_transition_color(element, COLOR_VISIBLE)
|
||||
|
||||
|
||||
func _to_disabled(element: Control) -> void:
|
||||
_transition_color(element, COLOR_DISABLED)
|
||||
|
||||
|
||||
func _to_invisible(element: Control) -> void:
|
||||
_transition_color(element, COLOR_INVISIBLE)
|
||||
|
||||
|
||||
func select_interactive(prop: Interactive) -> void:
|
||||
if prop:
|
||||
if prop.enabled:
|
||||
_to_visible(interact_hud)
|
||||
else:
|
||||
_to_disabled(interact_hud)
|
||||
else:
|
||||
_to_invisible(interact_hud)
|
||||
interact_hud.set_prop(prop)
|
||||
|
||||
|
||||
func _on_raise_alert(_new_value: int) -> void:
|
||||
|
@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://dq1x21tq06dud"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://dq1x21tq06dud"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://b07fevr214mmr" path="res://src/ui/hud/hud_theme.tres" id="1_lirk3"]
|
||||
[ext_resource type="Script" uid="uid://lrsv0185bfu" path="res://src/ui/hud/player_hud.gd" id="2_j6lpx"]
|
||||
[ext_resource type="PackedScene" uid="uid://cq8qcp5xg41e0" path="res://src/ui/hud/grunk_counter/grunk_counter.tscn" id="3_5be8f"]
|
||||
[ext_resource type="Script" uid="uid://bdsv404evn4fk" path="res://src/ui/hud/interact_hud.gd" id="3_n6jee"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n6jee"]
|
||||
length = 0.001
|
||||
@ -94,20 +95,42 @@ offset_bottom = 100.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("3_n6jee")
|
||||
|
||||
[node name="Label" type="Label" parent="InteractHUD"]
|
||||
[node name="InteractName" type="Label" parent="InteractHUD"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 45.0
|
||||
grow_horizontal = 2
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="InteractHUD"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -20.0
|
||||
offset_top = -23.0
|
||||
offset_right = 20.0
|
||||
offset_left = -85.0
|
||||
offset_top = -45.0
|
||||
offset_right = 85.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
text = "Press [E] to use"
|
||||
|
||||
[node name="Label" type="Label" parent="InteractHUD/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Press [E] to "
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="InteractVerb" type="Label" parent="InteractHUD/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "use"
|
||||
|
||||
[node name="AlertHUD" type="Control" parent="."]
|
||||
custom_minimum_size = Vector2(800, 600)
|
||||
|
Loading…
x
Reference in New Issue
Block a user