feat: new cards in game

This commit is contained in:
Kenshia 2025-01-26 01:58:35 +07:00
parent 2c4e9d90f3
commit 5af462e78d
14 changed files with 700 additions and 123 deletions

View file

@ -1,4 +1,9 @@
extends Control
class_name CardBase
signal left_clicked
signal right_clicked
signal hovering(delta: float)
@export var card_name_label: Label
@export var card_desc_label: Label
@ -17,4 +22,23 @@ func _update(card: SupportCard):
card_desc_label.text = card.description
icon_rect.texture = card.icon
func _process(delta):
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if rect.has_point(mouse_position):
hovering.emit(delta)
func _input(event):
if event is InputEventMouseButton:
if !event.is_pressed():
return
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if not rect.has_point(mouse_position):
return
if event.button_index == MOUSE_BUTTON_LEFT:
left_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT:
right_clicked.emit()

View file

@ -1,7 +1,56 @@
extends Control
class_name MonsterCardUI
@export var name_label: Label
@export var health_label: Label
@export var energy_pip_container: Container
@export var energy_pip: PackedScene
@export var art: Texture2D
signal left_clicked
signal right_clicked
signal hovering(delta: float)
@export var name_label : Label
@export var health_label : Label
@export var energy_pip_container :Container
@export var icon_texture_rect : TextureRect
@export var paper_damage : Label
@export var scissors_damage : Label
@export var rock_damage : Label
func show_monster(monster: MatchMonster):
if !monster:
name_label.text = ""
health_label.text = "HP"
icon_texture_rect.texture = null
return
name_label.text = monster.card.id
health_label.text = "HP %d" % [monster.health]
icon_texture_rect.texture = monster.card.icon
paper_damage.text = str(monster.card.paper)
scissors_damage.text = str(monster.card.scissors)
rock_damage.text = str(monster.card.rock)
var shown_stars = 0
for child in energy_pip_container.get_children():
var tr = child as TextureRect
tr.visible = shown_stars < monster.card.energy_cost
shown_stars += 1
func _process(delta):
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if rect.has_point(mouse_position):
hovering.emit(delta)
func _input(event):
if event is InputEventMouseButton:
if !event.is_pressed():
return
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if not rect.has_point(mouse_position):
return
if event.button_index == MOUSE_BUTTON_LEFT:
left_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT:
right_clicked.emit()

View file

@ -15,16 +15,27 @@
[ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="13_ifoc6"]
[ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="14_gm7k7"]
[node name="MonsterCard" type="Control"]
[node name="MonsterCard" type="Control" node_paths=PackedStringArray("name_label", "health_label", "energy_pip_container", "icon_texture_rect", "paper_damage", "scissors_damage", "rock_damage")]
custom_minimum_size = Vector2(220, 320)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -932.0
offset_bottom = -328.0
offset_right = -1700.0
offset_bottom = -760.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.7, 0.7)
pivot_offset = Vector2(110, 160)
size_flags_vertical = 8
script = ExtResource("1_xddej")
name_label = NodePath("MarginContainer/MonsterNameLabel")
health_label = NodePath("MarginContainer/HealthLabel")
energy_pip_container = NodePath("MarginContainer/EnergyStarsContainer")
icon_texture_rect = NodePath("MarginContainer/TextureRect2/IconTextureRect")
paper_damage = NodePath("MarginContainer/Paper/PaperDamage")
scissors_damage = NodePath("MarginContainer/Scissors/ScissorsDamage")
rock_damage = NodePath("MarginContainer/Rock/RockDamage")
[node name="Screenshot2025-01-25211435" type="Sprite2D" parent="."]
visible = false
@ -95,7 +106,8 @@ texture = ExtResource("7_qe8a1")
expand_mode = 1
stretch_mode = 5
[node name="TextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"]
[node name="IconTextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@ -106,32 +118,34 @@ texture = ExtResource("7_j2i0p")
expand_mode = 1
stretch_mode = 5
[node name="EnergyStars" type="HBoxContainer" parent="MarginContainer"]
[node name="EnergyStarsContainer" type="HBoxContainer" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 0
offset_left = 141.0
offset_top = 55.0
offset_right = 200.0
offset_bottom = 70.0
[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStars"]
[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_ophhb")
expand_mode = 3
stretch_mode = 5
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStars"]
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_ophhb")
expand_mode = 3
stretch_mode = 5
[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStars"]
[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_ophhb")
expand_mode = 3
stretch_mode = 5
[node name="HPNumber" type="Label" parent="MarginContainer"]
[node name="HealthLabel" type="Label" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -146,6 +160,7 @@ text = "HP 80"
vertical_alignment = 1
[node name="MonsterNameLabel" type="Label" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -191,6 +206,7 @@ horizontal_alignment = 1
vertical_alignment = 1
[node name="Paper" type="TextureRect" parent="MarginContainer"]
layout_mode = 0
offset_left = 109.0
offset_top = 183.0
offset_right = 222.0
@ -199,7 +215,8 @@ texture = ExtResource("14_gm7k7")
expand_mode = 1
stretch_mode = 5
[node name="HPNumber" type="Label" parent="MarginContainer/Paper"]
[node name="PaperDamage" type="Label" parent="MarginContainer/Paper"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -214,6 +231,7 @@ text = "10"
vertical_alignment = 1
[node name="Scissors" type="TextureRect" parent="MarginContainer"]
layout_mode = 0
offset_left = 43.0
offset_top = 182.0
offset_right = 156.0
@ -222,7 +240,8 @@ texture = ExtResource("13_ifoc6")
expand_mode = 1
stretch_mode = 5
[node name="HPNumber" type="Label" parent="MarginContainer/Scissors"]
[node name="ScissorsDamage" type="Label" parent="MarginContainer/Scissors"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -246,7 +265,8 @@ texture = ExtResource("12_a4kkh")
expand_mode = 1
stretch_mode = 5
[node name="HPNumber" type="Label" parent="MarginContainer/Rock"]
[node name="RockDamage" type="Label" parent="MarginContainer/Rock"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0

View file

@ -0,0 +1,274 @@
[gd_scene load_steps=14 format=3 uid="uid://b60vuykleugjn"]
[ext_resource type="Script" path="res://ui/card_template/card_base.gd" id="1_ci66m"]
[ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="3_lbsr3"]
[ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="4_avv1r"]
[ext_resource type="Texture2D" uid="uid://c2qyx2k50v2vv" path="res://assets/card_base/Monster-InnerFill.png" id="5_3yv36"]
[ext_resource type="Texture2D" uid="uid://dft4fbgoecbp4" path="res://assets/card_base/Illustrated BG.png" id="6_cfl8c"]
[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="7_5xgn0"]
[ext_resource type="Texture2D" uid="uid://cqttp0i3vph37" path="res://assets/card_base/Star.png" id="8_gh78y"]
[ext_resource type="Theme" path="res://cards.tres" id="9_gwg6h"]
[ext_resource type="Texture2D" uid="uid://cjmxetjq82rl2" path="res://assets/card_base/Pip.png" id="10_kd76d"]
[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="11_ofcpo"]
[ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="12_dql2x"]
[ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="13_0vsuw"]
[ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="14_o8cdd"]
[node name="SkipCard" type="Control"]
custom_minimum_size = Vector2(220, 320)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -1700.0
offset_bottom = -760.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.7, 0.7)
pivot_offset = Vector2(110, 160)
size_flags_vertical = 8
script = ExtResource("1_ci66m")
[node name="Frame" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("3_lbsr3")
expand_mode = 1
[node name="MarginContainer" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = 3.0
offset_right = -5.0
offset_bottom = -4.0
grow_horizontal = 2
grow_vertical = 2
[node name="OuterStroke" type="NinePatchRect" parent="MarginContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("4_avv1r")
[node name="InnerFill" type="TextureRect" parent="MarginContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 43.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("5_3yv36")
expand_mode = 1
[node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 42.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("4_avv1r")
[node name="TextureRect2" type="TextureRect" parent="MarginContainer"]
layout_mode = 0
offset_left = 9.0
offset_top = 77.0
offset_right = 199.0
offset_bottom = 207.0
pivot_offset = Vector2(95, 65)
texture = ExtResource("6_cfl8c")
expand_mode = 1
stretch_mode = 5
[node name="IconTextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("7_5xgn0")
expand_mode = 1
stretch_mode = 5
[node name="EnergyStarsContainer" type="HBoxContainer" parent="MarginContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 0
offset_left = 141.0
offset_top = 55.0
offset_right = 200.0
offset_bottom = 70.0
[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_gh78y")
expand_mode = 3
stretch_mode = 5
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_gh78y")
expand_mode = 3
stretch_mode = 5
[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"]
layout_mode = 2
texture = ExtResource("8_gh78y")
expand_mode = 3
stretch_mode = 5
[node name="HealthLabel" type="Label" parent="MarginContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_left = 14.0
offset_top = 44.0
offset_right = -99.0
offset_bottom = 80.0
grow_horizontal = 2
theme = ExtResource("9_gwg6h")
theme_override_font_sizes/font_size = 16
text = "HP 80"
vertical_alignment = 1
[node name="MonsterNameLabel" type="Label" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_left = 63.1429
offset_top = 118.429
offset_right = 58.1429
offset_bottom = 154.429
grow_horizontal = 2
theme = ExtResource("9_gwg6h")
theme_override_font_sizes/font_size = 26
text = "SKIP"
vertical_alignment = 1
[node name="CardNumber" type="TextureRect" parent="MarginContainer"]
visible = false
layout_mode = 0
offset_left = 7.0
offset_top = 17.0
offset_right = 26.0
offset_bottom = 36.0
texture = ExtResource("10_kd76d")
expand_mode = 1
stretch_mode = 5
[node name="Label" type="Label" parent="MarginContainer/CardNumber"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -9.5
offset_top = -7.0
offset_right = 9.5
offset_bottom = 7.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("9_gwg6h")
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("11_ofcpo")
theme_override_font_sizes/font_size = 6
text = "#01"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Paper" type="TextureRect" parent="MarginContainer"]
visible = false
layout_mode = 0
offset_left = 109.0
offset_top = 183.0
offset_right = 222.0
offset_bottom = 356.0
texture = ExtResource("12_dql2x")
expand_mode = 1
stretch_mode = 5
[node name="PaperDamage" type="Label" parent="MarginContainer/Paper"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_left = 48.0
offset_top = 32.0
offset_right = -32.0
offset_bottom = 73.0
grow_horizontal = 2
theme = ExtResource("9_gwg6h")
theme_override_font_sizes/font_size = 20
text = "10"
vertical_alignment = 1
[node name="Scissors" type="TextureRect" parent="MarginContainer"]
visible = false
layout_mode = 0
offset_left = 43.0
offset_top = 182.0
offset_right = 156.0
offset_bottom = 355.0
texture = ExtResource("13_0vsuw")
expand_mode = 1
stretch_mode = 5
[node name="ScissorsDamage" type="Label" parent="MarginContainer/Scissors"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_left = 48.0
offset_top = 32.0
offset_right = -32.0
offset_bottom = 73.0
grow_horizontal = 2
theme = ExtResource("9_gwg6h")
theme_override_font_sizes/font_size = 20
text = "10"
vertical_alignment = 1
[node name="Rock" type="TextureRect" parent="MarginContainer"]
visible = false
layout_mode = 0
offset_left = -23.0
offset_top = 181.0
offset_right = 90.0
offset_bottom = 354.0
texture = ExtResource("14_o8cdd")
expand_mode = 1
stretch_mode = 5
[node name="RockDamage" type="Label" parent="MarginContainer/Rock"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_left = 48.0
offset_top = 32.0
offset_right = -32.0
offset_bottom = 73.0
grow_horizontal = 2
theme = ExtResource("9_gwg6h")
theme_override_font_sizes/font_size = 20
text = "10"
vertical_alignment = 1

View file

@ -7,15 +7,19 @@
[ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_pgomu"]
[ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_501uu"]
[ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_ce7hm"]
[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_va1d7"]
[ext_resource type="Theme" path="res://cards.tres" id="7_va1d7"]
[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="8_4yq42"]
[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="10_c2ugn"]
[node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")]
custom_minimum_size = Vector2(220, 320)
layout_mode = 3
anchors_preset = 0
offset_right = 220.0
offset_bottom = 320.0
scale = Vector2(0.7, 0.7)
pivot_offset = Vector2(110, 160)
size_flags_vertical = 8
script = ExtResource("1_rpopv")
card_name_label = NodePath("MarginContainer/Label")
card_desc_label = NodePath("MarginContainer/DescriptionLabel")
@ -144,6 +148,7 @@ horizontal_alignment = 1
vertical_alignment = 1
[node name="Icon" type="TextureRect" parent="MarginContainer"]
layout_mode = 0
offset_left = 26.0
offset_top = 74.0
offset_right = 169.0
@ -153,6 +158,7 @@ expand_mode = 1
stretch_mode = 6
[node name="DescriptionLabel" type="Label" parent="MarginContainer"]
layout_mode = 0
offset_left = 11.0
offset_top = 224.0
offset_right = 200.0

View file

@ -7,15 +7,19 @@
[ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_2fw8n"]
[ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_n3v14"]
[ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_wrd2a"]
[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_fp6ys"]
[ext_resource type="Theme" path="res://cards.tres" id="7_fp6ys"]
[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="9_vilw6"]
[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="10_2t0ey"]
[node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")]
custom_minimum_size = Vector2(220, 320)
layout_mode = 3
anchors_preset = 0
offset_right = 220.0
offset_bottom = 320.0
scale = Vector2(0.7, 0.7)
pivot_offset = Vector2(110, 160)
size_flags_vertical = 8
script = ExtResource("1_d22a5")
card_name_label = NodePath("MarginContainer/Title")
card_desc_label = NodePath("MarginContainer/DescriptionLabel")