This commit is contained in:
2024-01-26 00:00:07 +01:00
parent 0d2e01073c
commit bb763ea4e2
140 changed files with 30775 additions and 296 deletions

View File

@@ -1,14 +1,23 @@
extends Node
var close_request_window: ConfirmationDialog
var close_request_window: CanvasLayer
var pause_menu: PauseMenu
var fullscreen: bool
func _ready() -> void:
process_mode = Node.PROCESS_MODE_ALWAYS
close_request_window = preload("res://scenes/close_game_confirmation.tscn").instantiate()
add_child(close_request_window)
pause_menu = preload("res://scenes/gui/menus/pause_menu.tscn").instantiate()
add_child(pause_menu)
fullscreen = DisplayServer.window_get_mode() == 4
func _process(delta: float) -> void:
if Input.is_action_just_released("fullscreen"):
fullscreen = !fullscreen
toggle_fullscreen()
func _notification(what: int) -> void:
if what == NOTIFICATION_WM_CLOSE_REQUEST:
@@ -17,11 +26,12 @@ func _notification(what: int) -> void:
else:
popup_close_dialog()
if what == NOTIFICATION_APPLICATION_FOCUS_OUT:
show_pause_menu()
if !get_tree().current_scene is MainMenu :
show_pause_menu()
func popup_close_dialog() -> void:
uncapture_mouse()
close_request_window.popup()
close_request_window.show()
func show_pause_menu() -> void:
uncapture_mouse()
@@ -34,3 +44,9 @@ func uncapture_mouse() -> void:
func _input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
show_pause_menu()
func toggle_fullscreen() -> void:
if fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)

View File

@@ -1,7 +1,10 @@
extends ConfirmationDialog
extends CanvasLayer
func _on_confirmed() -> void:
pass # Replace with function body.
func _on_canceled() -> void:
func _on_close_pressed() -> void:
get_tree().quit()
func _on_main_menu_pressed() -> void:
hide()
WindowManager.pause_menu.hide()
get_tree().change_scene_to_file("res://scenes/gui/menus/main_menu.tscn")

View File

@@ -2,6 +2,10 @@ extends CanvasLayer
class_name GravityGunLayer
@onready var gravity_particles: GPUParticles3D = $SubViewportContainer/SubViewport/Node3D/Camera3D/MeshInstance3D/GravityParticles
@onready var sound_effect: SoundEffect = $SoundEffect
@onready var freeze_label: Label = $HUD/Freeze
@onready var distance_label: Label = $HUD/Distance
@export var player: Player
var collider: RigidBody3D
@@ -13,25 +17,35 @@ func _on_visibility_changed() -> void:
func _ready() -> void:
# Führt sie auch am Anfang aus wenn sich die visibility noch nicht geändert hat
_on_visibility_changed()
await player.ready
distance_label.text = "Distanz: " + str(player.spring_arm.spring_length)
func _physics_process(_delta):
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED && player.spring_arm.get_hit_length() > 1.5 && Input.is_action_pressed("gravity_activate"):
gravity_particles.visible = true
$HUD.visible = true
if !sound_effect.playing:
sound_effect.play_key("gravity")
if collider:
collider.global_position = player.goal.global_position
if Input.is_action_just_pressed("gravity_freeze"):
collider.freeze = true
freeze_label.text = "Freeze: Aktiv"
elif player.raycast.get_collider() is RigidBody3D:
collider = player.raycast.get_collider()
collider.freeze = false
freeze_label.text = "Freeze: Inaktiv"
lock_vertical_rotation(collider,true)
if Input.is_action_pressed("gravity_push") || Input.is_action_just_pressed("gravity_push"):
player.spring_arm.spring_length += .5
distance_label.text = "Distanz: " + str(player.spring_arm.spring_length)
if Input.is_action_pressed("gravity_pull") || Input.is_action_just_pressed("gravity_pull"):
player.spring_arm.spring_length -= .5
distance_label.text = "Distanz: " + str(player.spring_arm.spring_length)
player.spring_arm.spring_length = clamp(player.spring_arm.spring_length,2,spring_length_cap)
else:
gravity_particles.visible = false
$HUD.visible = false
sound_effect.stop()
if collider:
lock_vertical_rotation(collider,false)
collider = null

View File

@@ -3,7 +3,10 @@ extends Completer
@onready var animation_player: AnimationPlayer = $AnimationPlayer
func _on_interaction_area_interacted():
animation_player.play("press")
if completed:
animation_player.play_backwards("press")
else:
animation_player.play("press")
toggle_complete()
if one_shot:
await animation_player.animation_finished

View File

@@ -0,0 +1,11 @@
extends PanelContainer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@@ -6,3 +6,7 @@ func _ready() -> void:
func _on_start_game_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/levels/lvl_1.tscn")
func _on_quit_game_pressed() -> void:
get_tree().quit()

View File

@@ -15,6 +15,10 @@ var camera_senitivity: float = 0.5
@onready var goal: Node3D = $Camera3D/SpringArm3D/GravityGunGoal
@onready var spring_arm: SpringArm3D = $Camera3D/SpringArm3D
@onready var sound_effect: SoundEffect = $FootSteps
var step_sound_toggle: bool
@onready var step_timer: Timer = $FootStepTimer
func _ready() -> void:
if get_tree().current_scene is MainMenu:
queue_free()
@@ -31,16 +35,22 @@ func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
sound_effect.play_key("jump")
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED * delta * 50
velocity.z = direction.z * SPEED * delta * 50
if step_timer.is_stopped() && is_on_floor():
sound_effect.play_key("step1")
step_timer.start()
elif !is_on_floor():
step_timer.stop()
else:
velocity.x = move_toward(velocity.x, 0, SPEED * delta * 50)
velocity.z = move_toward(velocity.z, 0, SPEED * delta * 50)
step_timer.stop()
move_and_slide()
# Pushing other objects
@@ -63,3 +73,11 @@ func capture(value: bool = true) -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _on_foot_step_timer_timeout() -> void:
step_sound_toggle = !step_sound_toggle
if step_sound_toggle:
sound_effect.play_key("step1")
else:
sound_effect.play_key("step2")

12
scripts/sound_effect.gd Normal file
View File

@@ -0,0 +1,12 @@
extends AudioStreamPlayer
class_name SoundEffect
@export var audio_library: Array[SoundeffectResource]
func play_key(key: String) -> void:
for res in audio_library:
if res.key == key:
stream = res.audio
play()
return
push_error(key + " is not available in the Audio Library variable")

View File

@@ -0,0 +1,5 @@
extends Resource
class_name SoundeffectResource
@export var key: String
@export var audio: AudioStreamWAV