2021-11-08 13:40:11 +00:00
|
|
|
extends Node
|
|
|
|
|
2021-11-13 10:34:39 +00:00
|
|
|
class ShipData:
|
|
|
|
var Coor: Vector2
|
|
|
|
var Length: int
|
|
|
|
var Orientation: bool #vertical is true, (Trueship = vertical) (Falseship = horizontal)
|
|
|
|
|
2021-11-14 08:50:39 +00:00
|
|
|
var light_theme = load("res://light_theme.tres")
|
|
|
|
var dark_theme = load("res://dark_theme.tres")
|
|
|
|
|
2021-11-13 10:34:39 +00:00
|
|
|
# Preloaded assets, to be used later
|
2021-11-13 11:08:53 +00:00
|
|
|
# TODO: Move Setup into the Player. It's just here, for now, so that it can be tested and the game doesn't appear broken
|
2021-11-13 10:34:39 +00:00
|
|
|
onready var Setup = preload("res://scenes/Game/Setup.tscn")
|
2021-11-13 11:08:53 +00:00
|
|
|
# TODO: Move Fire into the Player. See above.
|
2021-11-13 10:34:39 +00:00
|
|
|
onready var Fire = preload("res://scenes/Game/Fire.tscn")
|
|
|
|
|
2021-11-11 20:38:10 +00:00
|
|
|
# Path to Player class, for instantiating new Players in code
|
2021-11-14 04:46:24 +00:00
|
|
|
onready var Player = preload("res://scenes/Game/Player.tscn")
|
2021-11-11 20:38:10 +00:00
|
|
|
|
2021-11-14 06:34:51 +00:00
|
|
|
onready var Victory = preload("res://scenes/Game/Victory.tscn")
|
|
|
|
|
2021-11-13 10:34:39 +00:00
|
|
|
|
2021-11-11 21:38:50 +00:00
|
|
|
# Array of instances of the Player class; stores the Players
|
2021-11-08 13:40:11 +00:00
|
|
|
var players # = player1, player2, ...
|
2021-11-11 21:38:50 +00:00
|
|
|
# turn counter
|
|
|
|
var turn = 0
|
|
|
|
# Variable transporting hit state between players
|
|
|
|
var hit = false
|
|
|
|
# Variable tracking whether a game is multiplayer (so that the correct Player type can be spawned)
|
|
|
|
# TODO: Multiplayer
|
|
|
|
var is_multiplayer = false
|
2021-11-08 13:40:11 +00:00
|
|
|
|
2021-11-14 08:50:39 +00:00
|
|
|
|
2021-11-08 13:40:11 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2021-11-13 11:08:53 +00:00
|
|
|
# TODO: Move Setup into the Player.
|
2021-11-13 10:34:39 +00:00
|
|
|
var setup = Setup.instance()
|
|
|
|
setup.connect("game_ready", self, "game_setup")
|
|
|
|
add_child(setup)
|
2021-11-14 05:32:19 +00:00
|
|
|
|
|
|
|
get_node("ConfirmationDialog").get_ok().text = "Yes"
|
|
|
|
get_node("ConfirmationDialog").get_cancel().text = "No"
|
2021-11-14 08:50:39 +00:00
|
|
|
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
|
|
|
|
get_node("ConfirmationDialog").get_cancel().rect_min_size.x = 100
|
|
|
|
|
|
|
|
var _errno = 0;
|
|
|
|
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
|
|
|
|
_on_change_theme(OptionsController.get_theme())
|
2021-11-13 10:34:39 +00:00
|
|
|
|
2021-11-13 11:08:53 +00:00
|
|
|
# TODO: Move Setup into the Player.
|
2021-11-13 10:34:39 +00:00
|
|
|
func game_setup(_ships):
|
|
|
|
print_debug("Congrats! Setup complete.")
|
2021-11-13 11:08:53 +00:00
|
|
|
# TODO: Move Fire into the Player.
|
2021-11-13 10:34:39 +00:00
|
|
|
add_child(Fire.instance())
|
2021-11-08 13:40:11 +00:00
|
|
|
|
2021-11-11 21:38:50 +00:00
|
|
|
# Member functions:
|
|
|
|
# game_start: starts the game
|
|
|
|
func game_start():
|
2021-11-08 13:40:11 +00:00
|
|
|
pass
|
2021-11-11 21:38:50 +00:00
|
|
|
|
|
|
|
# victory_screen: display the victory screen
|
|
|
|
func victory_screen():
|
2021-11-14 04:46:24 +00:00
|
|
|
# TODO: Create the victory screen, fill it with knowledge
|
2021-11-08 13:40:11 +00:00
|
|
|
pass
|
2021-11-11 21:38:50 +00:00
|
|
|
|
|
|
|
# display_turn(): display which turn it is on the screen
|
|
|
|
func display_turn():
|
2021-11-14 04:46:24 +00:00
|
|
|
# TODO: Update the turn display, if there is one?
|
2021-11-08 13:40:11 +00:00
|
|
|
pass
|
2021-11-13 10:34:39 +00:00
|
|
|
|
|
|
|
func _on_Forfeit_pressed():
|
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-11-14 06:08:16 +00:00
|
|
|
get_node("ConfirmationDialog").popup()
|
2021-11-13 10:34:39 +00:00
|
|
|
|
|
|
|
func end():
|
|
|
|
queue_free()
|
2021-11-14 06:34:51 +00:00
|
|
|
|
|
|
|
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 06:39:02 +00:00
|
|
|
|
2021-11-14 06:08:16 +00:00
|
|
|
func _on_ConfirmationDialog_confirmed():
|
|
|
|
end()
|
2021-11-14 08:50:39 +00:00
|
|
|
|
|
|
|
func _on_change_theme(theme):
|
|
|
|
if theme == "light":
|
|
|
|
get_node("Buttons").set_theme(light_theme)
|
|
|
|
elif theme == "dark":
|
|
|
|
get_node("Buttons").set_theme(dark_theme)
|