2019-07-28 13:32:28 +02:00
|
|
|
extends Spatial
|
|
|
|
|
|
|
|
var player:Player
|
|
|
|
onready var camera:InterpolatedCamera = get_node("camera")
|
|
|
|
onready var ingame_menu:Spatial = find_node("ingame_menu")
|
|
|
|
|
|
|
|
|
2019-08-07 20:29:46 +02:00
|
|
|
func _process(delta):
|
2019-07-28 13:32:28 +02:00
|
|
|
if is_network_master() && player != null:
|
|
|
|
if Input.is_action_just_pressed("controls_menu"):
|
|
|
|
ingame_menu.set_visible(not ingame_menu.is_visible_in_tree())
|
2019-08-07 20:29:46 +02:00
|
|
|
if player.is_out():
|
2019-07-28 13:32:28 +02:00
|
|
|
camera.set_speed(0.1)
|
|
|
|
if player.timer.get_time_left() > 0:
|
|
|
|
get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1))
|
|
|
|
else:
|
|
|
|
get_node("hud/reset").set_text(tr("RESET"))
|
|
|
|
if Input.is_action_pressed("controls_reset"):
|
2019-08-07 20:29:46 +02:00
|
|
|
player.rpc("reset")
|
2019-07-28 13:32:28 +02:00
|
|
|
elif not ingame_menu.is_visible_in_tree():
|
2019-08-07 20:29:46 +02:00
|
|
|
camera.set_speed(10)
|
|
|
|
get_node("hud/reset").set_text("")
|
2019-07-28 13:32:28 +02:00
|
|
|
if Input.is_action_pressed("controls_thrust"):
|
2019-08-07 20:29:46 +02:00
|
|
|
player.rpc_unreliable("set_thrust",1)
|
2019-07-28 13:32:28 +02:00
|
|
|
elif Input.is_action_pressed("controls_break"):
|
2019-08-07 20:29:46 +02:00
|
|
|
player.rpc_unreliable("set_thrust",-1)
|
2019-07-28 13:32:28 +02:00
|
|
|
else:
|
2019-08-07 20:29:46 +02:00
|
|
|
player.rpc_unreliable("set_thrust",0)
|
2019-07-28 13:32:28 +02:00
|
|
|
|
|
|
|
get_node("hud/speed_slider").set_value(player.current_speed * 1000)
|
|
|
|
|
|
|
|
if Input.is_action_pressed("debug_camera_1"):
|
|
|
|
set_debug_camera(0)
|
|
|
|
elif Input.is_action_pressed("debug_camera_2"):
|
|
|
|
set_debug_camera(1)
|
|
|
|
elif Input.is_action_pressed("debug_camera_3"):
|
|
|
|
set_debug_camera(2)
|
|
|
|
elif Input.is_action_pressed("debug_camera_4"):
|
|
|
|
set_debug_camera(3)
|
|
|
|
|
|
|
|
|
|
|
|
func set_player(path:String):
|
|
|
|
player = get_node(path)
|
|
|
|
get_node("inventory").set_player(player)
|
|
|
|
camera.set_target_path(player.find_node("CameraTarget").get_path())
|
|
|
|
camera.set_interpolation_enabled(true)
|
|
|
|
camera.set_speed(10)
|
|
|
|
|
|
|
|
|
|
|
|
func set_debug_camera(idx):
|
|
|
|
if idx < gamestate.game.get_node("players").get_child_count():
|
|
|
|
camera.set_target_path(gamestate.game.get_node("players").get_child(idx).find_node("CameraTarget").get_path())
|