feat: rps button with texture
This commit is contained in:
parent
46e4ba0fbb
commit
5395f971cb
2 changed files with 66 additions and 18 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=19 format=3 uid="uid://bgc0u117jqyr1"]
|
||||
[gd_scene load_steps=22 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"]
|
||||
|
|
@ -18,6 +18,9 @@
|
|||
[ext_resource type="Resource" uid="uid://c0grh1y65e0f3" path="res://data/cards/support/energy_booster.tres" id="10_3rg8q"]
|
||||
[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="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"]
|
||||
|
||||
[node name="DemoGame" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -30,7 +33,7 @@ script = ExtResource("1_jn16u")
|
|||
player_1_deck = Array[ExtResource("2_xuft0")]([ExtResource("3_we1tk"), ExtResource("4_kkhfk"), ExtResource("5_3cm5x"), ExtResource("6_potm8"), ExtResource("7_nvv8k"), ExtResource("8_ewr4v"), ExtResource("9_ga5hf"), ExtResource("10_3rg8q"), ExtResource("11_seakd")])
|
||||
player_2_deck = Array[ExtResource("2_xuft0")]([ExtResource("12_xqqfn"), ExtResource("4_kkhfk"), ExtResource("6_potm8"), ExtResource("7_nvv8k"), ExtResource("8_ewr4v"), ExtResource("9_ga5hf"), ExtResource("10_3rg8q"), ExtResource("11_seakd"), ExtResource("5_3cm5x")])
|
||||
|
||||
[node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")]
|
||||
[node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label", "rps_button_container")]
|
||||
layout_mode = 1
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
|
|
@ -44,6 +47,8 @@ skip_card_prefab = ExtResource("7_skjyk")
|
|||
support_red_card_prefab = ExtResource("9_cabcc")
|
||||
support_green_card_prefab = ExtResource("8_dytl5")
|
||||
monster_card_prefab = ExtResource("7_4ah45")
|
||||
rps_button_container = NodePath("HBoxContainer")
|
||||
rps_grayed_color = Color(0.439216, 0.439216, 0.439216, 1)
|
||||
|
||||
[node name="MonsterCard" parent="Own" instance=ExtResource("7_4ah45")]
|
||||
custom_minimum_size = Vector2(220, 330)
|
||||
|
|
@ -109,12 +114,14 @@ text = "Energy:"
|
|||
|
||||
[node name="Hand" type="HBoxContainer" parent="Own"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -240.0
|
||||
offset_bottom = 130.0
|
||||
offset_left = -446.0
|
||||
offset_top = -370.0
|
||||
offset_right = 446.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
pivot_offset = Vector2(0, 150)
|
||||
|
|
@ -145,6 +152,26 @@ grow_horizontal = 2
|
|||
text = "Incoming Damage: 0"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Own"]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_left = 665.0
|
||||
offset_top = 299.0
|
||||
offset_right = 1326.0
|
||||
offset_bottom = 548.0
|
||||
|
||||
[node name="KertasButton" type="TextureButton" parent="Own/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("18_gwpy8")
|
||||
|
||||
[node name="GuntingButton" type="TextureButton" parent="Own/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("19_clnw6")
|
||||
|
||||
[node name="BatuButton" type="TextureButton" parent="Own/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("20_672ya")
|
||||
|
||||
[node name="Opponent" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")]
|
||||
layout_mode = 1
|
||||
anchor_right = 1.0
|
||||
|
|
@ -279,6 +306,9 @@ text = "Start Game"
|
|||
|
||||
[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"]
|
||||
[connection signal="button_down" from="Own/HBoxContainer/GuntingButton" to="Own" method="_on_gunting_button_button_down"]
|
||||
[connection signal="button_down" from="Own/HBoxContainer/BatuButton" to="Own" method="_on_batu_button_button_down"]
|
||||
[connection signal="play_card" from="Opponent" to="." method="_on_opponent_play_card"]
|
||||
[connection signal="rps_move" from="Opponent" to="." method="_on_opponent_rps_move"]
|
||||
[connection signal="button_up" from="StartGameButton" to="." method="_on_start_game_button_button_up"]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ signal rps_move(move: String)
|
|||
@export var support_red_card_prefab: PackedScene
|
||||
@export var support_green_card_prefab: PackedScene
|
||||
@export var monster_card_prefab: PackedScene
|
||||
@export var rps_button_container: Container
|
||||
@export var rps_grayed_color: Color
|
||||
|
||||
@onready var monster_card_ui := $"MonsterCard"
|
||||
@onready var support1_green := $"Support1GreenCard"
|
||||
|
|
@ -132,16 +134,11 @@ func _on_update(transition):
|
|||
_pop_this_card(btn)
|
||||
play_card.emit(card))
|
||||
|
||||
if match_manager.phase == Match.Phase.RPS:
|
||||
for move in ["rock", "paper", "scissors"]:
|
||||
if rps_button_container:
|
||||
rps_button_container.visible = match_manager.phase == Match.Phase.RPS
|
||||
for button: TextureButton in rps_button_container.get_children():
|
||||
button.modulate = rps_grayed_color
|
||||
|
||||
if !show_buttons:
|
||||
continue
|
||||
|
||||
var btn = Button.new()
|
||||
btn.text = move
|
||||
btn.button_up.connect(func (): rps_move.emit(move))
|
||||
deck.add_child(btn)
|
||||
|
||||
func _pop_this_card(control: Control):
|
||||
if selected_card:
|
||||
|
|
@ -149,3 +146,24 @@ func _pop_this_card(control: Control):
|
|||
|
||||
control.size_flags_vertical = Control.SIZE_SHRINK_BEGIN
|
||||
selected_card = control
|
||||
|
||||
|
||||
func _on_kertas_button_button_down() -> void:
|
||||
rps_move.emit("paper")
|
||||
for button: TextureButton in rps_button_container.get_children():
|
||||
button.modulate = rps_grayed_color
|
||||
rps_button_container.get_node("KertasButton").modulate = Color.WHITE
|
||||
|
||||
|
||||
func _on_gunting_button_button_down() -> void:
|
||||
rps_move.emit("scissors")
|
||||
for button: TextureButton in rps_button_container.get_children():
|
||||
button.modulate = rps_grayed_color
|
||||
rps_button_container.get_node("GuntingButton").modulate = Color.WHITE
|
||||
|
||||
|
||||
func _on_batu_button_button_down() -> void:
|
||||
rps_move.emit("rock")
|
||||
for button: TextureButton in rps_button_container.get_children():
|
||||
button.modulate = rps_grayed_color
|
||||
rps_button_container.get_node("BatuButton").modulate = Color.WHITE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue