Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions entities/game/card_collider/scene/CardCollider.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[gd_scene format=3 uid="uid://0m4c62oqj4ih"]

[ext_resource type="Script" uid="uid://bdy6xfwtsa3ff" path="res://entities/game/card_collider/scripts/CardCollider.gd" id="1_rityh"]

[node name="CardCollider" type="Node2D" unique_id=620304416]
script = ExtResource("1_rityh")

[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=214623478]
input_pickable = true

[node name="CollisionShape" type="CollisionShape2D" parent="StaticBody2D" unique_id=721046375]
unique_name_in_owner = true

[connection signal="set_shape" from="." to="StaticBody2D/CollisionShape" method="set_shape"]
[connection signal="input_event" from="StaticBody2D" to="." method="input_event"]
[connection signal="mouse_entered" from="StaticBody2D" to="." method="mouse_entered"]
[connection signal="mouse_exited" from="StaticBody2D" to="." method="mouse_has_left"]
48 changes: 48 additions & 0 deletions entities/game/card_collider/scripts/CardCollider.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class_name CardCollider extends Node2D

signal set_shape(shape: RectangleShape2D)
signal mouse_enter(grid: Vector2i)
signal mouse_left(grid: Vector2i)
signal clicked(grid: Vector2i)

var _grid_coordinate: Vector2i = Vector2i.ZERO
var _shape: CollisionShape2D = null

var _mouse_inside: bool = false

func _ready() -> void:
_shape = get_node("%CollisionShape")

func set_size(size: Vector2) -> void:
var shape: RectangleShape2D = RectangleShape2D.new()
shape.size = size

set_shape.emit(shape)

func set_grid_coordinate(grid_data: Vector2i) -> void:
_grid_coordinate = grid_data

func get_grid_coordinate() -> Vector2i:
return _grid_coordinate

func enable_collider() -> void:
_shape.disabled = false

func disable_collider() -> void:
_shape.disabled = true

func mouse_entered() -> void:
mouse_enter.emit(_grid_coordinate)
_mouse_inside = true

func mouse_has_left() -> void:
mouse_left.emit(_grid_coordinate)
_mouse_inside = false

func input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
if not _mouse_inside:
return
if event is InputEventMouseButton:
if event.pressed and event.button_index == MouseButton.MOUSE_BUTTON_LEFT:
clicked.emit(_grid_coordinate)
disable_collider()
1 change: 1 addition & 0 deletions entities/game/card_collider/scripts/CardCollider.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bdy6xfwtsa3ff
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends Node
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://3sou5fpl2h3r
19 changes: 2 additions & 17 deletions entities/game/card_template/scenes/CardTemplate.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
[ext_resource type="Resource" uid="uid://0hefyj7q57o6" path="res://entities/game/card_template/assets/dissolve_effects/dissolve.tres" id="8_nugiu"]
[ext_resource type="Script" uid="uid://cdvlsp04l5fhr" path="res://entities/game/card_template/scripts/ToggleCardVisibility.gd" id="8_pw264"]
[ext_resource type="Script" uid="uid://b5mhdwdn1h8fo" path="res://entities/game/card_template/scripts/CardDropShadow.gd" id="9_ja01p"]
[ext_resource type="Script" uid="uid://dni6lxtacurf1" path="res://entities/game/card_template/scripts/CardHandler.gd" id="9_mu0q4"]
[ext_resource type="Shader" uid="uid://djs1o5pxaguit" path="res://assets/shaders/SingleColorShader.gdshader" id="9_vcvmk"]
[ext_resource type="Texture2D" uid="uid://bmxqeqo65xwt" path="res://assets/sprites/spritesheet-default.png" id="12_h72da"]
[ext_resource type="Texture2D" uid="uid://b0lfebra6adhv" path="res://assets/sprites/Axuree/back_card_1.png" id="14_bmj37"]
Expand Down Expand Up @@ -52,9 +51,6 @@ region = Rect2(384, 256, 64, 64)
shader = ExtResource("14_l7f2y")
shader_parameter/edge_fade_width = 0.05

[sub_resource type="RectangleShape2D" id="RectangleShape2D_phkhd"]
size = Vector2(500, 550)

[sub_resource type="Curve" id="Curve_vcvmk"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.113014, 1), 0.0, 0.0, 0, 0, Vector2(0.75, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 4
Expand Down Expand Up @@ -165,13 +161,6 @@ toggle_material = ExtResource("5_b0osi")
focus_material = ExtResource("16_ja01p")
enforced_back_color = Color(1, 0.8745098, 0.7372549, 1)

[node name="Collider" type="Area2D" parent="CardBack" unique_id=1050148911]
unique_name_in_owner = true
script = ExtResource("9_mu0q4")

[node name="CollisionShape2D" type="CollisionShape2D" parent="CardBack/Collider" unique_id=876216407]
shape = SubResource("RectangleShape2D_phkhd")

[node name="DebugInformation" type="Node2D" parent="." unique_id=1036970705 node_paths=PackedStringArray("card_id_label", "card_position_label")]
position = Vector2(-250, -250)
script = ExtResource("18_tqsbp")
Expand Down Expand Up @@ -220,8 +209,10 @@ volume = -15.0
[connection signal="about_to_get_delete" from="." to="CardContentGroup" method="animate_destruction"]
[connection signal="about_to_get_delete" from="." to="CardBack" method="remove_from_board"]
[connection signal="about_to_get_delete" from="." to="MatchingFoundEffect" method="trigger"]
[connection signal="card_in_focus" from="." to="CardContentGroup/DropShadow" method="got_focus"]
[connection signal="card_in_focus" from="." to="CardBack" method="is_focused"]
[connection signal="card_in_focus" from="." to="FocusEffect" method="trigger_random_effect"]
[connection signal="card_lost_focus" from="." to="CardContentGroup/DropShadow" method="lost_focus"]
[connection signal="card_lost_focus" from="." to="CardBack" method="lost_focus"]
[connection signal="card_text_changed" from="." to="CardContentGroup/CardNameBackground/CardName" method="set_card_text"]
[connection signal="card_tooltip_changed" from="." to="CardContentGroup/CardNameBackground/CardName" method="set_tooltip"]
Expand All @@ -235,13 +226,7 @@ volume = -15.0
[connection signal="show_card" from="." to="CardContentGroup" method="show_card_content"]
[connection signal="show_card" from="." to="CardBack" method="toggle_off"]
[connection signal="ready_for_destruction" from="CardContentGroup" to="." method="destory_now"]
[connection signal="focus_lost" from="CardBack" to="CardContentGroup/DropShadow" method="lost_focus"]
[connection signal="fully_hidden" from="CardBack" to="." method="signal_repeater_fully_hidden"]
[connection signal="fully_hidden" from="CardBack" to="CardContentGroup" method="hide_card_content"]
[connection signal="fully_shown" from="CardBack" to="." method="signal_repeater_fully_shown"]
[connection signal="hide_started" from="CardBack" to="CardContentGroup/DropShadow" method="lost_focus"]
[connection signal="in_focus" from="CardBack" to="CardContentGroup/DropShadow" method="got_focus"]
[connection signal="in_focus" from="CardBack" to="FocusEffect" method="trigger_random_effect"]
[connection signal="clicked" from="CardBack/Collider" to="." method="card_was_clicked"]
[connection signal="mouse_entered" from="CardBack/Collider" to="." method="selected_by_mouse"]
[connection signal="mouse_entered" from="CardBack/Collider" to="CardBack" method="is_focused"]
2 changes: 0 additions & 2 deletions entities/game/card_template/scripts/CardTemplate.gd
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func get_height() -> float:
func freeze_card() -> void:
if back_side == null:
return
back_side.freeze_card()
_card_frozen = true
lost_focus()

Expand All @@ -139,7 +138,6 @@ func unfreeze_card() -> void:
return
_was_clicked = false
_card_frozen = false
back_side.unfreeze_card()

func get_width() -> float:
return back_side.get_rect().size.x
Expand Down
24 changes: 1 addition & 23 deletions entities/game/card_template/scripts/ToggleCardVisibility.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ signal ready_for_removal()
signal fully_hidden()
signal fully_shown()
signal hide_started()
signal in_focus()
signal focus_lost()

enum VisibilityEnum
{
Expand All @@ -28,11 +26,10 @@ var _internal_focus_material: ShaderMaterial

var currently_in_focus: bool = false

var collider: Area2D
var removal_requested: bool = false
var can_remove: bool = false
var removal_planned: bool = false
var currently_ai: bool = false
#var currently_ai: bool = false

var animation_tween: Tween = null
var _focus_tween: Tween = null
Expand All @@ -42,7 +39,6 @@ var fix_image_thread: Thread
var visibility: VisibilityEnum = VisibilityEnum.HIDDEN

func _ready() -> void:
collider = %Collider
visible = true
_internal_focus_material = focus_material.duplicate_deep()
_internal_toggle_material = toggle_material.duplicate_deep()
Expand Down Expand Up @@ -88,14 +84,6 @@ func _animation_finished(should_hide: bool) -> void:
can_remove = true
print("shown")

func freeze_card() -> void:
collider.visible = false

func unfreeze_card() -> void:
if currently_ai:
return
collider.visible = true

# This method will show a fully hidden card
func toggle_off() -> void:
print("toggle off")
Expand Down Expand Up @@ -125,14 +113,11 @@ func is_focused() -> void:

currently_in_focus = true
set_shader_material(_internal_focus_material)
in_focus.emit()
_animate_focus(focus_scale)

func lost_focus() -> void:
currently_in_focus = false
set_shader_material(_internal_toggle_material)
if collider.visible:
focus_lost.emit()

_animate_focus(1.0)

Expand Down Expand Up @@ -162,10 +147,3 @@ func _process(_delta: float) -> void:
if removal_planned && can_remove:
ready_for_removal.emit()
queue_free()

func input_active(is_active: bool) -> void:
currently_ai = !is_active
if is_active:
unfreeze_card()
return
freeze_card()
Loading
Loading