Reworked health indicator. Added blink charge indicator
This commit is contained in:
@@ -15,12 +15,12 @@ anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -16.0
|
||||
offset_top = -8.0
|
||||
offset_top = -1.0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 8.0
|
||||
offset_bottom = 2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
pivot_offset = Vector2(16, 8)
|
||||
pivot_offset = Vector2(16, 1)
|
||||
|
||||
[node name="ValueBar" type="TextureProgressBar" parent="."]
|
||||
layout_mode = 1
|
||||
@@ -30,12 +30,12 @@ anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -16.0
|
||||
offset_top = -8.0
|
||||
offset_top = -1.0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 8.0
|
||||
offset_bottom = 2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
pivot_offset = Vector2(16, 8)
|
||||
pivot_offset = Vector2(16, 1)
|
||||
|
||||
[node name="ShadeDelayTimer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
|
||||
@@ -5,58 +5,18 @@ extends Control
|
||||
@export var health: Health
|
||||
|
||||
|
||||
@onready var small_shield_part : HealthBarPart = $SmallShieldPart
|
||||
@onready var large_shield_part : HealthBarPart = $LargeShieldPart
|
||||
@onready var armor_part : HealthBarPart = $ArmorPart
|
||||
@onready var hull_part : HealthBarPart = $HullPart
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not health: return
|
||||
|
||||
small_shield_part.set_max_value(health.max_shield)
|
||||
small_shield_part.set_value(health.shield)
|
||||
|
||||
large_shield_part.set_max_value(health.max_shield)
|
||||
large_shield_part.set_value(health.shield)
|
||||
|
||||
armor_part.set_max_value(health.max_armor)
|
||||
armor_part.set_value(health.armor)
|
||||
|
||||
hull_part.set_max_value(health.max_hull)
|
||||
hull_part.set_value(health.hull)
|
||||
|
||||
_select_armor_part(health.armor)
|
||||
|
||||
health.shield_updated.connect(_on_shield_updated)
|
||||
health.armor_updated.connect(_on_armor_updated)
|
||||
health.hull_updated.connect(_on_hull_updated)
|
||||
|
||||
|
||||
func _on_shield_updated(value: int, max_value: int) -> void:
|
||||
small_shield_part.set_value(value)
|
||||
large_shield_part.set_value(value)
|
||||
small_shield_part.set_max_value(max_value)
|
||||
large_shield_part.set_max_value(max_value)
|
||||
|
||||
|
||||
func _on_armor_updated(value: int, max_value: int) -> void:
|
||||
armor_part.set_value(value)
|
||||
armor_part.set_max_value(max_value)
|
||||
_select_armor_part(value)
|
||||
|
||||
|
||||
func _on_hull_updated(value: int, max_value: int) -> void:
|
||||
hull_part.set_value(value)
|
||||
hull_part.set_max_value(max_value)
|
||||
|
||||
|
||||
func _select_armor_part(armor_value: int) -> void:
|
||||
if armor_value == 0:
|
||||
armor_part.hide()
|
||||
small_shield_part.show()
|
||||
large_shield_part.hide()
|
||||
else:
|
||||
armor_part.show()
|
||||
small_shield_part.hide()
|
||||
large_shield_part.show()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://d2snum2pxc2ui"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://d2snum2pxc2ui"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://be7k64p2kel8b" path="res://game/health_system/health_bar/heath_bar.gd" id="1_bx561"]
|
||||
[ext_resource type="PackedScene" uid="uid://xbfxsiumbgkp" path="res://game/health_system/health_bar/health_bar_part.tscn" id="2_wb6me"]
|
||||
@@ -6,39 +6,15 @@
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sgr4k"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(0, 64, 32, 16)
|
||||
region = Rect2(0, 6, 32, 3)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wb6me"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(0, 0, 32, 16)
|
||||
region = Rect2(0, 0, 32, 3)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fogsl"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(32, 0, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b6cw0"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(0, 16, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w8ken"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(32, 16, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hknxs"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(0, 32, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f0v4d"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(32, 32, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lfh3j"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(0, 48, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lc4fa"]
|
||||
atlas = ExtResource("3_fogsl")
|
||||
region = Rect2(32, 48, 32, 16)
|
||||
region = Rect2(0, 3, 32, 3)
|
||||
|
||||
[node name="HeathBar" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -48,28 +24,13 @@ script = ExtResource("1_bx561")
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = -16.0
|
||||
offset_top = -8.0
|
||||
offset_top = -1.0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 8.0
|
||||
pivot_offset = Vector2(16, 8)
|
||||
offset_bottom = 2.0
|
||||
pivot_offset = Vector2(16, 1)
|
||||
texture = SubResource("AtlasTexture_sgr4k")
|
||||
|
||||
[node name="HullPart" parent="." instance=ExtResource("2_wb6me")]
|
||||
layout_mode = 0
|
||||
texture_value = SubResource("AtlasTexture_wb6me")
|
||||
texture_shade = SubResource("AtlasTexture_fogsl")
|
||||
|
||||
[node name="ArmorPart" parent="." instance=ExtResource("2_wb6me")]
|
||||
layout_mode = 0
|
||||
texture_value = SubResource("AtlasTexture_b6cw0")
|
||||
texture_shade = SubResource("AtlasTexture_w8ken")
|
||||
|
||||
[node name="SmallShieldPart" parent="." instance=ExtResource("2_wb6me")]
|
||||
layout_mode = 0
|
||||
texture_value = SubResource("AtlasTexture_hknxs")
|
||||
texture_shade = SubResource("AtlasTexture_f0v4d")
|
||||
|
||||
[node name="LargeShieldPart" parent="." instance=ExtResource("2_wb6me")]
|
||||
layout_mode = 0
|
||||
texture_value = SubResource("AtlasTexture_lfh3j")
|
||||
texture_shade = SubResource("AtlasTexture_lc4fa")
|
||||
|
||||
Reference in New Issue
Block a user