Massive work on level, UI, sound, and player functionality, small progress on netcode. Renamed project to Net Gunner.
This commit is contained in:
28
scripts/trap_display.gd
Normal file
28
scripts/trap_display.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name TrapDisplay extends PanelContainer
|
||||
|
||||
|
||||
const trap_hud_icon = preload("res://templates/trap_icon.tscn")
|
||||
@onready var trap_container : HBoxContainer = %TrapsContainer
|
||||
@onready var cycle_sound : AudioStreamPlayer = %CycleSound
|
||||
func clear_traps() -> void:
|
||||
for child in trap_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
func _on_trap_list_changed(traps, trap_index) -> void:
|
||||
clear_traps()
|
||||
for trap in traps:
|
||||
var ticon = trap_hud_icon.instantiate()
|
||||
trap_container.add_child(ticon)
|
||||
ticon.setup(trap.type, trap.quantity)
|
||||
%LeftArrow.visible = (trap_index != 0)
|
||||
%RightArrow.visible = (trap_index != trap_container.get_children().size() - 1)
|
||||
|
||||
func _on_trap_quantity_changed(trap_index, qty) -> void:
|
||||
var ticon = trap_container.get_child(trap_index) as TrapIcon
|
||||
ticon.set_quantity(qty)
|
||||
|
||||
func _on_trap_cycled(trap_index) -> void:
|
||||
trap_container.position.x = -trap_index * 150
|
||||
%LeftArrow.visible = (trap_index != 0)
|
||||
%RightArrow.visible = (trap_index != trap_container.get_children().size() - 1)
|
||||
cycle_sound.play()
|
||||
Reference in New Issue
Block a user