Milestone 6 Beta 2

Reworked multiplayer, like a lot.
This commit is contained in:
patrick_pluto 2024-08-06 23:28:40 +02:00
commit 9de67986dd
17 changed files with 309 additions and 89 deletions

View file

@ -25,6 +25,7 @@ var beast = false
var mouse_locked = true
var is_frozen = false
var hp = 100
var menu = preload("res://menus/game_menu.tscn")
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@ -65,7 +66,13 @@ func _physics_process(delta):
speed += 3
$cam_y.position.y = 0.5
position.y += 1
if Input.is_action_pressed("click") and $hammer.rotation_degrees.x > -90:
$hammer.rotation_degrees.x -= 5
Server.sync_hammer.rpc(name, $hammer.rotation)
elif $hammer.rotation_degrees.x < 0 and !Input.is_action_pressed("click"):
$hammer.rotation_degrees.x += 5
Server.sync_hammer.rpc(name, $hammer.rotation)
var input_dir = Input.get_vector("left", "right", "forwards", "backwards")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
@ -80,15 +87,18 @@ func _physics_process(delta):
if !npc:
Server.sync_player.rpc(name, position, rotation)
if mouse_locked:
if mouse_locked and !has_node("./game_menu"):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.is_action_just_pressed("escape"):
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
Game.reset()
Server.reset()
if has_node("./game_menu"):
get_node("./game_menu").free()
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
var instance = menu.instantiate()
add_child(instance)
if Input.is_action_just_pressed("mouse_lock"):
mouse_locked = !mouse_locked
@ -96,7 +106,7 @@ func _physics_process(delta):
func _input(event):
if !npc:
if event is InputEventMouseMotion and (Input.is_action_pressed("cam_look") or $cam_y/Camera3D.position.z == 0):
if event is InputEventMouseMotion and (Input.is_action_pressed("cam_look") or $cam_y/Camera3D.position.z == 0) and !has_node("./game_menu"):
var camera_rotation = event.relative * 0.01
if $cam_y.rotation.x <= 1.6 && camera_rotation.y <= 0:
$cam_y.rotate(Vector3.RIGHT, -camera_rotation.y)
@ -110,13 +120,16 @@ func _input(event):
func beast_init():
if !npc:
Game.is_beast = true
beast = true
speed += 2
position.y += 10
$detect_hit.monitoring = true
$detect_hit.monitorable = true
$detect_hit/CollisionShape3D.disabled = false
$hammer_bag.visible = true
$hammer/hammer2/CSGBox3D/detect_hit.monitoring = true
$hammer/hammer2/CSGBox3D/detect_hit.monitorable = true
$hammer/hammer2/CSGBox3D/detect_hit/CollisionShape3D.disabled = false
$hammer.show()
$bag.show()
func _on_detect_hit_body_entered(body):
if enabled and body is CharacterBody3D and !got_person:
@ -137,11 +150,11 @@ func captured(beast2):
func got_one(target):
caught_body = target
got_person = true
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = true
$bag/CSGSphere3D.show()
func lost_one():
got_person = false
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = false
$bag/CSGSphere3D.hide()
func frozen():
visible = true