You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
470 B

  1. extends Node
  2. export var coin_scene : PackedScene
  3. export var all_coins_picked_up_script : Resource
  4. var coins := -1
  5. func spawn():
  6. if coins < 0: # not spawned yet
  7. coins = 0
  8. for spawn in get_children():
  9. var coin = coin_scene.instance()
  10. coin.connect("picked_up", self, "on_coin_picked_up")
  11. coins += 1
  12. spawn.add_child(coin)
  13. func on_coin_picked_up():
  14. coins -= 1
  15. if coins == 0:
  16. EventDispatcher.emit_signal("trigger_script", all_coins_picked_up_script)