diff --git a/demo_game.gd b/demo_game.gd index fdf9321..10c92e5 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -8,7 +8,8 @@ signal opponent_played_rts(move: String) @export var player_1_deck: Array[Card] @export var player_2_deck: Array[Card] -@onready var match_manager = $MatchManager + +@onready var match_manager: MatchManager = $MatchManager @onready var own_side = $Own @onready var opponent_side = $Opponent @onready var start_game_btn = $StartGameButton @@ -30,6 +31,9 @@ var player_2_action: Action: var id var signal_connected := false +func _ready() -> void: + _update_phase_info(Match.Phase.PREGAME) + func init(player_id: int) -> void: id = player_id @@ -44,6 +48,7 @@ func init(player_id: int) -> void: if card.id not in id_to_card: id_to_card[card.id] = card + print(match_manager.phase) match_manager.init({ MatchManager.PLAYER_1_ID: player_1_deck, MatchManager.PLAYER_2_ID: player_2_deck @@ -59,6 +64,7 @@ var transition_history: Array[PhaseTransition] = [] func _on_match_manager_state_transitioned(transition: PhaseTransition): start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME transition_history.append(transition) + _update_phase_info(transition.to) print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to)) func _on_start_game_button_button_up() -> void: @@ -113,3 +119,12 @@ func rpc_opponent_rps_move(move: String) -> void: if player_1_action: match_manager.resolve(player_action_queue) player_action_queue.clear() + +func _update_phase_info(phase: Match.Phase): + var phaseHeaders: Container = get_node("%PhaseInfo/PhaseHeader") + for child: Label in phaseHeaders.get_children(): + child.modulate = Color.DIM_GRAY + var target = phaseHeaders.get_node(Match.phase_to_str(phase)) + phaseHeaders.visible = target != null + if target: + target.modulate = Color.WHITE diff --git a/demo_game.tscn b/demo_game.tscn index 7f9d67d..a76e523 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=23 format=3 uid="uid://bgc0u117jqyr1"] [ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"] [ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"] @@ -6,7 +6,7 @@ [ext_resource type="PackedScene" uid="uid://cikstg43mudkn" path="res://tcg/match/match_manager.tscn" id="3_3yhrl"] [ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/monster/capytain.tres" id="3_we1tk"] [ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="4_kkhfk"] -[ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] +[ext_resource type="Resource" uid="uid://deo8mj887rfx1" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [ext_resource type="Resource" uid="uid://bcrlaam8uq6xt" path="res://data/cards/support/lifesteal.tres" id="6_potm8"] [ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] [ext_resource type="Resource" uid="uid://dgxcvdo6x6kst" path="res://data/cards/support/all_out_attack.tres" id="7_nvv8k"] @@ -19,6 +19,7 @@ [ext_resource type="Resource" uid="uid://2xeb6keaoabo" path="res://data/cards/support/sword_mastery.tres" id="11_seakd"] [ext_resource type="Resource" uid="uid://bmst884k0myvd" path="res://data/cards/monster/cattogato.tres" id="12_xqqfn"] [ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="18_gwpy8"] +[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="19_3iovu"] [ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="19_clnw6"] [ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="20_672ya"] @@ -253,18 +254,6 @@ offset_bottom = 31.0 grow_horizontal = 2 alignment = 1 -[node name="Button" type="Button" parent="Opponent/Hand"] -layout_mode = 2 -text = "CARD_1" - -[node name="Button2" type="Button" parent="Opponent/Hand"] -layout_mode = 2 -text = "CARD_2" - -[node name="Button3" type="Button" parent="Opponent/Hand"] -layout_mode = 2 -text = "CARD_3" - [node name="EnergyLabel" type="Label" parent="Opponent"] layout_mode = 2 offset_top = 35.0 @@ -305,6 +294,50 @@ text = "Start Game" [node name="MatchManager" parent="." instance=ExtResource("3_3yhrl")] +[node name="PhaseInfo" type="VBoxContainer" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 347.0 +offset_top = -102.0 +offset_right = 864.0 +offset_bottom = 106.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PhaseHeader" type="VBoxContainer" parent="PhaseInfo"] +layout_mode = 2 +theme_override_constants/separation = 24 +alignment = 2 + +[node name="Summon" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Summon" + +[node name="Support 1" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Support (1)" + +[node name="RPS" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Rock, Paper, Scissors" + +[node name="Support 2" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Support (2)" + [connection signal="play_card" from="Own" to="." method="_on_own_play_card"] [connection signal="rps_move" from="Own" to="." method="_on_own_rps_move"] [connection signal="button_down" from="Own/HBoxContainer/KertasButton" to="Own" method="_on_kertas_button_button_down"]