128 lines
4.5 KiB
GDScript
128 lines
4.5 KiB
GDScript
# Do not change those values
|
|
extends Node3D
|
|
|
|
#region DO NOT CHANGE
|
|
var paused = false
|
|
@onready var pause_menu = $PauseMenu
|
|
var checkpoint = checkpoint0
|
|
@onready var healthtext = $HUD/HBoxContainer/VBoxContainer/Label_Health
|
|
@onready var checkpointtext = $HUD/HBoxContainer/VBoxContainer/Label_Station
|
|
@onready var narrationtext = $HUD/HBoxContainer2/VBoxContainer2/Label
|
|
@onready var player = get_node("Player")
|
|
var time_accum = 0.0 # Timer accumulator
|
|
var elapsed_time := 0.0
|
|
var restart_count = 0
|
|
#endregion
|
|
|
|
var checkpoint0 = Vector3(0, 2, 1.374)
|
|
var checkpoint1 = Vector3(-27.5, 13, 12.5)
|
|
var checkpoint2 = Vector3(0, 22, 1.374)
|
|
var checkpoint3 = Vector3(-50, 25, -5)
|
|
var terminus = Vector3(-8, -8.5, 9.5)
|
|
|
|
#region DO NOT TOUCH
|
|
func _ready() -> void:
|
|
# var player = get_node("%Player")
|
|
narrationtext.hide()
|
|
checkpointtext.text = "station 0"
|
|
# checkpointtext.text = startmenu.stringing
|
|
# while true:
|
|
# wait(5)
|
|
# print(player.checkpoint)
|
|
|
|
|
|
# DEBUG SECTION: Testing whether checkpoint value is accessible by printing it every 4 seconds
|
|
#func _process(delta: float) -> void:
|
|
# var player = get_node("Player")
|
|
# time_accum += delta
|
|
# if time_accum >= 4.0:
|
|
# print("Checkpoint:", player.checkpoint)
|
|
# time_accum = 0.0
|
|
|
|
func wait(seconds: float) -> void:
|
|
await get_tree().create_timer(seconds).timeout
|
|
|
|
func _process(delta: float):
|
|
elapsed_time += delta
|
|
if Input.is_action_just_pressed("ui_cancel"):
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
|
pauseMenu()
|
|
elif Input.is_action_just_pressed("proluz_ui_respawn"):
|
|
player.teleport_to_checkpoint()
|
|
player.health = 100
|
|
Engine.time_scale = 1
|
|
player.audioplayer.stream = load("res://assets/audio/Revive.wav")
|
|
player.audioplayer.play()
|
|
restart_count = restart_count + 1
|
|
elif Input.is_action_just_pressed("proluz_ui_reset"):
|
|
get_tree().reload_current_scene()
|
|
$HUD/HBoxContainer/VBoxContainer/Label_Controls2.text = get_formatted_time()
|
|
# Health bar
|
|
if player.health == 100:
|
|
healthtext.text = "[//////////]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN)
|
|
elif player.health >= 90:
|
|
healthtext.text = "[/////////·]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN)
|
|
elif player.health >= 80:
|
|
healthtext.text = "[////////··]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN)
|
|
elif player.health >= 70:
|
|
healthtext.text = "[///////···]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN)
|
|
elif player.health >= 60:
|
|
healthtext.text = "[//////····]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN_YELLOW)
|
|
elif player.health >= 50:
|
|
healthtext.text = "[/////·····]"
|
|
healthtext.add_theme_color_override("font_color", Color.GREEN_YELLOW)
|
|
elif player.health >= 40:
|
|
healthtext.text = "[////······]"
|
|
healthtext.add_theme_color_override("font_color", Color.YELLOW)
|
|
elif player.health >= 30:
|
|
healthtext.text = "[///·······]"
|
|
healthtext.add_theme_color_override("font_color", Color.YELLOW)
|
|
elif player.health >= 20:
|
|
healthtext.text = "[//········]"
|
|
healthtext.add_theme_color_override("font_color", Color.YELLOW)
|
|
elif player.health >= 10:
|
|
healthtext.text = "[/·········]"
|
|
healthtext.add_theme_color_override("font_color", Color.INDIAN_RED)
|
|
elif player.health >= 1:
|
|
healthtext.text = "[|·········][CRITICAL]"
|
|
healthtext.add_theme_color_override("font_color", Color.RED)
|
|
elif player.health == 0:
|
|
healthtext.text = "[··········][DEAD/Shift+R to revive]"
|
|
healthtext.add_theme_color_override("font_color", Color.MEDIUM_PURPLE)
|
|
Engine.time_scale = 0.001
|
|
#endregion
|
|
|
|
func get_formatted_time() -> String:
|
|
var total_milliseconds = int(elapsed_time * 1000)
|
|
var minutes = total_milliseconds / 60000
|
|
var seconds = (total_milliseconds % 60000) / 1000
|
|
var milliseconds = total_milliseconds % 1000
|
|
return "time: %02d:%02d.%03d" % [minutes, seconds, milliseconds]
|
|
|
|
func pauseMenu():
|
|
if paused:
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
pause_menu.hide()
|
|
Engine.time_scale = 1
|
|
player.musicplayer.stream_paused = false
|
|
player.newmusicplayer.stream_paused = false
|
|
player.audioplayer.stream_paused = false
|
|
else:
|
|
pause_menu.show()
|
|
Engine.time_scale = 0.00001
|
|
player.musicplayer.stream_paused = true
|
|
player.newmusicplayer.stream_paused = true
|
|
player.audioplayer.stream_paused = true
|
|
# Engine.time_scale = -1
|
|
|
|
paused = !paused
|
|
|
|
func narrate(text: String):
|
|
player.audioplayer.stream = load("res://addons/kenney_ui_audio/switch38.wav")
|
|
player.audioplayer.play()
|
|
narrationtext.text = text
|