Milestone 8 preparations 1
This commit is contained in:
parent
8b97a6ee7e
commit
c9211b444e
26 changed files with 101 additions and 104 deletions
|
@ -17,7 +17,7 @@ func _ready():
|
|||
|
||||
func join_game():
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
peer.create_client(Game.settings["ip"], Game.settings["port"])
|
||||
peer.create_client(Game.settings["ip"], int(Game.settings["port"]))
|
||||
multiplayer.multiplayer_peer = peer
|
||||
|
||||
func is_valid(sender_id, must_be_from_owner):
|
||||
|
|
|
@ -12,16 +12,16 @@ extends StaticBody3D
|
|||
const TARGET = 100
|
||||
var current = 0
|
||||
|
||||
var pc_occupied = [0, 0, 0]
|
||||
var pc_occupied = 0
|
||||
|
||||
var pc_body = [0, 0, 0]
|
||||
var pc_body = []
|
||||
|
||||
func _ready():
|
||||
Game.computers += 1
|
||||
|
||||
func _on_computer_tick_timeout():
|
||||
if Game.is_server:
|
||||
current += (pc_occupied[0] + pc_occupied[1] + pc_occupied[2])
|
||||
current += pc_occupied
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_computers",name, current)
|
||||
if current >= TARGET:
|
||||
|
@ -34,36 +34,11 @@ func _on_computer_tick_timeout():
|
|||
|
||||
|
||||
func _on_pc_1_area_body_entered(body):
|
||||
if pc_occupied[0] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[0] = 1
|
||||
pc_body[0] = body
|
||||
|
||||
|
||||
func _on_pc_2_area_body_entered(body):
|
||||
if pc_occupied[1] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[1] = 1
|
||||
pc_body[1] = body
|
||||
|
||||
|
||||
func _on_pc_3_area_body_entered(body):
|
||||
if pc_occupied[2] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[2] = 1
|
||||
pc_body[2] = body
|
||||
|
||||
if pc_occupied < 3 and body is CharacterBody3D and !body.beast and body not in pc_body:
|
||||
pc_occupied += 1
|
||||
pc_body.append(body)
|
||||
|
||||
func _on_pc_1_area_body_exited(body):
|
||||
if pc_occupied[0] == 1 and body is CharacterBody3D and body == pc_body[0]:
|
||||
pc_occupied[0] = 0
|
||||
pc_body[0] = 0
|
||||
|
||||
|
||||
func _on_pc_2_area_body_exited(body):
|
||||
if pc_occupied[1] == 1 and body is CharacterBody3D and body == pc_body[1]:
|
||||
pc_occupied[1] = 0
|
||||
pc_body[1] = 0
|
||||
|
||||
|
||||
func _on_pc_3_area_body_exited(body):
|
||||
if pc_occupied[2] == 1 and body is CharacterBody3D and body == pc_body[2]:
|
||||
pc_occupied[2] = 0
|
||||
pc_body[2] = 0
|
||||
if pc_occupied < 3 and body is CharacterBody3D and body in pc_body:
|
||||
pc_occupied -= 1
|
||||
pc_body.erase(body)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
extends Node
|
||||
|
||||
var settings = {"save_version" = 3, "fps_counter" = 1, "port" = 35000, "ip" = "127.0.0.1"}
|
||||
var settings = {"save_version" = 4, "fps_counter" = 1, "port" = 35000, "ip" = "127.0.0.1", "username" = "DefaultName"}
|
||||
var computers = 0
|
||||
var players = 0
|
||||
var map_name = "mansion"
|
||||
|
@ -79,6 +79,7 @@ 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
|
||||
|
@ -111,9 +112,10 @@ func player_hit(target, beast):
|
|||
beast.got_one(target)
|
||||
|
||||
func sync_player(node_name, position, rotation):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/"+node_name)
|
||||
current_character.position = position
|
||||
current_character.rotation = rotation
|
||||
if get_tree().root.has_node("./"+map_name+"/"+node_name):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/"+node_name)
|
||||
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")
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
extends Control
|
||||
|
||||
func matchmaking():
|
||||
get_tree().root.get_node("./main_menu").hide()
|
||||
Matchmaking.create_game()
|
||||
|
||||
func _ready():
|
||||
Game.reset()
|
||||
|
@ -18,7 +18,7 @@ func _ready():
|
|||
$main_content/matchmaking.hide()
|
||||
$main_content/matchmaking.disabled = true
|
||||
if DisplayServer.get_name() == "headless":
|
||||
_on_matchmaking_pressed()
|
||||
matchmaking()
|
||||
|
||||
func _on_join_pressed():
|
||||
get_tree().change_scene_to_file("res://menus/create.tscn")
|
||||
|
@ -27,9 +27,3 @@ func _on_join_pressed():
|
|||
|
||||
func _on_settings_pressed():
|
||||
get_tree().change_scene_to_file("res://menus/settings.tscn")
|
||||
|
||||
|
||||
func _on_matchmaking_pressed():
|
||||
Matchmaking.create_game()
|
||||
matchmaking()
|
||||
|
||||
|
|
|
@ -69,11 +69,11 @@ func _physics_process(delta):
|
|||
position.y += 1
|
||||
|
||||
if Input.is_action_pressed("click") and $hammer.rotation_degrees.x > 0:
|
||||
$hammer.rotation_degrees.x -= 5
|
||||
$hammer.rotation_degrees.x -= 10
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_hammer",name, $hammer.rotation)
|
||||
elif $hammer.rotation_degrees.x < 90 and !Input.is_action_pressed("click"):
|
||||
$hammer.rotation_degrees.x += 5
|
||||
$hammer.rotation_degrees.x += 10
|
||||
for id in Game.player_list:
|
||||
Client.rpc_id(id,"sync_hammer",name, $hammer.rotation)
|
||||
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
extends TextEdit
|
||||
## freeftf
|
||||
## Copyright (C) 2024 Patrick_Pluto
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
extends LineEdit
|
||||
|
||||
func _ready():
|
||||
text = Game.settings[get_parent().name]
|
||||
text = str(Game.settings[get_parent().name])
|
||||
|
||||
func _on_text_changed():
|
||||
|
||||
|
||||
func _on_text_changed(new_text):
|
||||
Game.save_setting(get_parent().name, text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue