Public repository for MUR pre alpha
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.

52 lines
1.7 KiB

  1. extends Spatial
  2. var player:Player
  3. onready var camera:InterpolatedCamera = get_node("camera")
  4. onready var ingame_menu:Spatial = find_node("ingame_menu")
  5. func _physics_process(delta):
  6. if is_network_master() && player != null:
  7. if Input.is_action_just_pressed("controls_menu"):
  8. ingame_menu.set_visible(not ingame_menu.is_visible_in_tree())
  9. if player.is_out:
  10. camera.set_speed(0.1)
  11. if player.timer.get_time_left() > 0:
  12. get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1))
  13. else:
  14. get_node("hud/reset").set_text(tr("RESET"))
  15. if Input.is_action_pressed("controls_reset"):
  16. if player.reset():
  17. camera.set_speed(10)
  18. get_node("hud/reset").set_text("")
  19. elif not ingame_menu.is_visible_in_tree():
  20. if Input.is_action_pressed("controls_thrust"):
  21. player.thrust = 1
  22. elif Input.is_action_pressed("controls_break"):
  23. player.thrust = -1
  24. else:
  25. player.thrust = 0
  26. get_node("hud/speed_slider").set_value(player.current_speed * 1000)
  27. if Input.is_action_pressed("debug_camera_1"):
  28. set_debug_camera(0)
  29. elif Input.is_action_pressed("debug_camera_2"):
  30. set_debug_camera(1)
  31. elif Input.is_action_pressed("debug_camera_3"):
  32. set_debug_camera(2)
  33. elif Input.is_action_pressed("debug_camera_4"):
  34. set_debug_camera(3)
  35. func set_player(path:String):
  36. player = get_node(path)
  37. get_node("inventory").set_player(player)
  38. camera.set_target_path(player.find_node("CameraTarget").get_path())
  39. camera.set_interpolation_enabled(true)
  40. camera.set_speed(10)
  41. func set_debug_camera(idx):
  42. if idx < gamestate.game.get_node("players").get_child_count():
  43. camera.set_target_path(gamestate.game.get_node("players").get_child(idx).find_node("CameraTarget").get_path())