30 lines
1.5 KiB
GDScript
30 lines
1.5 KiB
GDScript
extends "res://scripts/game/shield_visual.gd"
|
|
|
|
func _uses_cached_shell() -> bool:
|
|
return false
|
|
|
|
func _draw() -> void:
|
|
if current_shields > 0.0:
|
|
var ratio := clampf(current_shields/max_shields,0.0,1.0)
|
|
var tint := Color("ba8cff")
|
|
var pulse := 0.85+sin(_time*2.0)*0.15
|
|
draw_circle(Vector2.ZERO,shield_radius,Color(tint,0.025*pulse))
|
|
draw_arc(Vector2.ZERO,shield_radius,0,TAU,112,Color(tint,0.55*pulse),1.8,true)
|
|
draw_arc(Vector2.ZERO,shield_radius+2.0,0,TAU,112,Color(tint,0.11),5.0,true)
|
|
for index in 12:
|
|
var start := TAU*index/12.0+_time*0.12
|
|
draw_arc(Vector2.ZERO,shield_radius-4.0,start,start+0.25,8,Color(Color("8ee9ff"),0.2+ratio*0.3),1.0,true)
|
|
for row in range(-3,4):
|
|
for column in range(-3,4):
|
|
var center := Vector2(column*18.0+9.0*(posmod(row,2)),row*15.6)
|
|
if center.length()+10.0 >= shield_radius: continue
|
|
var hexagon := PackedVector2Array()
|
|
for vertex in 7: hexagon.append(center+Vector2.from_angle(vertex*TAU/6.0+PI/6.0)*10.0)
|
|
draw_polyline(hexagon,Color(tint,0.045*pulse),0.7,true)
|
|
# Counter-rotate the readout so it stays legible as the ship turns.
|
|
draw_set_transform(Vector2.ZERO,-global_rotation)
|
|
draw_string(ThemeDB.fallback_font,Vector2(-65,-shield_radius-12), tr("OSŁONA %.0f / %.0f" % [current_shields,max_shields]),HORIZONTAL_ALIGNMENT_CENTER,130,11,Color("d7bfff"))
|
|
draw_set_transform(Vector2.ZERO)
|
|
# Keep the existing directional impact ripples on the larger perimeter.
|
|
if not _hits.is_empty(): _draw_impacts()
|