1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2025-02-04 12:28:35 +00:00

92 lines
2.4 KiB
GDScript3
Raw Normal View History

2021-11-18 09:00:15 -06:00
extends Control
2021-11-08 07:40:11 -06:00
2021-11-14 02:50:39 -06:00
var light_theme = load("res://light_theme.tres")
var dark_theme = load("res://dark_theme.tres")
# Path to Player class, for instantiating new Players in code
var Player = preload("res://scenes/Game/Player.tscn")
var Victory = preload("res://scenes/Game/Victory.tscn")
# Array of instances of the Player class; stores the Players
var players = [] # = player1, player2, ...
2021-11-18 09:00:15 -06:00
var players_ready = []
# turn counter
var turn = 0
2021-11-18 09:00:15 -06:00
# winner
var winner = 0
2021-11-08 07:40:11 -06:00
2021-11-18 09:00:15 -06:00
# Every game is a multiplayer game, even the ones that aren't.
# We're taking the Minecraft approach, baby
var network_id
2021-11-14 02:50:39 -06:00
2021-11-08 07:40:11 -06:00
# Called when the node enters the scene tree for the first time.
func _ready():
2021-11-14 23:50:23 -06:00
2021-11-13 23:32:19 -06:00
get_node("ConfirmationDialog").get_ok().text = "Yes"
get_node("ConfirmationDialog").get_cancel().text = "No"
2021-11-14 02:50:39 -06:00
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
get_node("ConfirmationDialog").get_cancel().rect_min_size.x = 100
2021-11-18 09:00:15 -06:00
if multiplayer:
# TODO: Spawn a lobby where people can either connect to a peer or create a server
pass
game_setup()
2021-11-18 09:00:15 -06:00
# Function used to keep track of which players are ready
2021-11-23 22:44:53 -06:00
# TODO: Change this to keep track of ready states only
func player_ready():
2021-11-23 22:44:53 -06:00
pass
2021-11-08 07:40:11 -06:00
# Member functions:
# game_start: starts the game
sync func game_setup():
2021-11-18 09:00:15 -06:00
# If there's no server connected, create one
if not Net.connected:
2021-11-18 09:00:15 -06:00
# TODO: Create a fake peer who we can automate, for single-player mode
Net.start_host()
network_id = Net.get_network_id()
2021-11-08 07:40:11 -06:00
pass
2021-11-18 09:00:15 -06:00
2021-11-23 22:44:53 -06:00
# game_start:
func game_start():
2021-11-18 09:00:15 -06:00
# Make sure we're the server
pass
2021-11-18 09:00:15 -06:00
2021-11-23 22:44:53 -06:00
# _on_player_ready: Player Ready signal handler
func _on_player_ready():
2021-11-18 09:00:15 -06:00
print ("_on_player_ready")
2021-11-23 22:44:53 -06:00
Net.send(1, ["player_ready", Net.Mail.REPLY])
# victory_screen: display the victory screen
func victory_screen():
2021-11-13 22:46:24 -06:00
# TODO: Create the victory screen, fill it with knowledge
2021-11-08 07:40:11 -06:00
pass
2021-11-23 22:44:53 -06:00
# display_turn: display which turn it is on the screen
func display_turn():
2021-11-13 22:46:24 -06:00
# TODO: Update the turn display, if there is one?
2021-11-08 07:40:11 -06:00
pass
2021-11-23 22:44:53 -06:00
# _on_Forfeit_pressed: Handle forfeit button press
func _on_Forfeit_pressed():
AudioBus.emit_signal("button_clicked")
2021-11-14 00:08:16 -06:00
get_node("ConfirmationDialog").popup()
2021-11-23 22:44:53 -06:00
# end: end the Game
func end():
queue_free()
2021-11-23 22:44:53 -06:00
# _on_Button_button_down: Handle win button press
# TODO: This isn't a thing any more
func _on_Button_button_down():
AudioBus.emit_signal("button_clicked")
var victory = Victory.instance()
add_child(victory)
victory.connect("exit_main", self, "end")
2021-11-14 00:08:16 -06:00
func _on_ConfirmationDialog_confirmed():
end()
2021-11-14 02:50:39 -06:00