Compare commits
No commits in common. "5dc194bd761349d200365407742cdeb0e5932c70" and "a27e6517ccdf31ffaff46eec31aa395c061cfdd8" have entirely different histories.
5dc194bd76
...
a27e6517cc
|
@ -27,7 +27,7 @@ func init() -> void:
|
||||||
func _process(delta : float) -> void:
|
func _process(delta : float) -> void:
|
||||||
var all_ready = true
|
var all_ready = true
|
||||||
for player in players.values():
|
for player in players.values():
|
||||||
if !player.is_ready and !player.has_died and !player.is_zombie:
|
if !player.is_ready and !player.has_died:
|
||||||
all_ready = false
|
all_ready = false
|
||||||
if all_ready:
|
if all_ready:
|
||||||
for player in players.values():
|
for player in players.values():
|
||||||
|
@ -36,12 +36,12 @@ func _process(delta : float) -> void:
|
||||||
player.calculate_plans()
|
player.calculate_plans()
|
||||||
|
|
||||||
func generate_translation() -> Vector3:
|
func generate_translation() -> Vector3:
|
||||||
return Vector3(rand_range(-5,5),rand_range(-5,5),rand_range(-5,5))
|
#return Vector3(rand_range(-5,5),rand_range(-5,5),rand_range(-5,5))
|
||||||
#return Vector3(0,0,rand_range(-5,5))
|
return Vector3(0,0,rand_range(-5,5))
|
||||||
|
|
||||||
func generate_rotation() -> Vector3:
|
func generate_rotation() -> Vector3:
|
||||||
return Vector3(rand_range(-1,1),rand_range(-1,1),rand_range(-1,1)).normalized()
|
#return Vector3(rand_range(-1,1),rand_range(-1,1),rand_range(-1,1)).normalized()
|
||||||
#return Vector3(0,0,1)
|
return Vector3(0,0,1)
|
||||||
|
|
||||||
func play_full_plans():
|
func play_full_plans():
|
||||||
for player in players.values():
|
for player in players.values():
|
||||||
|
@ -68,6 +68,8 @@ remote func request_rematch(id) -> void:
|
||||||
if len(rematch_requests) == len(get_parent().ids):
|
if len(rematch_requests) == len(get_parent().ids):
|
||||||
start_rematch()
|
start_rematch()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func start_rematch() -> void:
|
func start_rematch() -> void:
|
||||||
for player_id in players.keys():
|
for player_id in players.keys():
|
||||||
players[player_id].queue_free()
|
players[player_id].queue_free()
|
||||||
|
|
|
@ -22,7 +22,6 @@ var health : float = 100.0
|
||||||
var is_alive : bool = true
|
var is_alive : bool = true
|
||||||
var time_of_death : float = -1
|
var time_of_death : float = -1
|
||||||
var has_died : bool = false
|
var has_died : bool = false
|
||||||
var is_zombie : bool = false
|
|
||||||
|
|
||||||
var turn_number : int = 0
|
var turn_number : int = 0
|
||||||
|
|
||||||
|
@ -195,6 +194,7 @@ func die(time : float) -> void:
|
||||||
has_died = true
|
has_died = true
|
||||||
$CollisionShape.disabled = true
|
$CollisionShape.disabled = true
|
||||||
time_of_death = time
|
time_of_death = time
|
||||||
|
|
||||||
|
|
||||||
func play_all_plans():
|
func play_all_plans():
|
||||||
get_parent().play_full_plans()
|
get_parent().play_full_plans()
|
||||||
|
@ -217,8 +217,6 @@ func play_last_plan():
|
||||||
$CollisionShape.disabled = false
|
$CollisionShape.disabled = false
|
||||||
|
|
||||||
func calculate_plans():
|
func calculate_plans():
|
||||||
if is_zombie:
|
|
||||||
create_zombie_plan()
|
|
||||||
if turn_number == 0:
|
if turn_number == 0:
|
||||||
play_full_plan()
|
play_full_plan()
|
||||||
else:
|
else:
|
||||||
|
@ -242,7 +240,3 @@ func _on_player_enter_firing_arc(body):
|
||||||
|
|
||||||
func _on_player_exit_firing_arc(body):
|
func _on_player_exit_firing_arc(body):
|
||||||
players_in_firing_arc.erase(body)
|
players_in_firing_arc.erase(body)
|
||||||
|
|
||||||
func create_zombie_plan() -> void:
|
|
||||||
add_thrust_element(5, Vector3.ZERO, Vector3.ZERO)
|
|
||||||
add_weapons_element(5, false)
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
const MAX_PLAYERS : int = 3
|
const MAX_PLAYERS : int = 2
|
||||||
const PORT : int = 9374
|
const PORT : int = 9374
|
||||||
|
|
||||||
const Arena = preload("res://Scenes/Arena.tscn")
|
const Arena = preload("res://Scenes/Arena.tscn")
|
||||||
|
@ -10,7 +10,6 @@ var peer : NetworkedMultiplayerENet = null
|
||||||
var ids = []
|
var ids = []
|
||||||
var console_output : TextEdit = null
|
var console_output : TextEdit = null
|
||||||
var ready_ids = []
|
var ready_ids = []
|
||||||
var playing : bool = false
|
|
||||||
var name_dict = {}
|
var name_dict = {}
|
||||||
var color_dict = {}
|
var color_dict = {}
|
||||||
|
|
||||||
|
@ -43,15 +42,6 @@ func _peer_connected(id : int) -> void:
|
||||||
func _peer_disconnected(id : int) -> void:
|
func _peer_disconnected(id : int) -> void:
|
||||||
ids.erase(id)
|
ids.erase(id)
|
||||||
self.console_print("Player has disconnected with id " + String(id))
|
self.console_print("Player has disconnected with id " + String(id))
|
||||||
if !playing:
|
|
||||||
return
|
|
||||||
var alive_online_players : int = 0
|
|
||||||
$Arena.players[id].is_zombie = true
|
|
||||||
for id in ids:
|
|
||||||
if $Arena.players[id].is_alive:
|
|
||||||
alive_online_players += 1
|
|
||||||
if alive_online_players < 2:
|
|
||||||
self.server_request_exit()
|
|
||||||
|
|
||||||
remote func client_ready(id : int) -> void:
|
remote func client_ready(id : int) -> void:
|
||||||
if id in ready_ids:
|
if id in ready_ids:
|
||||||
|
@ -67,7 +57,6 @@ func start_game() -> void:
|
||||||
console_print('Starting Game...')
|
console_print('Starting Game...')
|
||||||
send_name_dict()
|
send_name_dict()
|
||||||
send_color_dict()
|
send_color_dict()
|
||||||
playing = true
|
|
||||||
|
|
||||||
func send_name_dict() -> void:
|
func send_name_dict() -> void:
|
||||||
for element in name_dict.keys():
|
for element in name_dict.keys():
|
||||||
|
@ -95,14 +84,8 @@ func end_game() -> void:
|
||||||
peer.close_connection()
|
peer.close_connection()
|
||||||
peer.create_server( PORT, MAX_PLAYERS )
|
peer.create_server( PORT, MAX_PLAYERS )
|
||||||
peer.refuse_new_connections = false
|
peer.refuse_new_connections = false
|
||||||
playing = false
|
|
||||||
|
|
||||||
remote func request_exit() -> void:
|
remote func request_exit() -> void:
|
||||||
console_print("Exit requested...")
|
console_print("Exit requested...")
|
||||||
rpc("exit_requested")
|
rpc("exit_requested")
|
||||||
$ExitTimer.start()
|
$ExitTimer.start()
|
||||||
|
|
||||||
func server_request_exit() -> void:
|
|
||||||
console_print("Server requested exit...")
|
|
||||||
rpc("server_exit_requested")
|
|
||||||
$ExitTimer.start()
|
|
||||||
|
|
Loading…
Reference in New Issue