Reworked health indicator. Added blink charge indicator
This commit is contained in:
@@ -36,6 +36,7 @@ material = SubResource("ShaderMaterial_bkxo4")
|
||||
[node name="Health" parent="." instance=ExtResource("2_xxtvk")]
|
||||
|
||||
[node name="HeathBar" parent="." node_paths=PackedStringArray("health") instance=ExtResource("3_l62e5")]
|
||||
z_index = 101
|
||||
health = NodePath("../Health")
|
||||
|
||||
[node name="WeaponSlots" type="Node2D" parent="."]
|
||||
|
||||
@@ -42,8 +42,8 @@ rect = Rect2(-29, -21, 58, 42)
|
||||
max_hull = 200
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
offset_top = 27.0
|
||||
offset_bottom = 27.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(-8, 0)
|
||||
|
||||
@@ -42,8 +42,8 @@ rect = Rect2(-13, -21, 26, 42)
|
||||
max_hull = 100
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
offset_top = 19.0
|
||||
offset_bottom = 19.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(4, -8)
|
||||
|
||||
@@ -42,8 +42,8 @@ rect = Rect2(-13, -5, 26, 10)
|
||||
max_hull = 50
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 14.0
|
||||
offset_bottom = 14.0
|
||||
offset_top = 11.0
|
||||
offset_bottom = 11.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(5, 0)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
class_name BlinkChargeIndicator
|
||||
extends Node2D
|
||||
|
||||
|
||||
var maximum: float = 0:
|
||||
set = _set_maximum
|
||||
|
||||
var value: float = 0:
|
||||
set = _set_value
|
||||
|
||||
|
||||
@onready var progress_bar : TextureProgressBar = $ProgressBar
|
||||
@onready var charged_sprite : Sprite2D = $ChargedSprite
|
||||
|
||||
|
||||
func _set_maximum(new_value: float) -> void:
|
||||
maximum = new_value
|
||||
value = clampf(value, 0, maximum)
|
||||
progress_bar.max_value = maximum
|
||||
_update_charged_sprite()
|
||||
|
||||
|
||||
func _set_value(new_value: float) -> void:
|
||||
value = clampf(new_value, 0, maximum)
|
||||
progress_bar.value = value
|
||||
_update_charged_sprite()
|
||||
|
||||
|
||||
func _update_charged_sprite() -> void:
|
||||
if is_equal_approx(value, maximum):
|
||||
charged_sprite.show()
|
||||
else:
|
||||
charged_sprite.hide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bpfr1laquec3u
|
||||
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d20nvskf38vpo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpfr1laquec3u" path="res://game/entities/ships/player/blink_charge_indicator.gd" id="1_5n4fu"]
|
||||
[ext_resource type="Texture2D" uid="uid://y2yfli24n51v" path="res://images/ships/player.png" id="2_i476t"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fo48j"]
|
||||
atlas = ExtResource("2_i476t")
|
||||
region = Rect2(0, 128, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_i476t"]
|
||||
atlas = ExtResource("2_i476t")
|
||||
region = Rect2(16, 128, 16, 16)
|
||||
|
||||
[node name="BlinkChargeIndicator" type="Node2D"]
|
||||
script = ExtResource("1_5n4fu")
|
||||
|
||||
[node name="ProgressBar" type="TextureProgressBar" parent="."]
|
||||
offset_left = -8.0
|
||||
offset_top = -8.0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
step = 0.1
|
||||
value = 100.0
|
||||
texture_progress = SubResource("AtlasTexture_fo48j")
|
||||
|
||||
[node name="ChargedSprite" type="Sprite2D" parent="."]
|
||||
texture = SubResource("AtlasTexture_i476t")
|
||||
@@ -4,31 +4,51 @@ extends AbstractShip
|
||||
|
||||
const ENEMY_LAYER = 4
|
||||
|
||||
const BLINK_CHARGE_MAXIMUM = 3.0
|
||||
|
||||
|
||||
@export_range(0, 200) var blink_range := 0
|
||||
|
||||
|
||||
@onready var blink_timer : Timer = $BlinkTimer
|
||||
var blink_charge: float:
|
||||
set(value):
|
||||
blink_charge = value
|
||||
if blink_charge_indicator != null:
|
||||
blink_charge_indicator.value = blink_charge
|
||||
|
||||
|
||||
@onready var blink_shadow : GPUParticles2D = $BlinkShadow
|
||||
@onready var blink_charge_indicator : BlinkChargeIndicator = $BlinkChargeIndicator
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
|
||||
blink_charge_indicator.maximum = BLINK_CHARGE_MAXIMUM
|
||||
blink_charge = BLINK_CHARGE_MAXIMUM
|
||||
|
||||
for weapon_position in weapon_positions:
|
||||
var weapon : AbstractWeapon = WEAPONS.pick_random().instantiate()
|
||||
_add_weapon(weapon, weapon_position)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
super._physics_process(delta)
|
||||
|
||||
if blink_charge < BLINK_CHARGE_MAXIMUM:
|
||||
blink_charge += delta
|
||||
blink_charge_indicator.value = blink_charge
|
||||
|
||||
|
||||
func _add_weapon(weapon: AbstractWeapon, weapon_position: Vector2) -> void:
|
||||
super._add_weapon(weapon, weapon_position)
|
||||
weapon.set_belonging(AbstractWeapon.Belonging.PLAYER)
|
||||
|
||||
|
||||
func _blink(direction: Vector2) -> void:
|
||||
if not blink_timer.is_stopped(): return
|
||||
if blink_charge < BLINK_CHARGE_MAXIMUM: return
|
||||
|
||||
blink_timer.start()
|
||||
blink_charge = 0
|
||||
|
||||
var shadow : GPUParticles2D = blink_shadow.duplicate()
|
||||
var process_material : ParticleProcessMaterial = shadow.process_material
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://br074cqcnul3d"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://br074cqcnul3d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jvyagshykmgb" path="res://game/entities/ships/abstract_ship.tscn" id="1_6otxb"]
|
||||
[ext_resource type="Script" uid="uid://ruxw1n03iq4i" path="res://game/entities/ships/player/player_ship.gd" id="2_625ti"]
|
||||
[ext_resource type="PackedScene" uid="uid://dh1oj1w5wx4je" path="res://game/controllers/player_controller.tscn" id="3_4mjo1"]
|
||||
[ext_resource type="Texture2D" uid="uid://y2yfli24n51v" path="res://images/ships/player.png" id="3_uf2n1"]
|
||||
[ext_resource type="PackedScene" uid="uid://d20nvskf38vpo" path="res://game/entities/ships/player/blink_charge_indicator.tscn" id="5_uf2n1"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4mjo1"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
@@ -70,8 +71,8 @@ one_shot = true
|
||||
process_material = SubResource("ParticleProcessMaterial_pjmi2")
|
||||
|
||||
[node name="HeathBar" parent="." index="8"]
|
||||
offset_top = 22.0
|
||||
offset_bottom = 22.0
|
||||
offset_top = 19.0
|
||||
offset_bottom = 19.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(-2, 8)
|
||||
@@ -79,6 +80,9 @@ position = Vector2(-2, 8)
|
||||
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
|
||||
position = Vector2(-2, -8)
|
||||
|
||||
[node name="BlinkChargeIndicator" parent="." index="10" instance=ExtResource("5_uf2n1")]
|
||||
position = Vector2(-11, 0)
|
||||
|
||||
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
|
||||
[connection signal="blink" from="PlayerController" to="." method="_blink"]
|
||||
[connection signal="shoot" from="PlayerController" to="." method="shoot"]
|
||||
|
||||
@@ -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")
|
||||
|
||||
+23
-2
@@ -1,12 +1,21 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dgc0087kvarx6"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dgc0087kvarx6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c6gpm3edyr4nu" path="res://game/passage.gd" id="1_ltkyg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpn5x0ijgl7ei" path="res://game/controllers/enemy_swamp_controller.tscn" id="2_72vqi"]
|
||||
[ext_resource type="PackedScene" uid="uid://br074cqcnul3d" path="res://game/entities/ships/player/player_ship.tscn" id="3_r3x05"]
|
||||
[ext_resource type="PackedScene" uid="uid://chdrjc7c6bdpb" path="res://game/background.tscn" id="4_cuj01"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1n7qejdcrpkf" path="res://images/passage_process.png" id="5_yetnv"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ltkyg"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_u0ams"]
|
||||
atlas = ExtResource("5_yetnv")
|
||||
region = Rect2(0, 0, 640, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_heelu"]
|
||||
atlas = ExtResource("5_yetnv")
|
||||
region = Rect2(0, 8, 640, 8)
|
||||
|
||||
[node name="Passage" type="Node2D"]
|
||||
script = ExtResource("1_ltkyg")
|
||||
|
||||
@@ -20,7 +29,7 @@ shape = SubResource("WorldBoundaryShape2D_ltkyg")
|
||||
one_way_collision = true
|
||||
|
||||
[node name="CollisionBottom" type="CollisionShape2D" parent="World"]
|
||||
position = Vector2(320, 360)
|
||||
position = Vector2(320, 352)
|
||||
shape = SubResource("WorldBoundaryShape2D_ltkyg")
|
||||
one_way_collision = true
|
||||
|
||||
@@ -49,5 +58,17 @@ autostart = true
|
||||
|
||||
[node name="Background" parent="." instance=ExtResource("4_cuj01")]
|
||||
|
||||
[node name="TextureProgressBar" type="TextureProgressBar" parent="."]
|
||||
z_index = 100
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 352.0
|
||||
offset_right = 640.0
|
||||
offset_bottom = 360.0
|
||||
grow_vertical = 0
|
||||
texture_under = SubResource("AtlasTexture_u0ams")
|
||||
texture_progress = SubResource("AtlasTexture_heelu")
|
||||
|
||||
[connection signal="destroyed" from="PlayerShip" to="." method="_on_player_ship_destroyed"]
|
||||
[connection signal="timeout" from="EnemyTimer" to="." method="_on_enemy_timer_timeout"]
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d1n7qejdcrpkf"
|
||||
path="res://.godot/imported/passage_process.png-bff772a67d53dffb8cf9f2e6d1d84977.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://images/passage_process.png"
|
||||
dest_files=["res://.godot/imported/passage_process.png-bff772a67d53dffb8cf9f2e6d1d84977.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user