2021-11-14 06:34:51 +00:00
|
|
|
extends Control
|
|
|
|
|
2021-11-24 18:17:07 +00:00
|
|
|
# Path to Board class, for instantiating new Boards in code
|
|
|
|
var Board = preload("res://scenes/Game/Board.tscn")
|
2021-11-14 06:34:51 +00:00
|
|
|
|
2021-12-06 19:16:49 +00:00
|
|
|
# Sidnals
|
|
|
|
# request to return to lobby
|
|
|
|
signal end_game
|
2021-11-14 06:34:51 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
2021-11-24 18:17:07 +00:00
|
|
|
# Reveal a list of ships
|
|
|
|
func reveal_ships(ships:Array):
|
|
|
|
var board = Board.instance()
|
|
|
|
add_child(board);
|
|
|
|
for ship in ships:
|
|
|
|
board.callv("place_ship", ship)
|
2021-11-14 06:34:51 +00:00
|
|
|
|
2021-12-06 19:16:49 +00:00
|
|
|
func set_win(won:bool):
|
|
|
|
var Text = find_node("Text")
|
|
|
|
if won:
|
|
|
|
Text.text = "You win!"
|
|
|
|
else:
|
|
|
|
Text.text = "You lose"
|
|
|
|
|
2021-11-14 06:34:51 +00:00
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
#func _process(delta):
|
|
|
|
# pass
|
|
|
|
|
2021-12-06 19:16:49 +00:00
|
|
|
func _on_Restart_pressed():
|
2021-11-14 06:43:32 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-12-06 19:16:49 +00:00
|
|
|
emit_signal("end_game")
|
2021-11-24 18:17:07 +00:00
|
|
|
|
2021-11-14 06:34:51 +00:00
|
|
|
|
|
|
|
# returns player(s) back to main menu
|
2021-12-06 19:16:49 +00:00
|
|
|
func _on_Exit_to_Title_pressed():
|
2021-11-14 06:34:51 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-12-06 19:16:49 +00:00
|
|
|
# Disconnect from peer
|
|
|
|
Net.disconnect_host()
|
|
|
|
# Force return to title
|
2021-11-24 18:17:07 +00:00
|
|
|
MessageBus.emit_signal("return_to_title")
|