mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-14 21:15:58 +00:00
All: General code cleanup
This commit is contained in:
parent
8239c133fc
commit
ff45799305
@ -3,7 +3,7 @@
|
||||
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://assets/backgrounds/PanelBG_Light.tres" type="StyleBox" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=5]
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 1, 1, 1, 1 )
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
@ -11,7 +11,7 @@ corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
shadow_size = 4
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=6]
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.847059, 0.921569, 0.964706, 1 )
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
@ -19,7 +19,7 @@ corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
shadow_size = 3
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=4]
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.941176, 0.941176, 0.941176, 1 )
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
@ -27,11 +27,11 @@ corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
shadow_size = 3
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
[sub_resource type="StyleBoxEmpty" id=4]
|
||||
content_margin_left = 5.0
|
||||
content_margin_right = 5.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
[sub_resource type="StyleBoxFlat" id=5]
|
||||
bg_color = Color( 0.847059, 0.921569, 0.964706, 1 )
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
@ -46,7 +46,7 @@ corner_radius_bottom_left = 4
|
||||
expand_margin_top = 20.0
|
||||
shadow_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=3]
|
||||
[sub_resource type="DynamicFont" id=6]
|
||||
outline_size = 1
|
||||
outline_color = Color( 0.847059, 0.921569, 0.964706, 0.501961 )
|
||||
extra_spacing_top = 5
|
||||
@ -55,7 +55,7 @@ extra_spacing_char = 1
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[resource]
|
||||
default_font = SubResource( 3 )
|
||||
default_font = SubResource( 6 )
|
||||
Button/colors/font_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 )
|
||||
Button/colors/font_color_disabled = Color( 0.901961, 0.901961, 0.901961, 0.2 )
|
||||
Button/colors/font_color_hover = Color( 0.0784314, 0.0784314, 0.0784314, 1 )
|
||||
@ -64,9 +64,9 @@ Button/constants/hseparation = 2
|
||||
Button/fonts/font = null
|
||||
Button/styles/disabled = null
|
||||
Button/styles/focus = null
|
||||
Button/styles/hover = SubResource( 5 )
|
||||
Button/styles/normal = SubResource( 6 )
|
||||
Button/styles/pressed = SubResource( 4 )
|
||||
Button/styles/hover = SubResource( 1 )
|
||||
Button/styles/normal = SubResource( 2 )
|
||||
Button/styles/pressed = SubResource( 3 )
|
||||
Label/colors/font_color = Color( 1, 1, 1, 1 )
|
||||
Label/colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
Label/colors/font_outline_modulate = Color( 0, 0, 0, 1 )
|
||||
@ -87,7 +87,7 @@ LineEdit/constants/minimum_spaces = 12
|
||||
LineEdit/fonts/font = null
|
||||
LineEdit/icons/clear = null
|
||||
LineEdit/styles/focus = null
|
||||
LineEdit/styles/normal = SubResource( 1 )
|
||||
LineEdit/styles/normal = SubResource( 4 )
|
||||
LineEdit/styles/read_only = null
|
||||
Panel/styles/panel = ExtResource( 2 )
|
||||
PanelContainer/styles/panel = ExtResource( 2 )
|
||||
@ -99,4 +99,4 @@ WindowDialog/constants/title_height = 20
|
||||
WindowDialog/fonts/title_font = null
|
||||
WindowDialog/icons/close = null
|
||||
WindowDialog/icons/close_highlight = null
|
||||
WindowDialog/styles/panel = SubResource( 2 )
|
||||
WindowDialog/styles/panel = SubResource( 5 )
|
||||
|
@ -9,7 +9,6 @@ var hits
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
print("Fire: _ready()")
|
||||
for x in 10:
|
||||
for y in 10:
|
||||
texture(Vector2(x,y))
|
||||
|
@ -6,17 +6,12 @@ extends Control
|
||||
enum {MISS = -1, READY = 0, HIT = 1, SUNK = 2, LOST = 3}
|
||||
|
||||
# Signals
|
||||
signal fire # fire(position)
|
||||
signal hit # hit (state): see Miss/Ready/Hit/Sunk enum in Board.gd)
|
||||
signal miss
|
||||
signal loss
|
||||
signal forfeit
|
||||
|
||||
# Sent when game is ready
|
||||
signal game_ready
|
||||
|
||||
# Path to Player class, for instantiating new Players in code
|
||||
var Player = preload("res://scenes/Game/Player.tscn")
|
||||
|
||||
# Path to Victory class, which handles the victory screen
|
||||
var Victory = preload("res://scenes/Game/Victory.tscn")
|
||||
|
||||
|
||||
@ -44,8 +39,8 @@ func _ready():
|
||||
|
||||
# Function used to keep track of which players are ready
|
||||
func player_ready(sender):
|
||||
print("player_ready(%s), %d" % [sender, players_ready.size()])
|
||||
players_ready.append(sender)
|
||||
print_debug("%s ready (%d/%d)" % [sender, players_ready.size(), Net.peer_info.size()])
|
||||
if (players_ready.size() >= Net.peer_info.size()):
|
||||
emit_signal("game_ready")
|
||||
|
||||
@ -100,7 +95,7 @@ remote func state_win(ships):
|
||||
|
||||
# play_hit_sound: Play a hit sound depending on the severity of the hit
|
||||
# value: Lost/Sunk/Hit/Miss
|
||||
sync func play_hit_sound(value):
|
||||
remote func play_hit_sound(value):
|
||||
match value:
|
||||
LOST, SUNK:
|
||||
AudioBus.emit_signal("ship_sunk")
|
||||
@ -122,16 +117,13 @@ func mark(res):
|
||||
|
||||
# _on_Net_incoming: Handle mail.
|
||||
func _on_Net_incoming(mail):
|
||||
print ("mail: ", mail, mail.size())
|
||||
if mail.size() == 3:
|
||||
print ("mail: ", mail, mail.size())
|
||||
var sender = int(mail[0])
|
||||
var message = mail[1]
|
||||
var mailtype = int(mail[2])
|
||||
printt(sender, message, mailtype)
|
||||
match mailtype:
|
||||
Net.REPLY:
|
||||
print ("got REPLY")
|
||||
print_debug ("got REPLY")
|
||||
# message is a REPLY (return value)
|
||||
match message[0]:
|
||||
# on "fire": fire(result)
|
||||
@ -143,15 +135,15 @@ func _on_Net_incoming(mail):
|
||||
"forfeit":
|
||||
pass
|
||||
Net.READY:
|
||||
print ("got READY")
|
||||
print_debug ("got READY")
|
||||
# Add player to the ready array
|
||||
player_ready(sender)
|
||||
_:
|
||||
print ("got ", mailtype)
|
||||
# Unhandled mail type
|
||||
print_debug ("got %d?" % mailtype)
|
||||
|
||||
# _on_player_ready: Player Ready signal handler
|
||||
func _on_player_ready():
|
||||
print ("_on_player_ready")
|
||||
Net.send(0, [], Net.READY)
|
||||
player_ready(Net.get_network_id())
|
||||
|
||||
@ -164,8 +156,6 @@ func victory_screen(ships, winner = true):
|
||||
var victory = Victory.instance()
|
||||
# Give it the ships received from the opponent
|
||||
victory.reveal_ships(ships)
|
||||
# Print a nice message to stdout
|
||||
print("You won!")
|
||||
# Add victory to the scene tree
|
||||
add_child(victory)
|
||||
else:
|
||||
|
@ -17,7 +17,7 @@ func _on_peers_updated():
|
||||
pass
|
||||
|
||||
func set_IP_Address_text(show):
|
||||
# Print the IP address and port
|
||||
# Show the IP address (or nothing)
|
||||
if show:
|
||||
# ip_address.text = "IP: %sPort:%s" % [Net.get_ip(), Net.DEFAULT_PORT]
|
||||
ip_address.text = "IP: %s" % Net.get_ip()
|
||||
|
@ -38,12 +38,13 @@ var local_info = {"name": ""}
|
||||
# mail: The message received from the sender (implicitly JSON-decoded by JSONRPC)
|
||||
# mail_type: Type of mail (see "Mail Types" enum above)
|
||||
remote func receive(mail):
|
||||
print_debug("recv: %s" % mail)
|
||||
# Unpack the mail
|
||||
# Uses json parser of unknown stability, how fun
|
||||
mail = parse_json(mail)
|
||||
# Get the sender's ID and force letter to be properly addressed
|
||||
mail[0] = get_tree().get_rpc_sender_id()
|
||||
# print_debug it, for posterity
|
||||
print_debug("recv: ", mail)
|
||||
# Add the mail to the inbox (so it can be read back later if necessary
|
||||
inbox.append(mail)
|
||||
# Sent it off to anything that expects mail
|
||||
@ -54,7 +55,7 @@ remote func receive(mail):
|
||||
# mail: Variant of a json-encodable type (non-Object) to send
|
||||
# mail_type: Type of mail (see "Mail Types" enum above)
|
||||
func send(id, mail, mail_type = REPLY):
|
||||
print_debug("send: %d, %s, %d" % [id, mail, mail_type])
|
||||
print_debug("send: [%d, %s, %d]" % [id, mail, mail_type])
|
||||
# Make the recipient receive the mail
|
||||
rpc_id(id, "receive", to_json([-1, mail, mail_type]))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user