new work towards M8
This commit is contained in:
parent
5cd0c24223
commit
bb7fd5cb3b
13 changed files with 194 additions and 75 deletions
|
@ -80,21 +80,26 @@ func player_hit(target, beast):
|
|||
Game.player_hit(target, beast)
|
||||
|
||||
@rpc("any_peer", "call_local", "unreliable")
|
||||
func sync_player(node_name, position, rotation):
|
||||
func sync_player(node_path, position, rotation):
|
||||
if is_valid(multiplayer.get_remote_sender_id(), false):
|
||||
Game.sync_player(node_name, position, rotation)
|
||||
Game.sync_player(node_path, position, rotation)
|
||||
|
||||
@rpc("any_peer", "call_local", "unreliable")
|
||||
func sync_hammer(node_name, rotation):
|
||||
func sync_hammer(node_path, rotation):
|
||||
if is_valid(multiplayer.get_remote_sender_id(), false):
|
||||
Game.sync_hammer(node_name, rotation)
|
||||
Game.sync_hammer(node_path, rotation)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_computers(node_name, current):
|
||||
func sync_computers(node_path, current):
|
||||
if is_valid(multiplayer.get_remote_sender_id(), true):
|
||||
Game.sync_computers(node_name, current)
|
||||
Game.sync_computers(node_path, current)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_beast(player):
|
||||
if is_valid(multiplayer.get_remote_sender_id(), true):
|
||||
Game.sync_beast(player)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_level(map_name):
|
||||
if is_valid(multiplayer.get_remote_sender_id(), true):
|
||||
Game.map_name = map_name
|
||||
|
|
|
@ -23,7 +23,7 @@ func _on_computer_tick_timeout():
|
|||
if Game.is_server:
|
||||
current += pc_occupied
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_computers",name, current)
|
||||
Client.rpc_id(id,"sync_computers",get_path(), current)
|
||||
if current >= TARGET:
|
||||
current = "Complete"
|
||||
$computer_tick.stop()
|
||||
|
|
|
@ -11,9 +11,29 @@ extends Control
|
|||
|
||||
var elevated = false
|
||||
var done
|
||||
var map_name = "mansion"
|
||||
|
||||
func _ready():
|
||||
$player_customization/name.text = Game.settings["username"]
|
||||
var username_cmdline
|
||||
var roomname_cmdline
|
||||
for argument in OS.get_cmdline_args():
|
||||
if argument == "--username":
|
||||
username_cmdline = "ready"
|
||||
continue
|
||||
if argument == "--roomname":
|
||||
roomname_cmdline = "ready"
|
||||
continue
|
||||
if argument == "--autojoin":
|
||||
_on_join_pressed()
|
||||
if username_cmdline == "ready":
|
||||
username_cmdline = null
|
||||
$player_customization/name.text = argument
|
||||
if roomname_cmdline == "ready":
|
||||
roomname_cmdline = null
|
||||
$player_customization/ip.text = argument
|
||||
multiplayer.connected_to_server.connect(_on_connected_ok)
|
||||
multiplayer.peer_connected.connect(_sync_options)
|
||||
|
||||
func server_prepare():
|
||||
if Game.is_server:
|
||||
|
@ -23,6 +43,8 @@ func server_prepare():
|
|||
$start/start.show()
|
||||
$start/start.disabled = false
|
||||
$player_list/list.text = " "
|
||||
$options.show()
|
||||
$options/map_name/OptionButton.disabled = false
|
||||
|
||||
func _process(_delta):
|
||||
server_prepare()
|
||||
|
@ -55,3 +77,17 @@ func _on_connected_ok():
|
|||
$player_customization/join.disabled = true
|
||||
$player_customization/name.editable = false
|
||||
$player_customization/ip.editable = false
|
||||
|
||||
|
||||
func _on_option_button_item_selected(index):
|
||||
match index:
|
||||
0:
|
||||
map_name = "mansion"
|
||||
_:
|
||||
map_name = "mansion"
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id, "sync_level", map_name)
|
||||
|
||||
func _sync_options():
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id, "sync_level", map_name)
|
||||
|
|
|
@ -14,12 +14,14 @@ var occupied = false
|
|||
var living = true
|
||||
|
||||
func _process(_delta):
|
||||
if occupied:
|
||||
trapped_body.position = global_position
|
||||
if occupied and trapped_body.hp == 0 and living:
|
||||
Game.died()
|
||||
living = false
|
||||
$dead.show()
|
||||
$Sprite3D.hide()
|
||||
elif occupied:
|
||||
trapped_body.position = global_position
|
||||
$Sprite3D.show()
|
||||
|
||||
func _on_area_3d_body_entered(body):
|
||||
if body is CharacterBody3D:
|
||||
|
|
|
@ -79,7 +79,6 @@ func reset():
|
|||
func save_setting(setting_name, value):
|
||||
settings[setting_name] = value
|
||||
Save.saveJSON("user://settings.json", settings)
|
||||
print("saved")
|
||||
|
||||
func apply_settings():
|
||||
players = player_list.size() - 1
|
||||
|
@ -105,24 +104,24 @@ func start_game():
|
|||
apply_settings()
|
||||
|
||||
func player_hit(target, beast):
|
||||
target = get_tree().root.get_node("./"+map_name+"/"+target)
|
||||
beast = get_tree().root.get_node("./"+map_name+"/"+beast)
|
||||
target = get_tree().root.get_node(target)
|
||||
beast = get_tree().root.get_node(beast)
|
||||
if !target.is_frozen:
|
||||
target.captured(beast)
|
||||
beast.got_one(target)
|
||||
|
||||
func sync_player(node_name, position, rotation):
|
||||
if get_tree().root.has_node("./"+map_name+"/"+node_name):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/"+node_name)
|
||||
func sync_player(node_path, position, rotation):
|
||||
if get_tree().root.has_node(node_path):
|
||||
var current_character = get_tree().root.get_node(node_path)
|
||||
current_character.position = position
|
||||
current_character.rotation = rotation
|
||||
|
||||
func sync_hammer(node_name, rotation):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/"+node_name+"/hammer")
|
||||
func sync_hammer(node_path, rotation):
|
||||
var current_character = get_tree().root.get_node(node_path)
|
||||
current_character.rotation = rotation
|
||||
|
||||
func sync_computers(node_name, current):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/computers/"+node_name)
|
||||
func sync_computers(node_path, current):
|
||||
var current_character = get_tree().root.get_node(node_path)
|
||||
current_character.current = current
|
||||
|
||||
func sync_beast(player):
|
||||
|
|
|
@ -14,9 +14,6 @@ func matchmaking():
|
|||
|
||||
func _ready():
|
||||
Game.reset()
|
||||
if !OS.is_debug_build():
|
||||
$main_content/matchmaking.hide()
|
||||
$main_content/matchmaking.disabled = true
|
||||
if DisplayServer.get_name() == "headless":
|
||||
matchmaking()
|
||||
|
||||
|
@ -24,6 +21,5 @@ func _on_join_pressed():
|
|||
get_tree().change_scene_to_file("res://menus/create.tscn")
|
||||
|
||||
|
||||
|
||||
func _on_settings_pressed():
|
||||
get_tree().change_scene_to_file("res://menus/settings.tscn")
|
||||
|
|
|
@ -71,11 +71,11 @@ func _physics_process(delta):
|
|||
if Input.is_action_pressed("click") and $hammer.rotation_degrees.x > 0:
|
||||
$hammer.rotation_degrees.x -= 10
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_hammer",name, $hammer.rotation)
|
||||
Client.rpc_id(id,"sync_hammer",$hammer.get_path(), $hammer.rotation)
|
||||
elif $hammer.rotation_degrees.x < 90 and !Input.is_action_pressed("click"):
|
||||
$hammer.rotation_degrees.x += 10
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_hammer",name, $hammer.rotation)
|
||||
Client.rpc_id(id,"sync_hammer",$hammer.get_path(), $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()
|
||||
|
@ -90,7 +90,7 @@ func _physics_process(delta):
|
|||
|
||||
if !npc:
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_player",name, position, rotation)
|
||||
Client.rpc_id(id,"sync_player",get_path(), position, rotation)
|
||||
if mouse_locked and !has_node("./game_menu"):
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
|
@ -138,24 +138,26 @@ func beast_init():
|
|||
func _on_detect_hit_body_entered(body):
|
||||
if enabled and body is CharacterBody3D and !got_person:
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"player_hit",body.name, name)
|
||||
Client.rpc_id(id,"player_hit",body.get_path(), get_path())
|
||||
|
||||
func captured(beast2):
|
||||
if !npc:
|
||||
$in_bag.visible = true
|
||||
$time_in_bag.start()
|
||||
visible = false
|
||||
enabled = false
|
||||
caught = true
|
||||
captured_by = beast2
|
||||
position_pre = position
|
||||
position = Vector3(10000, 10000, 10000)
|
||||
if !beast:
|
||||
if !npc:
|
||||
$in_bag.visible = true
|
||||
$time_in_bag.start()
|
||||
visible = false
|
||||
enabled = false
|
||||
caught = true
|
||||
captured_by = beast2
|
||||
position_pre = position
|
||||
position = Vector3(10000, 10000, 10000)
|
||||
|
||||
|
||||
func got_one(target):
|
||||
caught_body = target
|
||||
got_person = true
|
||||
$bag/CSGSphere3D.show()
|
||||
if !target.beast:
|
||||
caught_body = target
|
||||
got_person = true
|
||||
$bag/CSGSphere3D.show()
|
||||
|
||||
func lost_one():
|
||||
got_person = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue