diff --git a/entities/game/card_template/scenes/CardTemplate.tscn b/entities/game/card_template/scenes/CardTemplate.tscn index 3091870..7303eb8 100644 --- a/entities/game/card_template/scenes/CardTemplate.tscn +++ b/entities/game/card_template/scenes/CardTemplate.tscn @@ -204,7 +204,7 @@ script = ExtResource("18_8fn1p") visible = false z_index = 1001 position = Vector2(0, 25) -amount = 1600 +amount = 800 texture = ExtResource("20_ja01p") lifetime = 3.0 preprocess = 1.5 @@ -231,6 +231,7 @@ volume = -15.0 [connection signal="hide_card" from="." to="CardBack" method="toggle_on"] [connection signal="input_active" from="." to="CardBack" method="input_active"] [connection signal="input_active" from="." to="FocusEffect" method="toggle_state"] +[connection signal="remove_requested" from="." to="CardBack" method="removal_planed"] [connection signal="show_card" from="." to="CardContentGroup" method="show_card_content"] [connection signal="show_card" from="." to="CardBack" method="toggle_off"] [connection signal="ready_for_destruction" from="CardContentGroup" to="." method="destory_now"] diff --git a/entities/game/card_template/scripts/CardTemplate.gd b/entities/game/card_template/scripts/CardTemplate.gd index 572d00e..0a8bfd8 100644 --- a/entities/game/card_template/scripts/CardTemplate.gd +++ b/entities/game/card_template/scripts/CardTemplate.gd @@ -20,6 +20,8 @@ signal card_text_changed(new_text: String) signal card_tooltip_changed(new_tooltip: String) signal deck_changed(deck: MemoryDeckResource) +signal remove_requested() + @export var is_ghost: bool = false @export_group("Visuals") @@ -31,6 +33,7 @@ signal deck_changed(deck: MemoryDeckResource) @export_range(0,0.25) var card_flip_animation_min_time_delay: float = 0.1 @export_range(0,0.5) var card_flip_animation_max_time_delay: float = 0.5 @export var matching_animation_scale: float = 1.5 +@export var shrink_animation_scale: float = 0.3 @export_group("Debug") @export var debug_remove: bool = false: @@ -51,6 +54,22 @@ var _getting_removed: bool = false var _playing_animation: bool = false var _valid_game_state: bool = false +var _memory_game: MemoryGame: + get(): + if _memory_game == null: + _memory_game = get_tree().get_first_node_in_group("game_scene") + return _memory_game + +var _ui_information: UiInformationSystem: + get(): + if _ui_information == null: + if _memory_game == null: + return _ui_information + for system: Node in _memory_game.get_systems().get_systems(): + if system is UiInformationSystem: + _ui_information = system + break + return _ui_information var _game_manager: GameManager: get(): @@ -157,31 +176,65 @@ func is_turned() -> bool: return _was_clicked func remove_from_board(was_ai: bool) -> void: + top_level = true + z_index = 100 _getting_removed = true + remove_requested.emit() var settings: SettingsResource = SettingsRepository.load_settings() + _playing_animation = true + if not settings.animate_card_matches or was_ai: - _trigger_remove() + _fast_match_animation(settings) return + _player_match_animation(settings) + +func _fast_match_animation(settings: SettingsResource) -> void: var remove_tween: Tween = create_tween() + remove_tween.tween_property(self, "scale", scale, settings.animation_time) + remove_tween.tween_property(self, "scale", Vector2(shrink_animation_scale, shrink_animation_scale), settings.animation_time / 2) + remove_tween.parallel() + remove_tween.tween_method(_move_to_player_ui, 0.0, 1.0, settings.animation_time * 1.5) + remove_tween.finished.connect(_trigger_remove) + +func _player_match_animation(settings: SettingsResource) -> void: var camera: Camera2D = get_viewport().get_camera_2d() - var center: Vector2 = _game_manager._get_viewport_size() / 2.0 var additional_scale: float = 1 if camera != null: - center = camera.get_screen_center_position() additional_scale = 1.0 / camera.zoom.x - z_index = 100 - var target_scale: Vector2 = Vector2(matching_animation_scale * additional_scale, matching_animation_scale * additional_scale) - _playing_animation = true + + var remove_tween: Tween = create_tween() remove_tween.tween_property(self, "scale", scale, settings.animation_time) - remove_tween.tween_property(self, "global_position", center, settings.animation_time) + remove_tween.tween_method(_move_to_center, 0.0, 1.0, settings.animation_time) remove_tween.parallel() remove_tween.tween_property(self, "scale", target_scale, settings.animation_time) ## Wait for some time to display card remove_tween.tween_property(self, "scale", target_scale, settings.animation_time) + remove_tween.tween_property(self, "scale", Vector2(shrink_animation_scale, shrink_animation_scale), settings.animation_time / 2) + remove_tween.parallel() + remove_tween.tween_method(_move_to_player_ui, 0.0, 1.0, settings.animation_time / 2) remove_tween.finished.connect(_trigger_remove) +func _move_to_center(lerp_weight: float) -> void: + var center: Vector2 = _game_manager._get_viewport_size() / 2.0 + var camera: Camera2D = get_viewport().get_camera_2d() + if camera != null: + center = camera.get_screen_center_position() + + global_position = lerp(global_position, center, lerp_weight) + +func _move_to_player_ui(lerp_weight: float) -> void: + var target_position: Vector2 = _get_global_player_ui_position() + + global_position = lerp(global_position, target_position, lerp_weight) + +func _get_global_player_ui_position() -> Vector2: + if _ui_information == null: + return global_position + var player_overlay: PlayerGameOverlay = _ui_information.get_ui_element("PlayersOverlay") + return player_overlay.get_global_position_of_current_player() + func _trigger_remove() -> void: for group: String in get_groups(): remove_from_group(group) diff --git a/entities/game/card_template/scripts/ToggleCardVisibility.gd b/entities/game/card_template/scripts/ToggleCardVisibility.gd index 8863d1a..56500c2 100644 --- a/entities/game/card_template/scripts/ToggleCardVisibility.gd +++ b/entities/game/card_template/scripts/ToggleCardVisibility.gd @@ -31,6 +31,7 @@ var currently_in_focus: bool = false var collider: Area2D var removal_requested: bool = false var can_remove: bool = false +var removal_planned: bool = false var currently_ai: bool = false var animation_tween: Tween = null @@ -116,6 +117,8 @@ func update_toggle_material(progress: float) -> void: func is_focused() -> void: if animation_tween != null && animation_tween.is_running(): return + if visibility == VisibilityEnum.TRANSITION: + return for card: Node in get_tree().get_nodes_in_group("game_card"): if card is CardTemplate and card.card_is_focused(): card.lost_focus() @@ -152,8 +155,11 @@ func is_currently_in_focus() -> bool: func remove_from_board() -> void: removal_requested = true +func removal_planed() -> void: + removal_planned = true + func _process(_delta: float) -> void: - if removal_requested && can_remove: + if removal_planned && can_remove: ready_for_removal.emit() queue_free() diff --git a/entities/game/finish_game/scripts/PlayerScoreList.gd b/entities/game/finish_game/scripts/PlayerScoreList.gd index 2d2874c..1b5aaec 100644 --- a/entities/game/finish_game/scripts/PlayerScoreList.gd +++ b/entities/game/finish_game/scripts/PlayerScoreList.gd @@ -5,10 +5,6 @@ extends VBoxContainer var _win_sound_played: bool = false -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - func build_player_statistic(players: Array[PlayerResource], winners: Array[PlayerResource]) -> void: players.sort_custom(sort_by_score) for player: PlayerResource in players: @@ -21,7 +17,6 @@ func build_player_statistic(players: Array[PlayerResource], winners: Array[Playe break player_node.set_player(player, did_win) add_child(player_node) - func sort_by_score(a: PlayerResource, b: PlayerResource) -> bool: return a.score > b.score diff --git a/entities/game/finish_game/scripts/ReplayGame.gd b/entities/game/finish_game/scripts/ReplayGame.gd index b4ddc8b..e3fd44e 100644 --- a/entities/game/finish_game/scripts/ReplayGame.gd +++ b/entities/game/finish_game/scripts/ReplayGame.gd @@ -9,7 +9,12 @@ func _ready() -> void: func _pressed() -> void: get_tree().paused = false - GlobalGameManagerAccess.get_game_manager().play_game_with_position(finish_game_node.manager.get_players(), finish_game_node.played_deck, get_screen_position()) + var players: Array[PlayerResource] = finish_game_node.manager.get_players() + players.sort_custom(sort_by_id) + GlobalGameManagerAccess.get_game_manager().play_game_with_position(players, finish_game_node.played_deck, get_screen_position()) + +func sort_by_id(a: PlayerResource, b: PlayerResource) -> bool: + return a.id < b.id func was_multiplayer_game() -> bool: return not multiplayer.multiplayer_peer is OfflineMultiplayerPeer \ No newline at end of file diff --git a/entities/game/memory_game/scenes/MemoryGame.tscn b/entities/game/memory_game/scenes/MemoryGame.tscn index 7830854..cacbf55 100644 --- a/entities/game/memory_game/scenes/MemoryGame.tscn +++ b/entities/game/memory_game/scenes/MemoryGame.tscn @@ -8,6 +8,7 @@ [ext_resource type="PackedScene" uid="uid://csamt2tu6hlpo" path="res://entities/game/finish_game/scenes/FinishGame.tscn" id="4_6f670"] [ext_resource type="Script" uid="uid://bxjrl2ikqn4tk" path="res://entities/game/memory_game/scripts/systems/PlayerSystem.gd" id="4_n744t"] [ext_resource type="AudioStream" uid="uid://dq3rmjoitwi1a" path="res://assets/audio/effect/confirmation_001.ogg" id="6_a3528"] +[ext_resource type="Script" uid="uid://cetyf2kvhh70r" path="res://entities/game/memory_game/scripts/Systems.gd" id="7_8jbv8"] [ext_resource type="PackedScene" uid="uid://d0vijthhc3d38" path="res://entities/game/players_overlay/scenes/PlayersOverlay.tscn" id="7_a7rnv"] [ext_resource type="Script" uid="uid://bmwi41kseslkw" path="res://entities/game/memory_game/scripts/systems/GameStateSystem.gd" id="7_j82c0"] [ext_resource type="Script" uid="uid://bglvkbo4aydsy" path="res://entities/game/memory_game/scripts/Background.gd" id="7_kxmqb"] @@ -34,6 +35,7 @@ [ext_resource type="PackedScene" uid="uid://laeqw1xjwd1b" path="res://entities/game/debug_tool/scenes/DebugPanel.tscn" id="33_j82c0"] [ext_resource type="Script" uid="uid://c1wsjd5pkvtiq" path="res://entities/game/debug_tool/scripts/DebugFunctionality.gd" id="34_4hsit"] [ext_resource type="Script" uid="uid://ce067cc441ff1" path="res://entities/game/debug_tool/scripts/FinishGameFunction.gd" id="35_imof5"] +[ext_resource type="Script" uid="uid://b34wu88vlg03e" path="res://entities/game/memory_game/scripts/systems/UiInformationSystem.gd" id="36_m766l"] [ext_resource type="Script" uid="uid://p5xd1ppjr4ph" path="res://entities/game/memory_game/scripts/systems/TutorialStateSystem.gd" id="40_1resq"] [sub_resource type="Resource" id="Resource_kihnp"] @@ -76,9 +78,11 @@ finished_game_template = ExtResource("4_6f670") game_menu_template = ExtResource("12_dfx06") game_nodes_to_show = [NodePath("UI"), NodePath("World/Background")] card_target_node = NodePath("World/Cards") -sound_effect = ExtResource("6_a3528") -[node name="Systems" type="Node" parent="." unique_id=1597793066] +[node name="Systems" type="Node" parent="." unique_id=1325794078] +unique_name_in_owner = true +script = ExtResource("7_8jbv8") +metadata/_custom_type_script = "uid://cetyf2kvhh70r" [node name="GameStateSystem" type="Node" parent="Systems" unique_id=2091663874] script = ExtResource("7_j82c0") @@ -124,6 +128,11 @@ card_template = ExtResource("3_ihyl6") place_offset = Vector2(250, 250) metadata/_custom_type_script = "uid://btm576yjkyt4j" +[node name="UiInformationSystem" type="Node" parent="Systems" unique_id=1812178848] +unique_name_in_owner = true +script = ExtResource("36_m766l") +metadata/_custom_type_script = "uid://b34wu88vlg03e" + [node name="World" type="Node2D" parent="." unique_id=997333008] unique_name_in_owner = true @@ -138,6 +147,7 @@ camera_node = NodePath("../Camera2D") unique_name_in_owner = true script = ExtResource("19_ploi3") state_machine = NodePath("../../Systems/GameStateSystem") +matching_card_sound_effect = ExtResource("6_a3528") [node name="CardTemplateGhost" parent="World" unique_id=155356654 groups=["game_initialize_scene"] instance=ExtResource("3_ihyl6")] position = Vector2(-11367, -8587) @@ -224,7 +234,6 @@ debug_functions = Array[ExtResource("34_4hsit")]([SubResource("Resource_8rpam")] [connection signal="game_paused" from="." to="Systems/PlayerInputSystem" method="game_paused"] [connection signal="game_paused" from="." to="World/Camera2D" method="game_paused"] -[connection signal="game_was_finished" from="." to="World/Camera2D" method="queue_free"] [connection signal="load_game" from="." to="Systems/CardSpawnerSystem" method="place_cards_from_deck"] [connection signal="request_popup" from="." to="Systems/PopupSystem" method="add_and_show_popup"] [connection signal="force_close_popup" from="Systems/GameStateSystem" to="Systems/PopupSystem" method="force_close_popup_with_id"] diff --git a/entities/game/memory_game/scripts/GameCardGrid.gd b/entities/game/memory_game/scripts/GameCardGrid.gd index 88e293e..fbc67b6 100644 --- a/entities/game/memory_game/scripts/GameCardGrid.gd +++ b/entities/game/memory_game/scripts/GameCardGrid.gd @@ -10,6 +10,7 @@ signal board_empty() signal card_activated() @export var state_machine: GameStateSystem +@export var matching_card_sound_effect: AudioStream var current_card: CardTemplate @@ -142,6 +143,7 @@ func remove_cards_from_board(grid_positions: Array[Point]) -> void: if card.is_playing_animation(): await card.about_to_get_delete all_matching_cards_removed.emit() + GlobalSoundManager.play_sound_effect(matching_card_sound_effect) func remove_card_from_board(grid_position: Point) -> void: for child: CardTemplate in _get_game_card_templates_children(): diff --git a/entities/game/memory_game/scripts/MemoryGame.gd b/entities/game/memory_game/scripts/MemoryGame.gd index 5487322..78d2859 100644 --- a/entities/game/memory_game/scripts/MemoryGame.gd +++ b/entities/game/memory_game/scripts/MemoryGame.gd @@ -19,9 +19,6 @@ const CARDS_PER_PLAYER: int = 2 @export var game_nodes_to_show: Array[Node] @export var card_target_node: Node2D -@export_group("Effect Setup") -@export var sound_effect: AudioStream - #var current_game_state: int var player_node: PlayerSystem var triggered_cards: int @@ -34,10 +31,19 @@ var auto_close_popup: PackedScene = preload("res://entities/game/auto_close_popu var last_message_banner_id: int = -1 var _is_local_only: bool = true +var _game_scene_group_name: String = "game_scene" +var _systems: Systems: + get(): + if _systems == null: + _systems = get_node("%Systems") + return _systems + +func _init() -> void: + add_to_group(_game_scene_group_name) func _ready() -> void: process_mode = PROCESS_MODE_DISABLED - player_node = get_node("%PlayerSystem") + player_node = get_node("%PlayerSystem") func start_loading_data() -> void: load_game.emit(card_deck) @@ -58,6 +64,7 @@ func show_initial_setup() -> bool: return true func show_game_end_screen() -> void: + remove_from_group(_game_scene_group_name) var finish_node: GameFinished = finished_game_template.instantiate() as GameFinished finish_node.high_priority = true finish_node.set_player_manager(player_node) @@ -106,4 +113,7 @@ func all_cards_placed() -> void: for child: Node in get_tree().get_nodes_in_group("game_initialize_scene"): child.queue_free() GlobalSoundManager.stop_all_sounds() - process_mode = Node.PROCESS_MODE_INHERIT \ No newline at end of file + process_mode = Node.PROCESS_MODE_INHERIT + +func get_systems() -> Systems: + return _systems \ No newline at end of file diff --git a/entities/game/memory_game/scripts/Systems.gd b/entities/game/memory_game/scripts/Systems.gd new file mode 100644 index 0000000..14835c8 --- /dev/null +++ b/entities/game/memory_game/scripts/Systems.gd @@ -0,0 +1,4 @@ +class_name Systems extends Node + +func get_systems() -> Array[Node]: + return get_children() \ No newline at end of file diff --git a/entities/game/memory_game/scripts/Systems.gd.uid b/entities/game/memory_game/scripts/Systems.gd.uid new file mode 100644 index 0000000..8bac779 --- /dev/null +++ b/entities/game/memory_game/scripts/Systems.gd.uid @@ -0,0 +1 @@ +uid://cetyf2kvhh70r diff --git a/entities/game/memory_game/scripts/systems/AiAgentSystem.gd b/entities/game/memory_game/scripts/systems/AiAgentSystem.gd index 472006d..809527d 100644 --- a/entities/game/memory_game/scripts/systems/AiAgentSystem.gd +++ b/entities/game/memory_game/scripts/systems/AiAgentSystem.gd @@ -37,7 +37,6 @@ func game_state_changed(game_state: GameEnum.State) -> void: timer.stop() return - func get_all_card_positions() -> Array[Point]: return cards_node.get_all_card_positions() diff --git a/entities/game/memory_game/scripts/systems/UiInformationSystem.gd b/entities/game/memory_game/scripts/systems/UiInformationSystem.gd new file mode 100644 index 0000000..e90bf8d --- /dev/null +++ b/entities/game/memory_game/scripts/systems/UiInformationSystem.gd @@ -0,0 +1,20 @@ +class_name UiInformationSystem extends Node + +var _elements: Dictionary[String, Control] = {} + +func register_ui_element(element_name: String, control: Control) -> bool: + if _elements.has(element_name): + return false + _elements.set(element_name, control) + return true + +func get_ui_element(searched_name: String) -> Control: + if _elements.has(searched_name): + return _elements.get(searched_name) + return null + +func get_all_elements() -> Dictionary[String, Control]: + return _elements + +func get_all_names() -> Array[String]: + return _elements.keys() \ No newline at end of file diff --git a/entities/game/memory_game/scripts/systems/UiInformationSystem.gd.uid b/entities/game/memory_game/scripts/systems/UiInformationSystem.gd.uid new file mode 100644 index 0000000..e2f524a --- /dev/null +++ b/entities/game/memory_game/scripts/systems/UiInformationSystem.gd.uid @@ -0,0 +1 @@ +uid://b34wu88vlg03e diff --git a/entities/game/players_overlay/scenes/PlayersOverlay.tscn b/entities/game/players_overlay/scenes/PlayersOverlay.tscn index 8ff8436..e527b74 100644 --- a/entities/game/players_overlay/scenes/PlayersOverlay.tscn +++ b/entities/game/players_overlay/scenes/PlayersOverlay.tscn @@ -1,9 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://d0vijthhc3d38"] +[gd_scene format=3 uid="uid://d0vijthhc3d38"] [ext_resource type="Script" uid="uid://ss52earb6w0r" path="res://entities/game/players_overlay/scripts/PlayerGameOverlay.gd" id="1_mi4rq"] [ext_resource type="PackedScene" uid="uid://cynb8xjpxqa6w" path="res://entities/game/player_name_overlay/scenes/PlayerNameOverlay.tscn" id="2_ehytq"] -[node name="MarginContainer" type="MarginContainer" node_paths=PackedStringArray("player_target_control")] +[node name="MarginContainer" type="MarginContainer" unique_id=1095593491 node_paths=PackedStringArray("player_target_control")] offset_right = 40.0 offset_bottom = 40.0 theme_override_constants/margin_left = 50 @@ -12,35 +12,35 @@ script = ExtResource("1_mi4rq") player_template = ExtResource("2_ehytq") player_target_control = NodePath("PanelContainer/MarginContainer/PlayerList") -[node name="PanelContainer" type="PanelContainer" parent="."] +[node name="PanelContainer" type="PanelContainer" parent="." unique_id=92997789] layout_mode = 2 tooltip_text = "Players" -[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=614710565] layout_mode = 2 theme_override_constants/margin_left = 10 theme_override_constants/margin_top = 10 theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 10 -[node name="PlayerList" type="VBoxContainer" parent="PanelContainer/MarginContainer"] +[node name="PlayerList" type="VBoxContainer" parent="PanelContainer/MarginContainer" unique_id=1714859550] layout_mode = 2 -[node name="Label" type="Label" parent="PanelContainer/MarginContainer/PlayerList"] +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/PlayerList" unique_id=2419812] layout_mode = 2 text = "PLAYER_LIST" horizontal_alignment = 1 -[node name="PlayerNames" type="VBoxContainer" parent="PanelContainer/MarginContainer/PlayerList"] +[node name="PlayerNames" type="VBoxContainer" parent="PanelContainer/MarginContainer/PlayerList" unique_id=939828383] layout_mode = 2 size_flags_vertical = 4 -[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/MarginContainer/PlayerList/PlayerNames"] -clip_contents = true +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/MarginContainer/PlayerList/PlayerNames" unique_id=407573925] custom_minimum_size = Vector2(5, 5) +clip_contents = true layout_mode = 2 -[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/MarginContainer/PlayerList/PlayerNames/MarginContainer"] +[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/MarginContainer/PlayerList/PlayerNames/MarginContainer" unique_id=391253913] layout_mode = 2 text = "PLACEHOLDER" fit_content = true diff --git a/entities/game/players_overlay/scripts/PlayerGameOverlay.gd b/entities/game/players_overlay/scripts/PlayerGameOverlay.gd index e4b41f5..7963596 100644 --- a/entities/game/players_overlay/scripts/PlayerGameOverlay.gd +++ b/entities/game/players_overlay/scripts/PlayerGameOverlay.gd @@ -1,13 +1,23 @@ -extends Control +class_name PlayerGameOverlay extends Control @export var player_template: PackedScene @export var player_target_control: Control +var _ui_information_system: UiInformationSystem = null +var _current_player: int = -1 + # Called when the node enters the scene tree for the first time. func _ready() -> void: visible = false for child: Node in player_target_control.get_children(): player_target_control.remove_child(child) + var scene_parent: MemoryGame = get_tree().get_first_node_in_group("game_scene") + var systems: Systems = scene_parent.get_systems() + for system: Node in systems.get_systems(): + if system is UiInformationSystem: + _ui_information_system = system + break + _ui_information_system.register_ui_element(name, self) func add_player(player: PlayerResource) -> void: var node: PlayerGameLabel = player_template.instantiate() as PlayerGameLabel @@ -17,6 +27,7 @@ func add_player(player: PlayerResource) -> void: player_target_control.add_child(node) func player_changed(player_id: int) -> void: + _current_player = player_id for child: Node in player_target_control.get_children(): if child is PlayerGameLabel: child.player_turn(player_id) @@ -37,3 +48,25 @@ func game_ended() -> void: func game_state_changed(game_state: GameEnum.State) -> void: if game_state == GameEnum.State.TURN_END: round_end() + if game_state == GameEnum.State.GAME_END: + visible = false + +func get_global_position_of_current_player() -> Vector2: + var target: Control = null + for child: Control in player_target_control.get_children(): + if child.contained_player.id == _current_player: + target = child + break + if target == null: + target = self + var camera: Camera2D = get_viewport().get_camera_2d() + if camera == null: + return global_position + + var ui_screen_pos: Vector2 = target.get_global_rect().get_center() + ui_screen_pos.x = get_global_rect().end.x + var viewport_center: Vector2 = get_viewport().get_visible_rect().get_center() + + var world_position: Vector2 = camera.global_position + (ui_screen_pos - viewport_center) / camera.zoom + + return world_position diff --git a/shared/entities/clickable_button/resources/actions/StartGameAction.gd b/shared/entities/clickable_button/resources/actions/StartGameAction.gd index 5dff251..47d42b3 100644 --- a/shared/entities/clickable_button/resources/actions/StartGameAction.gd +++ b/shared/entities/clickable_button/resources/actions/StartGameAction.gd @@ -4,9 +4,12 @@ class_name StartGameAction extends ButtonAction func execute(base: ClickableButton) -> void: var order_number: int = 0 + var player_templates: Array[PlayerResource] = [] for player: PlayerResource in players: - player.order_number = order_number - if player.ai_difficulty != null: - player.name = player.ai_difficulty.get_translated_name() + var template: PlayerResource = player.duplicate_deep() + template.order_number = order_number + if template.ai_difficulty != null: + template.name = template.ai_difficulty.get_translated_name() + player_templates.append(template) var game_manager: GameManager = GlobalGameManagerAccess.get_game_manager() - game_manager.play_game_with_position(players, game_manager.get_available_decks().pick_random(), base.get_global_center_position()) \ No newline at end of file + game_manager.play_game_with_position(player_templates, game_manager.get_available_decks().pick_random(), base.get_global_center_position()) \ No newline at end of file