generated from krampus/template-godot4
adds scenes folder (which is breaking linting)
All checks were successful
linting & formatting / build (push) Successful in 16s
All checks were successful
linting & formatting / build (push) Successful in 16s
This commit is contained in:
parent
57b3214494
commit
ddd2fed714
67
scenes/board_game.gd
Normal file
67
scenes/board_game.gd
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
class_name BoardGame extends Control
|
||||||
|
|
||||||
|
const DOWN_SPAWN_SCENE = preload("uid://d4ltd1geg7s2p")
|
||||||
|
|
||||||
|
var turn: int = 0:
|
||||||
|
set(value):
|
||||||
|
turn = value
|
||||||
|
controls.set_turn(turn)
|
||||||
|
var player: Player
|
||||||
|
var citizen_count: int = 0:
|
||||||
|
set(value):
|
||||||
|
print(value)
|
||||||
|
citizen_count = value
|
||||||
|
if citizen_count == 0:
|
||||||
|
handle_turn_over()
|
||||||
|
|
||||||
|
var spawn_placement_actions = 0
|
||||||
|
|
||||||
|
@onready var board: Board = %Board
|
||||||
|
@onready var controls: Controls = %Controls
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
Globals.board_game = self
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
player = Player.new()
|
||||||
|
controls.set_players([player])
|
||||||
|
start_turn()
|
||||||
|
|
||||||
|
|
||||||
|
func start_turn() -> void:
|
||||||
|
turn += 1
|
||||||
|
if spawn_placement_actions > 0:
|
||||||
|
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||||
|
|
||||||
|
|
||||||
|
func select_tile(tile: Tile):
|
||||||
|
board.set_active_tile(tile)
|
||||||
|
|
||||||
|
|
||||||
|
func select_building(building: Building) -> void:
|
||||||
|
if building is Home:
|
||||||
|
board.set_active_building(building, player)
|
||||||
|
else:
|
||||||
|
board.set_active_building(building)
|
||||||
|
|
||||||
|
|
||||||
|
func place_walls() -> void:
|
||||||
|
board.is_placing_walls = !board.is_placing_walls
|
||||||
|
|
||||||
|
|
||||||
|
func handle_turn_over() -> void:
|
||||||
|
get_tree().call_group("PostTurnActions", "handle_post_turn_actions")
|
||||||
|
controls.reset_turn()
|
||||||
|
start_turn()
|
||||||
|
|
||||||
|
|
||||||
|
func queue_spawn_placement(num: int) -> void:
|
||||||
|
spawn_placement_actions += num
|
||||||
|
|
||||||
|
|
||||||
|
func handle_spawn_placed() -> void:
|
||||||
|
spawn_placement_actions = maxi(spawn_placement_actions - 1, 0)
|
||||||
|
if spawn_placement_actions > 0:
|
||||||
|
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||||
1
scenes/board_game.gd.uid
Normal file
1
scenes/board_game.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://p10j5v8tlyb
|
||||||
69
scenes/board_game.tscn
Normal file
69
scenes/board_game.tscn
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dmqvnr7uev0i6"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://caq4f3l237i42" path="res://prefabs/ui/controls.tscn" id="1_8orke"]
|
||||||
|
[ext_resource type="Script" uid="uid://c5vwubjdr23jr" path="res://prefabs/game_camera.gd" id="2_v8odh"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ct6tclctgdrkm" path="res://prefabs/board.tscn" id="3_02cv7"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fc0e3"]
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_top = 10.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_bottom = 10.0
|
||||||
|
bg_color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7jktm"]
|
||||||
|
bg_color = Color(0, 0, 0, 1)
|
||||||
|
corner_radius_top_left = 16
|
||||||
|
corner_radius_top_right = 16
|
||||||
|
corner_radius_bottom_right = 16
|
||||||
|
corner_radius_bottom_left = 16
|
||||||
|
|
||||||
|
[node name="GameContainer" type="PanelContainer" unique_id=1427225690]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_fc0e3")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=348137536]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Controls" parent="VBoxContainer" unique_id=1719205711 instance=ExtResource("1_8orke")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(0, 50)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 4
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer" unique_id=511396372]
|
||||||
|
process_mode = 3
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_7jktm")
|
||||||
|
|
||||||
|
[node name="SubViewportContainer" type="SubViewportContainer" parent="VBoxContainer/PanelContainer" unique_id=758297429]
|
||||||
|
process_mode = 3
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
stretch = true
|
||||||
|
mouse_target = true
|
||||||
|
|
||||||
|
[node name="SubViewport" type="SubViewport" parent="VBoxContainer/PanelContainer/SubViewportContainer" unique_id=584942697]
|
||||||
|
process_mode = 3
|
||||||
|
disable_3d = true
|
||||||
|
transparent_bg = true
|
||||||
|
handle_input_locally = false
|
||||||
|
physics_object_picking = true
|
||||||
|
size = Vector2i(2, 2)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=416785798]
|
||||||
|
anchor_mode = 0
|
||||||
|
zoom = Vector2(0.94, 0.94)
|
||||||
|
position_smoothing_enabled = true
|
||||||
|
drag_horizontal_enabled = true
|
||||||
|
drag_vertical_enabled = true
|
||||||
|
script = ExtResource("2_v8odh")
|
||||||
|
|
||||||
|
[node name="Board" parent="VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=752933545 instance=ExtResource("3_02cv7")]
|
||||||
|
unique_name_in_owner = true
|
||||||
15
scenes/game.gd
Normal file
15
scenes/game.gd
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class_name Game extends Node
|
||||||
|
|
||||||
|
var this_player: Player
|
||||||
|
var players: Array[Player] = []
|
||||||
|
|
||||||
|
@onready var tube_client: TubeClient = %TubeClient
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
Globals.game = self
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("any_peer", "call_local", "reliable")
|
||||||
|
func add_player(player: Player) -> void:
|
||||||
|
players.push_back(player)
|
||||||
1
scenes/game.gd.uid
Normal file
1
scenes/game.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://bg3v68a7qpt8t
|
||||||
17
scenes/game.tscn
Normal file
17
scenes/game.tscn
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[gd_scene format=3 uid="uid://fbdci3d048m7"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bg3v68a7qpt8t" path="res://scenes/game.gd" id="1_fc0e3"]
|
||||||
|
[ext_resource type="Script" uid="uid://cy006uvidc4y" path="res://addons/tube/tube_client.gd" id="2_lnu2h"]
|
||||||
|
[ext_resource type="Resource" uid="uid://c4wgewmmuj74g" path="res://resources/local_tube_context.tres" id="3_lbhrr"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dpuwsqorot65h" path="res://scenes/main_menu.tscn" id="4_lbhrr"]
|
||||||
|
|
||||||
|
[node name="Game" type="Node" unique_id=384379479]
|
||||||
|
script = ExtResource("1_fc0e3")
|
||||||
|
|
||||||
|
[node name="TubeClient" type="Node" parent="." unique_id=646833557]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("2_lnu2h")
|
||||||
|
context = ExtResource("3_lbhrr")
|
||||||
|
metadata/_custom_type_script = "uid://cy006uvidc4y"
|
||||||
|
|
||||||
|
[node name="MainMenu" parent="." unique_id=459413586 instance=ExtResource("4_lbhrr")]
|
||||||
49
scenes/main_menu.gd
Normal file
49
scenes/main_menu.gd
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@onready var main_menu: Container = %MainMenu
|
||||||
|
@onready var create_session: Container = %CreateSession
|
||||||
|
@onready var join_session: Container = %JoinSession
|
||||||
|
@onready var lobby: Lobby = %Lobby
|
||||||
|
|
||||||
|
|
||||||
|
func handle_create_session(player: Player) -> void:
|
||||||
|
Globals.game.tube_client.create_session()
|
||||||
|
Globals.game.this_player = player
|
||||||
|
Globals.game.add_player.rpc(player)
|
||||||
|
create_session.hide()
|
||||||
|
lobby.show()
|
||||||
|
lobby.set_session_id(Globals.game.tube_client.session_id)
|
||||||
|
lobby.add_player(player)
|
||||||
|
|
||||||
|
|
||||||
|
func handle_join_session(session_id: String, player: Player) -> void:
|
||||||
|
Globals.game.tube_client.join_session(session_id)
|
||||||
|
await Globals.game.tube_client.peer_connected
|
||||||
|
Globals.game.this_player = player
|
||||||
|
Globals.game.add_player.rpc(player)
|
||||||
|
join_session.hide()
|
||||||
|
lobby.show()
|
||||||
|
lobby.set_session_id(session_id)
|
||||||
|
lobby.add_player(player)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#func handle_chat_update(new_text):
|
||||||
|
#update_chat.rpc(new_text)
|
||||||
|
#chat_text_input.text = ""
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#@rpc("any_peer", "call_local", "reliable")
|
||||||
|
#func update_chat(text):
|
||||||
|
#chat_log.text += text + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
func _on_create_session_pressed():
|
||||||
|
main_menu.hide()
|
||||||
|
create_session.show()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_join_session_pressed():
|
||||||
|
main_menu.hide()
|
||||||
|
join_session.show()
|
||||||
1
scenes/main_menu.gd.uid
Normal file
1
scenes/main_menu.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://ccycmp8aj70fe
|
||||||
55
scenes/main_menu.tscn
Normal file
55
scenes/main_menu.tscn
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dpuwsqorot65h"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ccycmp8aj70fe" path="res://scenes/main_menu.gd" id="1_ouk2q"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b7rfnt0d4qoew" path="res://prefabs/lobby/create_session.tscn" id="4_m5hu6"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cfci3j2ur3g31" path="res://prefabs/lobby/lobby.tscn" id="4_wu84c"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://j3v0ad1b28il" path="res://prefabs/lobby/join_session.tscn" id="5_v1fnr"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_2wvic"]
|
||||||
|
font_size = 48
|
||||||
|
|
||||||
|
[node name="MainMenu" type="Node" unique_id=459413586]
|
||||||
|
script = ExtResource("1_ouk2q")
|
||||||
|
|
||||||
|
[node name="MainMenu" type="VBoxContainer" parent="." unique_id=1667537625]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 20
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="MainMenu" unique_id=1959052214]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Clockwork City"
|
||||||
|
label_settings = SubResource("LabelSettings_2wvic")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="CreateSession" type="Button" parent="MainMenu" unique_id=1320477862]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
text = "Create Session"
|
||||||
|
|
||||||
|
[node name="JoinSession" type="Button" parent="MainMenu" unique_id=897089302]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
text = "Join Session"
|
||||||
|
|
||||||
|
[node name="CreateSession" parent="." unique_id=1876286176 instance=ExtResource("4_m5hu6")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="JoinSession" parent="." unique_id=1106179304 instance=ExtResource("5_v1fnr")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Lobby" parent="." unique_id=581427024 instance=ExtResource("4_wu84c")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[connection signal="pressed" from="MainMenu/CreateSession" to="." method="_on_create_session_pressed"]
|
||||||
|
[connection signal="pressed" from="MainMenu/JoinSession" to="." method="_on_join_session_pressed"]
|
||||||
|
[connection signal="create_session" from="CreateSession" to="." method="handle_create_session"]
|
||||||
|
[connection signal="join_session" from="JoinSession" to="." method="handle_join_session"]
|
||||||
Loading…
x
Reference in New Issue
Block a user