feat: new cards in game
This commit is contained in:
parent
2c4e9d90f3
commit
5af462e78d
14 changed files with 700 additions and 123 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue