Made pause controller to be created on player if it exists

This commit is contained in:
2ndbeam 2024-04-30 21:24:51 +03:00
commit 93aa83dcaa
11 changed files with 129 additions and 17 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://dok3i8u5t1ka4"]
[gd_scene load_steps=11 format=3 uid="uid://dok3i8u5t1ka4"]
[ext_resource type="PackedScene" uid="uid://bjkshql8ut6hk" path="res://scenes/Ships/ship.tscn" id="1_6x7bu"]
[ext_resource type="Script" path="res://scripts/Ship/player_ship.gd" id="2_oqdd7"]
@ -58,6 +58,25 @@ func _process(_delta):
text = unformatted_text.format([ship.shield.capacity, ship.shield.max_capacity])
"
[sub_resource type="GDScript" id="GDScript_rrgab"]
resource_name = "ammunition_counter"
script/source = "extends Label
## Text with placeholder
@onready var unformatted_text: String = text
## Shortcut to get_parent().get_parent()
@onready var ship: PlayerShip = get_parent().get_parent()
func _process(_delta):
var format = [
ship.hull.ammunition[\"Laser Energy\"],
ship.hull.max_ammunition[\"Laser Energy\"],
ship.hull.ammunition[\"Rockets\"],
ship.hull.max_ammunition[\"Rockets\"]
]
text = unformatted_text.format(format)
"
[node name="PlayerShip" instance=ExtResource("1_6x7bu")]
script = ExtResource("2_oqdd7")
@ -66,6 +85,8 @@ script = ExtResource("3_0e84a")
[node name="Weapon" parent="Weapons" index="0" instance=ExtResource("4_fy1be")]
action_id = "primary"
ammo_type = "Laser Energy"
ammo_consumption = 1.0
[node name="ColorableGUI" type="CanvasLayer" parent="." index="5"]
@ -101,6 +122,17 @@ offset_bottom = 661.0
text = "Shield: {0} / {1} units"
script = SubResource("GDScript_q1sx2")
[node name="Ammunition" type="Label" parent="ColorableGUI" index="4"]
offset_left = 1060.0
offset_top = 638.0
offset_right = 1273.0
offset_bottom = 713.0
text = "Ammunition:
Laser Energy: {0} / {1}
Rockets: {2} / {3}"
horizontal_alignment = 2
script = SubResource("GDScript_rrgab")
[node name="NonColorableGUI" type="CanvasLayer" parent="." index="6"]
[node name="Camera" type="Camera2D" parent="." index="7"]