24 lines
719 B
GDScript
24 lines
719 B
GDScript
extends TextureProgressBar
|
|
|
|
@export var weapon_signal_name = "minigun"
|
|
@onready var reset_position = position
|
|
|
|
var last_ammo : int = 99999
|
|
|
|
func _ready() -> void:
|
|
HudSignalBus.connect(weapon_signal_name, update)
|
|
|
|
func update(current_ammo : int, max_ammo : int):
|
|
if current_ammo < last_ammo:
|
|
last_ammo = current_ammo
|
|
$GPUParticles2D.emitting = true
|
|
get_tree().create_timer(0.1).timeout.connect(particle_foo)
|
|
value = (current_ammo*100.0)/max_ammo
|
|
$Label.text = str(current_ammo)
|
|
var tween = get_tree().create_tween()
|
|
tween.tween_property(self, "position", reset_position+(6*Vector2.ONE),.05)
|
|
tween.tween_property(self, "position", reset_position,.05)
|
|
|
|
func particle_foo():
|
|
$GPUParticles2D.emitting = false
|