wip: refactoring casrd board
This commit is contained in:
parent
f962cdfe7a
commit
6824a75e29
|
|
@ -182,18 +182,13 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
# Logic for attaching a postit to a card. Also reset postit positions if the card cannot be attached
|
||||
func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
|
||||
|
||||
if postit.is_in_group(card.name):
|
||||
|
||||
if card.has_postit_attached():
|
||||
if active_context == ui_context.ASSIGN_POST_IT:
|
||||
_return_postit_to_panels(postit) # don't attach if card has already a post-it attached
|
||||
return
|
||||
|
||||
postit.reparent(card.get_child(3, true))
|
||||
postit.position = Vector2(0,0)
|
||||
postit.on_board = false
|
||||
|
||||
postit.set_owner(self)
|
||||
postit.position = card.get_child(3).position
|
||||
|
||||
if update_dict:
|
||||
area_dict["post_its_in_list"].erase(postit)
|
||||
|
|
@ -210,6 +205,13 @@ func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
|
|||
return
|
||||
emit_signal("board_completed")
|
||||
|
||||
func is_board_lore() -> bool:
|
||||
for post_it in area_dict["dropzone_content"]:
|
||||
if post_it is PostIt:
|
||||
var card = post_it.get_parent().get_parent()
|
||||
if not post_it.is_in_group(card.name): return false
|
||||
return true
|
||||
|
||||
# Mark area that was hovered over as currently selected
|
||||
func handle_hover(to_handle: Area2D):
|
||||
if to_handle != currently_selected_node:
|
||||
|
|
@ -347,7 +349,7 @@ func _enter_assignment_context():
|
|||
|
||||
# move the post it so it floats next to the card where it should be attached
|
||||
func _select_card_for_assigning(post_it: Area2D, card: Area2D):
|
||||
post_it.tween_transform_to(card.get_child(3).global_position + Vector2(0, 50))
|
||||
post_it.tween_transform_to(card.get_child(3).global_position)
|
||||
|
||||
# leaves the context for assigning postit via button controls
|
||||
func _leave_assignment_context():
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ extends Area2D
|
|||
class_name Card
|
||||
var compatible_postits: Array[PostIt] = []
|
||||
var own_postits: Array[PostIt] = []
|
||||
var current_post_it: PostIt = null
|
||||
var is_in_preview: bool = false:
|
||||
set(preview):
|
||||
is_in_preview = preview
|
||||
highlighted = preview
|
||||
var wiggle_pos: float = 0
|
||||
var wiggle_intensity: float = 0
|
||||
var noise: Noise = FastNoiseLite.new()
|
||||
|
|
@ -152,7 +157,28 @@ func _move_card():
|
|||
position += (get_viewport().get_mouse_position() - position) - mouse_offset
|
||||
|
||||
func has_postit_attached() -> bool:
|
||||
return postit_anchor.get_child(-1) is PostIt
|
||||
return is_instance_valid(current_post_it) and not is_in_preview
|
||||
|
||||
func preview_postit(postit: PostIt) -> bool:
|
||||
is_in_preview = attach_postit(postit)
|
||||
return is_in_preview
|
||||
|
||||
func attach_postit(postit: PostIt) -> bool:
|
||||
if is_instance_valid(current_post_it):
|
||||
return false
|
||||
postit.reparent(get_child(3, true))
|
||||
postit.position = Vector2(0,0)
|
||||
postit.on_board = false
|
||||
if not is_in_preview: current_post_it = postit
|
||||
return true
|
||||
|
||||
func remove_postit() -> PostIt:
|
||||
var former_child:PostIt = current_post_it
|
||||
current_post_it = null
|
||||
former_child.reparent(get_parent())
|
||||
former_child.on_board = true
|
||||
is_in_preview = false
|
||||
return former_child
|
||||
|
||||
func check_hover():
|
||||
if is_mouse_entered:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ theme_type_variation = &"card_text"
|
|||
autowrap_mode = 3
|
||||
|
||||
[node name="postit anchor" type="Node2D" parent="."]
|
||||
position = Vector2(0, 21)
|
||||
position = Vector2(-66, 83)
|
||||
|
||||
[connection signal="input_event" from="." to="." method="_on_input_event"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://bnskiyx1sksww"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bnskiyx1sksww"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bi3xqdknw5tpe" path="res://logic-scenes/board/board-texture/Cork002_2K_Color.png" id="1_8brxc"]
|
||||
[ext_resource type="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"]
|
||||
[ext_resource type="Script" path="res://logic-scenes/board/card-board.gd" id="3_8v4c4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="3_mg053"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvowj4l8dtceu" path="res://dev-util/board of devs.tscn" id="4_sskx2"]
|
||||
[ext_resource type="PackedScene" path="res://logic-scenes/board/empty_postIt_panel.tscn" id="5_dr0qs"]
|
||||
[ext_resource type="Script" path="res://logic-scenes/board/card collider.gd" id="6_wpxls"]
|
||||
|
|
@ -41,20 +40,6 @@ layout_mode = 2
|
|||
size_flags_horizontal = 3
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="card3" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")]
|
||||
process_mode = 4
|
||||
visible = false
|
||||
z_as_relative = false
|
||||
position = Vector2(371, 290)
|
||||
collision_layer = 2147483649
|
||||
is_dragable = true
|
||||
|
||||
[node name="card" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")]
|
||||
process_mode = 4
|
||||
visible = false
|
||||
position = Vector2(640, 659)
|
||||
is_dragable = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue