1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00

Merge branch 'game-logic' of https://github.com/StatewideInk/Group12 into game-logic

This commit is contained in:
tommy-l-ngo 2021-11-14 00:43:23 -06:00
commit be4429a717
10 changed files with 113 additions and 1271 deletions

File diff suppressed because it is too large Load Diff

View File

@ -26,12 +26,15 @@ bus = "SFX"
[node name="shipHitSFX" type="AudioStreamPlayer" parent="."] [node name="shipHitSFX" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 4 ) stream = ExtResource( 4 )
volume_db = -10.0
bus = "SFX" bus = "SFX"
[node name="shipMissedSFX" type="AudioStreamPlayer" parent="."] [node name="shipMissedSFX" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 5 ) stream = ExtResource( 5 )
volume_db = -5.0
bus = "SFX" bus = "SFX"
[node name="shipSunkSFX" type="AudioStreamPlayer" parent="."] [node name="shipSunkSFX" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 6 ) stream = ExtResource( 6 )
volume_db = -10.0
bus = "SFX" bus = "SFX"

View File

@ -1,6 +1,5 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://main.tres" type="Theme" id=1]
[ext_resource path="res://script/debug/debug_menu.gd" type="Script" id=2] [ext_resource path="res://script/debug/debug_menu.gd" type="Script" id=2]
[ext_resource path="res://script/debug/In.gd" type="Script" id=3] [ext_resource path="res://script/debug/In.gd" type="Script" id=3]
[ext_resource path="res://script/debug/Out.gd" type="Script" id=4] [ext_resource path="res://script/debug/Out.gd" type="Script" id=4]
@ -9,7 +8,7 @@
[node name="Debug" type="Control"] [node name="Debug" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 1 ) theme = ExtResource( 5 )
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -51,6 +50,7 @@ focus_neighbour_right = NodePath(".")
focus_neighbour_bottom = NodePath(".") focus_neighbour_bottom = NodePath(".")
focus_next = NodePath(".") focus_next = NodePath(".")
focus_previous = NodePath(".") focus_previous = NodePath(".")
theme = ExtResource( 5 )
max_length = 256 max_length = 256
placeholder_text = "By your command." placeholder_text = "By your command."
caret_blink = true caret_blink = true

View File

@ -0,0 +1,51 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://script/game/Victory.gd" type="Script" id=1]
[ext_resource path="res://assets/font/Minecraft.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=1]
size = 40
font_data = ExtResource( 2 )
[node name="Victory" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
margin_left = 118.32
margin_top = 44.5109
margin_right = 260.32
margin_bottom = 84.5109
size_flags_vertical = 0
custom_fonts/font = SubResource( 1 )
text = "Victory"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Button" type="Button" parent="."]
margin_left = 541.0
margin_top = 327.85
margin_right = 636.0
margin_bottom = 353.85
text = "Exit to Main"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Button2" type="Button" parent="."]
visible = false
margin_left = 2.22023
margin_top = 337.41
margin_right = 63.2202
margin_bottom = 357.41
text = "Restart"
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
[connection signal="button_down" from="Button2" to="." method="_on_restart_button_down"]

View File

@ -58,10 +58,9 @@ focus_neighbour_top = NodePath("../../../Back")
focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider") focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider")
focus_next = NodePath("../../Volume Setting/Volume Slider") focus_next = NodePath("../../Volume Setting/Volume Slider")
focus_previous = NodePath("../../../Back") focus_previous = NodePath("../../../Back")
min_value = -25.0 max_value = 1.0
max_value = 0.0 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -90,10 +89,9 @@ focus_neighbour_top = NodePath("../../SFX Setting/SFX Slider")
focus_neighbour_bottom = NodePath("../../../Buttons/Dark") focus_neighbour_bottom = NodePath("../../../Buttons/Dark")
focus_next = NodePath("../../../Buttons/Dark") focus_next = NodePath("../../../Buttons/Dark")
focus_previous = NodePath("../../SFX Setting/SFX Slider") focus_previous = NodePath("../../SFX Setting/SFX Slider")
min_value = -50.0 max_value = 1.0
max_value = 0.0 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -117,10 +115,9 @@ margin_left = 64.0
margin_top = 48.0 margin_top = 48.0
margin_right = 208.0 margin_right = 208.0
margin_bottom = 64.0 margin_bottom = 64.0
min_value = -50.0 max_value = 1.0
max_value = 0.0 step = 0.05
tick_count = 10 tick_count = 10
ticks_on_borders = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }

View File

@ -14,6 +14,8 @@ onready var Fire = preload("res://scenes/Game/Fire.tscn")
# Path to Player class, for instantiating new Players in code # Path to Player class, for instantiating new Players in code
onready var Player = preload("res://scenes/Game/Player.tscn") onready var Player = preload("res://scenes/Game/Player.tscn")
onready var Victory = preload("res://scenes/Game/Victory.tscn")
# Array of instances of the Player class; stores the Players # Array of instances of the Player class; stores the Players
var players # = player1, player2, ... var players # = player1, player2, ...
@ -63,5 +65,11 @@ func _on_Forfeit_pressed():
func end(): func end():
queue_free() queue_free()
func _on_Button_button_down():
AudioBus.emit_signal("button_clicked")
var victory = Victory.instance()
add_child(victory)
victory.connect("exit_main", self, "end")
func _on_ConfirmationDialog_confirmed(): func _on_ConfirmationDialog_confirmed():
end() end()

View File

@ -4,6 +4,8 @@ signal game_ready
onready var Ships = ["2Ship", "3ShipA", "3ShipB", "4Ship", "5Ship"] onready var Ships = ["2Ship", "3ShipA", "3ShipB", "4Ship", "5Ship"]
onready var Victory = preload("res://scenes/Game/Player.tscn")
class ShipData: class ShipData:
var Position: Vector2 var Position: Vector2
var Length: int var Length: int

View File

@ -0,0 +1,30 @@
extends Control
signal exit_main
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
# returns player(s) back to main menu
func _on_Button_pressed():
AudioBus.emit_signal("button_clicked")
#MessageBus.emit_signal("change_scene", "Title")
emit_signal("exit_main")
func _on_restart_button_down():
AudioBus.emit_signal("button_clicked")
#MessageBus.emit_signal("change_scene", "Multiplayer")
pass # Replace with function body.

View File

@ -10,9 +10,9 @@ onready var theme_buttons = find_node("Buttons", true, true).get_children()
func _ready(): func _ready():
OptionsController.load_options() OptionsController.load_options()
find_next_valid_focus().grab_focus() find_next_valid_focus().grab_focus()
master_slider.value = OptionsController.get_mas_volume() master_slider.value = db2linear(OptionsController.get_mas_volume())
music_slider.value = OptionsController.get_mus_volume() music_slider.value = db2linear(OptionsController.get_mus_volume())
sound_slider.value = OptionsController.get_sfx_volume() sound_slider.value = db2linear(OptionsController.get_sfx_volume())
func _on_Button_pressed(): func _on_Button_pressed():
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
@ -20,14 +20,17 @@ func _on_Button_pressed():
#MessageBus.emit_signal("change_scene", "Title") #MessageBus.emit_signal("change_scene", "Title")
func _on_Master_Slider_value_changed(value): func _on_Master_Slider_value_changed(value):
value = linear2db(value)
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
OptionsController.set_vol(value, "mas_vol") OptionsController.set_vol(value, "mas_vol")
func _on_Music_Slider_value_changed(value): func _on_Music_Slider_value_changed(value):
value = linear2db(value)
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
OptionsController.set_vol(value, "mus_vol") OptionsController.set_vol(value, "mus_vol")
func _on_SFX_Slider_value_changed(value): func _on_SFX_Slider_value_changed(value):
value = linear2db(value)
AudioBus.emit_signal("button_clicked") AudioBus.emit_signal("button_clicked")
OptionsController.set_vol(value, "sfx_vol") OptionsController.set_vol(value, "sfx_vol")

View File

@ -8,9 +8,9 @@ signal change_theme (theme)
var f = File.new() var f = File.new()
var options_file = "user://options.save" var options_file = "user://options.save"
var theme = "dark" var theme = "dark"
var mas_vol = 0 var mas_vol = linear2db(1)
var mus_vol = 0 var mus_vol = linear2db(1)
var sfx_vol = 0 var sfx_vol = linear2db(1)
func _ready(): func _ready():
load_options() load_options()
@ -62,7 +62,7 @@ func load_options():
mus_vol = f.get_var() mus_vol = f.get_var()
sfx_vol = f.get_var() sfx_vol = f.get_var()
f.close() f.close()
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mus_vol) AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mas_vol)
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol) AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol) AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)