idk anymore
This commit is contained in:
@@ -1,12 +1,33 @@
|
||||
extends Node
|
||||
|
||||
var close_request_window: ConfirmationDialog
|
||||
var pause_menu: PauseMenu
|
||||
|
||||
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)
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
close_request_window.popup()
|
||||
popup_close_dialog()
|
||||
if what == NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
show_pause_menu()
|
||||
|
||||
func popup_close_dialog() -> void:
|
||||
uncapture_mouse()
|
||||
close_request_window.popup()
|
||||
|
||||
func show_pause_menu() -> void:
|
||||
uncapture_mouse()
|
||||
get_tree().paused = true
|
||||
pause_menu.show()
|
||||
|
||||
func uncapture_mouse() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("pause"):
|
||||
show_pause_menu()
|
||||
|
@@ -6,25 +6,25 @@ class_name GravityGunLayer
|
||||
@export var player: Player
|
||||
var collider: RigidBody3D
|
||||
|
||||
var spring_length_cap: float
|
||||
@export_range(1.5,10) var spring_length_cap: float = 10
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
set_physics_process(visible) # Deaktiviert die Schleife unten wenn die Gun unsichtbar ist.
|
||||
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
|
||||
spring_length_cap = player.spring_arm.spring_length
|
||||
|
||||
func _physics_process(_delta):
|
||||
if player.spring_arm.get_hit_length() > 1.5 && Input.is_action_pressed("gravity_activate"):
|
||||
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
|
||||
if collider:
|
||||
collider.global_position = player.goal.global_position
|
||||
if Input.is_action_just_pressed("gravity_freeze"):
|
||||
collider.freeze = true
|
||||
elif player.raycast.get_collider() is RigidBody3D:
|
||||
collider = player.raycast.get_collider()
|
||||
collider.lock_rotation = true
|
||||
collider.freeze = false
|
||||
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
|
||||
if Input.is_action_pressed("gravity_pull") || Input.is_action_just_pressed("gravity_pull"):
|
||||
@@ -33,6 +33,14 @@ func _physics_process(_delta):
|
||||
else:
|
||||
gravity_particles.visible = false
|
||||
if collider:
|
||||
collider.lock_rotation = false
|
||||
lock_vertical_rotation(collider,false)
|
||||
collider = null
|
||||
|
||||
func lock_vertical_rotation(body: RigidBody3D, locked: bool):
|
||||
if locked:
|
||||
var rot = body.rotation
|
||||
body.rotation = Vector3(0,rot.y,0)
|
||||
body.axis_lock_linear_x = locked
|
||||
body.axis_lock_linear_z = locked
|
||||
body.axis_lock_angular_x = locked
|
||||
body.axis_lock_angular_z = locked
|
||||
|
@@ -1,4 +1,5 @@
|
||||
extends Control
|
||||
class_name MainMenu
|
||||
|
||||
func _on_start_game_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
get_tree().change_scene_to_file("res://scenes/levels/lvl_1.tscn")
|
||||
|
@@ -1,3 +1,20 @@
|
||||
extends Control
|
||||
extends CanvasLayer
|
||||
class_name PauseMenu
|
||||
|
||||
signal continued
|
||||
|
||||
func _on_continue_pressed() -> void:
|
||||
hide()
|
||||
get_tree().paused = false
|
||||
continued.emit()
|
||||
|
||||
|
||||
func _on_restart_level_pressed() -> void:
|
||||
if !get_tree().current_scene is MainMenu:
|
||||
get_tree().reload_current_scene()
|
||||
hide()
|
||||
get_tree().paused = false
|
||||
|
||||
|
||||
func _on_close_level_pressed() -> void:
|
||||
WindowManager.popup_close_dialog()
|
||||
|
@@ -19,6 +19,7 @@ func _ready() -> void:
|
||||
capture()
|
||||
camera.make_current()
|
||||
$Camera3D/DDOF.show() # Würde den spieler im editor unsichtbar machen
|
||||
WindowManager.pause_menu.continued.connect(capture)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
gun_cam.transform = camera.transform
|
||||
@@ -51,16 +52,9 @@ func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion && Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
rotate_y(-event.relative.x * camera_senitivity * 0.0025)
|
||||
camera.rotate_x(-event.relative.y * camera_senitivity * 0.0015)
|
||||
camera.rotation_degrees.x = clamp(camera.rotation_degrees.x, -80, 80)
|
||||
camera.rotation_degrees.x = clamp(camera.rotation_degrees.x, -50, 80)
|
||||
if event.is_action_pressed("pause"):
|
||||
capture(false)
|
||||
if event.is_action_pressed("mouse_capture"):
|
||||
capture()
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
capture(false)
|
||||
|
||||
func capture(value: bool = true) -> void:
|
||||
if value:
|
||||
|
Reference in New Issue
Block a user