feat: rps button with texture
This commit is contained in:
parent
46e4ba0fbb
commit
5395f971cb
2 changed files with 66 additions and 18 deletions
|
|
@ -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"
|
||||
|
|
@ -131,21 +133,37 @@ func _on_update(transition):
|
|||
btn.left_clicked.connect(func ():
|
||||
_pop_this_card(btn)
|
||||
play_card.emit(card))
|
||||
|
||||
if match_manager.phase == Match.Phase.RPS:
|
||||
for move in ["rock", "paper", "scissors"]:
|
||||
|
||||
if !show_buttons:
|
||||
continue
|
||||
|
||||
var btn = Button.new()
|
||||
btn.text = move
|
||||
btn.button_up.connect(func (): rps_move.emit(move))
|
||||
deck.add_child(btn)
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
func _pop_this_card(control: Control):
|
||||
if selected_card:
|
||||
selected_card.size_flags_vertical = Control.SIZE_SHRINK_END
|
||||
|
||||
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