Reworked health indicator. Added blink charge indicator
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user