diff --git a/cut_sequence.gd b/cut_sequence.gd new file mode 100644 index 0000000..f5cb364 --- /dev/null +++ b/cut_sequence.gd @@ -0,0 +1,50 @@ +class_name CutSequence +extends Node2D + +signal sequence_failed +signal sequence_succeeded + +var cut_sequence_points: Array[CutSequencePoint] = [] +func _ready(): + _build_sequence() + + +func _build_sequence(): + for c in get_children(): + if c is CutSequencePoint: + c.point_cut.connect(_trigger_point_cut.bind(c)) + cut_sequence_points.push_back(c) + + +var cut_indices: Array[int] = [] +func _trigger_point_cut(point: CutSequencePoint): + var cut_index = cut_sequence_points.find(point) + var is_cut_valid = false + if cut_indices.is_empty(): + is_cut_valid = cut_index == 0 or cut_index == cut_sequence_points.size() - 1 + if not is_cut_valid: + print("Failed cut: Expected %i or %i as first point, but got %i." % [0, cut_sequence_points.size() - 1, cut_index]) + else: + var direction = -1 if cut_indices[0] == 0 else 1 + is_cut_valid = cut_index + direction == cut_indices[-1] # Expect the next index + if not is_cut_valid: + print("Failed cut: Expected %i as next point, but got %i." % [cut_indices[-1] - direction, cut_index]) + + if not is_cut_valid: + _fail_sequence() + return + + point.confirm_cut() + cut_indices.push_back(cut_index) + if cut_indices.size() == cut_sequence_points.size(): + _succeed_sequence() + +func _fail_sequence(): + print("Fail cut sequence") + for i in cut_indices: + cut_sequence_points[i].reset_cut() + cut_indices.clear() + sequence_failed.emit() + +func _succeed_sequence(): + sequence_succeeded.emit() diff --git a/cut_sequence_point.gd b/cut_sequence_point.gd new file mode 100644 index 0000000..f86627f --- /dev/null +++ b/cut_sequence_point.gd @@ -0,0 +1,20 @@ +class_name CutSequencePoint +extends Sprite2D + +signal point_cut + +var scalpel: Scalpel +func _ready(): + scalpel = get_tree().get_first_node_in_group("cutter") + +func _on_area_2d_area_entered(area): + if area != scalpel.cut_area or not scalpel.is_cutting: return + point_cut.emit() + +func confirm_cut(): + visible = false + $Area2D.set_deferred("monitoring", false) + +func reset_cut(): + visible = true + $Area2D.set_deferred("monitoring", true) diff --git a/cut_sequence_point.tscn b/cut_sequence_point.tscn new file mode 100644 index 0000000..9e3effd --- /dev/null +++ b/cut_sequence_point.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=3 uid="uid://x5powiwrfash"] + +[ext_resource type="Texture2D" uid="uid://gf7us6an3mhu" path="res://test_star.png" id="1_o3e76"] +[ext_resource type="Script" path="res://cut_sequence_point.gd" id="2_um6ol"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_e2fuh"] +radius = 8.24621 + +[node name="CutSequencePoint" type="Sprite2D"] +scale = Vector2(0.5, 0.5) +texture = ExtResource("1_o3e76") +script = ExtResource("2_um6ol") + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2(0, 2) +shape = SubResource("CircleShape2D_e2fuh") + +[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] diff --git a/feedback_canvas_modulate.gd b/feedback_canvas_modulate.gd index 85f5647..86e0f06 100644 --- a/feedback_canvas_modulate.gd +++ b/feedback_canvas_modulate.gd @@ -12,4 +12,3 @@ func show_hurt_feedback(): tween.tween_property(self, "color", Color(1.0,0,0, .2), .1) tween.tween_property(self, "color", default_color, .3) tween.tween_callback(func(): is_tweening = false) - diff --git a/guideline_point.gd b/guideline_point.gd deleted file mode 100644 index 44b9b67..0000000 --- a/guideline_point.gd +++ /dev/null @@ -1,18 +0,0 @@ -class_name GuidelinePoint -extends Sprite2D - -@export_node_path("Node2D") var connections: Array[NodePath] = [] - -@onready var area = $Area2D - -var scalpel: Scalpel - -func _ready(): - area.connect("area_exited", _on_area_entered) - scalpel = get_tree().get_first_node_in_group("cutter") - - -func _on_area_entered(area: Area2D): - if area != scalpel.cut_area or not scalpel.is_cutting: return - queue_free() - diff --git a/guidelines.gd b/guidelines.gd deleted file mode 100644 index d325e77..0000000 --- a/guidelines.gd +++ /dev/null @@ -1,13 +0,0 @@ -extends Node2D - -class Connection: - var source: NodePath - var targets: Array[NodePath] - -var guideline_points: Array[Node] - -func _ready(): - guideline_points = get_children().filter(func(c): return c is GuidelinePoint) - -func _process(delta): - if get_child_count() == 0: get_parent().operation_succeeded() diff --git a/operation.gd b/operation.gd new file mode 100644 index 0000000..a113b64 --- /dev/null +++ b/operation.gd @@ -0,0 +1,42 @@ +class_name Operation +extends Node + +var steps: Array[Node2D] = [] +var active_step: Node2D = null + +func _ready(): + var children = get_children() + for child in children: + if child is Node2D: + steps.push_back(child) + if child is CutSequence: + child.sequence_succeeded.connect(_on_cut_sequence_succeeded.bind(child)) + child.sequence_failed.connect(_on_cut_sequence_failed.bind(child)) + _disable_node2d(child) + + active_step = steps[0] + _enable_node2d(active_step) + + +func _on_cut_sequence_succeeded(cut_sequence: CutSequence): + _disable_node2d(active_step) + var next_index = steps.find(cut_sequence) + 1 + if next_index == 4: + _enable_node2d(%TestBody2) + _disable_node2d(%TestBody1) + + active_step = steps[next_index] + _enable_node2d(active_step) + + +func _on_cut_sequence_failed(cut_sequence: CutSequence): + pass + +func _enable_node2d(node: Node2D): + node.set_deferred("visible", true) + node.set_deferred("process_mode", Node.PROCESS_MODE_INHERIT) + + +func _disable_node2d(node: Node2D): + node.set_deferred("visible", false) + node.set_deferred("process_mode", Node.PROCESS_MODE_DISABLED) diff --git a/project.godot b/project.godot index 21fc49d..474fddd 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,12 @@ config/icon="res://icon.svg" window/stretch/mode="viewport" +[layer_names] + +2d_physics/layer_1="Operation" +2d_physics/layer_2="Pickup" +2d_physics/layer_3="Body" + [rendering] renderer/rendering_method="gl_compatibility" diff --git a/prototype_dark_cut.tscn b/prototype_dark_cut.tscn index cbf876c..fb30211 100644 --- a/prototype_dark_cut.tscn +++ b/prototype_dark_cut.tscn @@ -5,10 +5,11 @@ [ext_resource type="Texture2D" uid="uid://bp10w3bh1gn14" path="res://test_body_1.png" id="2_atjyl"] [ext_resource type="Texture2D" uid="uid://cg3dg7iqif56d" path="res://test_scalpel.png" id="3_a4jra"] [ext_resource type="Script" path="res://test_scalpel.gd" id="4_5ba3g"] -[ext_resource type="Texture2D" uid="uid://gf7us6an3mhu" path="res://test_star.png" id="4_frsoy"] -[ext_resource type="Script" path="res://guidelines.gd" id="6_0fd2w"] -[ext_resource type="Script" path="res://guideline_point.gd" id="8_5qgyw"] +[ext_resource type="Texture2D" uid="uid://b82j8773uke65" path="res://test_body_2.png" id="5_piyi3"] +[ext_resource type="Script" path="res://operation.gd" id="7_mteqj"] [ext_resource type="Script" path="res://feedback_canvas_modulate.gd" id="9_4ghh6"] +[ext_resource type="Script" path="res://cut_sequence.gd" id="10_gcaa6"] +[ext_resource type="PackedScene" uid="uid://x5powiwrfash" path="res://cut_sequence_point.tscn" id="11_hcsao"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pgu75"] bg_color = Color(0.417457, 0, 0.105249, 1) @@ -23,8 +24,6 @@ height = 142.904 [sub_resource type="CircleShape2D" id="CircleShape2D_qmwrh"] radius = 5.65684 -[sub_resource type="CircleShape2D" id="CircleShape2D_0bwgd"] - [node name="PrototypeDarkCut" type="Node"] script = ExtResource("1_vl0qk") @@ -60,6 +59,10 @@ size_flags_vertical = 4 theme_override_styles/fill = SubResource("StyleBoxFlat_pgu75") value = 100.0 +[node name="FeedbackCanvasModulate" type="CanvasModulate" parent="."] +unique_name_in_owner = true +script = ExtResource("9_4ghh6") + [node name="UtilsDropoff" type="Sprite2D" parent="."] position = Vector2(1020.25, 43) scale = Vector2(0.761429, 0.14494) @@ -75,14 +78,22 @@ position = Vector2(613, 358) texture = ExtResource("1_7i8d4") [node name="TestBody1" type="Sprite2D" parent="."] +unique_name_in_owner = true position = Vector2(620, 399) texture = ExtResource("2_atjyl") [node name="Area2D" type="Area2D" parent="TestBody1"] +collision_layer = 4 +collision_mask = 4 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="TestBody1/Area2D"] polygon = PackedVector2Array(0, -250, -39.2, -250, -45.6, -246, -48.9, -246, -54.9, -239, -56.2, -239, -61.1, -230, -62.6, -230, -67.5, -210, -69, -210, -69, -181.7, -65, -168, -65, -163.3, -49, -143, -47, -128.8, -47, -124.8, -63.3, -122, -67.3, -122, -102.9, -109.8, -113.5, -116, -124.4, -116, -148.3, -106, -150, -106, -150, 49.2, -146, 67.4, -146, 71.4, -138, 93.4, -138, 99.7, -132, 106.7, -132, 109, -115.2, 109, -108.2, 102, -106.5, 102, -101.5, 86, -100, 86, -99, 35, -99, 16.8, -96.5, 26, -96, 93, -100, 140.9, -100, 163.1, -95.7, 192, -94.9, 192, -91, 246.1, -91, 250, 61, 250, 61, 236.5, 58, 230.5, 58, 217.1, 68, 38.1, 68, 64.3, 74, 82.3, 74, 85, 82, 91, 82, 92.8, 93, 93.8, 93, 95, 109.8, 95, 117.7, 88, 119.8, 88, 128.8, 9, 129.9, 9, 131.9, -42, 133.1, -42, 132, -84, 132, -90.7, 121, -103.8, 121, -105.6, 113, -107.6, 113, -109.2, 90.1, -107.1, 87, -112.5, 87, -114.9, 75, -125, 75, -127.2, 44.8, -124, 31.2, -124, 33, -144.9, 33, -151.3, 48.9, -169, 50.4, -169, 54.4, -179, 56, -179, 56, -200.6, 43, -219.7, 43, -222, 30, -232, 30, -233.2, 0, -248.3) +[node name="TestBody2" type="Sprite2D" parent="."] +unique_name_in_owner = true +position = Vector2(620, 399) +texture = ExtResource("5_piyi3") + [node name="TestScalpel" type="Sprite2D" parent="." groups=["cutter"]] position = Vector2(949, 41) rotation = -2.0542 @@ -91,11 +102,15 @@ texture = ExtResource("3_a4jra") script = ExtResource("4_5ba3g") [node name="PickupArea" type="Area2D" parent="TestScalpel"] +collision_layer = 2 +collision_mask = 2 [node name="CollisionShape2D" type="CollisionShape2D" parent="TestScalpel/PickupArea"] shape = SubResource("CapsuleShape2D_jndi4") [node name="CutArea" type="Area2D" parent="TestScalpel"] +collision_layer = 5 +collision_mask = 5 [node name="CollisionShape2D" type="CollisionShape2D" parent="TestScalpel/CutArea"] position = Vector2(9.33812, -65.1214) @@ -105,204 +120,76 @@ debug_color = Color(0.879882, 0.304191, 0.394852, 0.42) [node name="CutHurtTimer" type="Timer" parent="TestScalpel"] unique_name_in_owner = true -[node name="Guidelines" type="Node2D" parent="."] -script = ExtResource("6_0fd2w") +[node name="Operation" type="Node" parent="."] +script = ExtResource("7_mteqj") -[node name="TestStar_1" type="Sprite2D" parent="Guidelines"] -position = Vector2(557, 313) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_2")]) +[node name="CutSequence" type="Node2D" parent="Operation"] +script = ExtResource("10_gcaa6") -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_1"] +[node name="CutSequencePoint" parent="Operation/CutSequence" instance=ExtResource("11_hcsao")] +position = Vector2(558, 316) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_1/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint2" parent="Operation/CutSequence" instance=ExtResource("11_hcsao")] +position = Vector2(584, 321) -[node name="TestStar_2" type="Sprite2D" parent="Guidelines"] -position = Vector2(574, 318) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_1"), NodePath("../TestStar_3")]) +[node name="CutSequencePoint3" parent="Operation/CutSequence" instance=ExtResource("11_hcsao")] +position = Vector2(614, 326) -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_2"] +[node name="CutSequencePoint4" parent="Operation/CutSequence" instance=ExtResource("11_hcsao")] +position = Vector2(644, 318) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_2/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint5" parent="Operation/CutSequence" instance=ExtResource("11_hcsao")] +position = Vector2(668, 311) -[node name="TestStar_3" type="Sprite2D" parent="Guidelines"] -position = Vector2(593, 323) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_2"), NodePath("../TestStar_4")]) +[node name="CutSequence2" type="Node2D" parent="Operation"] +position = Vector2(-4, 69) +script = ExtResource("10_gcaa6") -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_3"] +[node name="CutSequencePoint" parent="Operation/CutSequence2" instance=ExtResource("11_hcsao")] +position = Vector2(618, 257) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_3/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint2" parent="Operation/CutSequence2" instance=ExtResource("11_hcsao")] +position = Vector2(615, 285) -[node name="TestStar_4" type="Sprite2D" parent="Guidelines"] -position = Vector2(609, 324) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_3"), NodePath("../TestStar_5"), NodePath("../TestStar_8")]) +[node name="CutSequencePoint3" parent="Operation/CutSequence2" instance=ExtResource("11_hcsao")] +position = Vector2(615, 310) -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_4"] +[node name="CutSequencePoint4" parent="Operation/CutSequence2" instance=ExtResource("11_hcsao")] +position = Vector2(615, 334) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_4/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequence3" type="Node2D" parent="Operation"] +position = Vector2(-4, 69) +script = ExtResource("10_gcaa6") -[node name="TestStar_5" type="Sprite2D" parent="Guidelines"] -position = Vector2(627, 324) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_4"), NodePath("../TestStar_6")]) +[node name="CutSequencePoint" parent="Operation/CutSequence3" instance=ExtResource("11_hcsao")] +position = Vector2(615, 334) -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_5"] +[node name="CutSequencePoint2" parent="Operation/CutSequence3" instance=ExtResource("11_hcsao")] +position = Vector2(598, 342) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_5/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint3" parent="Operation/CutSequence3" instance=ExtResource("11_hcsao")] +position = Vector2(580, 350) -[node name="TestStar_6" type="Sprite2D" parent="Guidelines"] -position = Vector2(647, 322) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_5"), NodePath("../TestStar_7")]) +[node name="CutSequencePoint4" parent="Operation/CutSequence3" instance=ExtResource("11_hcsao")] +position = Vector2(562, 355) -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_6"] +[node name="CutSequence4" type="Node2D" parent="Operation"] +position = Vector2(-4, 69) +script = ExtResource("10_gcaa6") -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_6/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint" parent="Operation/CutSequence4" instance=ExtResource("11_hcsao")] +position = Vector2(615, 334) -[node name="TestStar_7" type="Sprite2D" parent="Guidelines"] -position = Vector2(666, 318) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_6")]) +[node name="CutSequencePoint2" parent="Operation/CutSequence4" instance=ExtResource("11_hcsao")] +position = Vector2(628, 342) -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_7"] +[node name="CutSequencePoint3" parent="Operation/CutSequence4" instance=ExtResource("11_hcsao")] +position = Vector2(647, 353) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_7/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") +[node name="CutSequencePoint4" parent="Operation/CutSequence4" instance=ExtResource("11_hcsao")] +position = Vector2(665, 355) -[node name="TestStar_8" type="Sprite2D" parent="Guidelines"] -position = Vector2(609, 345) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_4"), NodePath("../TestStar_9")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_8"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_8/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_9" type="Sprite2D" parent="Guidelines"] -position = Vector2(608, 368) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_8"), NodePath("../TestStar_910")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_9"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_9/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_910" type="Sprite2D" parent="Guidelines"] -position = Vector2(609, 385) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_9"), NodePath("../TestStar_911"), NodePath("../TestStar_914")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_910"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_910/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_911" type="Sprite2D" parent="Guidelines"] -position = Vector2(594, 399) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_910"), NodePath("../TestStar_912")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_911"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_911/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_912" type="Sprite2D" parent="Guidelines"] -position = Vector2(572, 398) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_911"), NodePath("../TestStar_913")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_912"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_912/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_913" type="Sprite2D" parent="Guidelines"] -position = Vector2(552, 398) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_912")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_913"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_913/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_914" type="Sprite2D" parent="Guidelines"] -position = Vector2(626, 401) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_910"), NodePath("../TestStar_915")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_914"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_914/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar_915" type="Sprite2D" parent="Guidelines"] -position = Vector2(646, 402) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_914"), NodePath("../TestStar1_916")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar_915"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar_915/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="TestStar1_916" type="Sprite2D" parent="Guidelines"] -position = Vector2(666, 403) -scale = Vector2(0.5, 0.5) -texture = ExtResource("4_frsoy") -script = ExtResource("8_5qgyw") -connections = Array[NodePath]([NodePath("../TestStar_915")]) - -[node name="Area2D" type="Area2D" parent="Guidelines/TestStar1_916"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar1_916/Area2D"] -shape = SubResource("CircleShape2D_0bwgd") - -[node name="FeedbackCanvasModulate" type="CanvasModulate" parent="."] -unique_name_in_owner = true -script = ExtResource("9_4ghh6") +[node name="GrabBat" type="Node2D" parent="Operation"] [connection signal="value_changed" from="UI/HBoxContainer/PatienceBar" to="." method="_on_patience_bar_value_changed"] [connection signal="area_entered" from="UtilsDropoff/Area2D" to="TestScalpel" method="_on_dropoff_area_entered"] diff --git a/test_body_2.png b/test_body_2.png new file mode 100644 index 0000000..2abce5c Binary files /dev/null and b/test_body_2.png differ diff --git a/test_body_2.png.import b/test_body_2.png.import new file mode 100644 index 0000000..42e15d8 --- /dev/null +++ b/test_body_2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b82j8773uke65" +path="res://.godot/imported/test_body_2.png-d7075535262222be1c971d9545bf8b7c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://test_body_2.png" +dest_files=["res://.godot/imported/test_body_2.png-d7075535262222be1c971d9545bf8b7c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/test_scalpel.gd b/test_scalpel.gd index 5fc1e06..b7e162b 100644 --- a/test_scalpel.gd +++ b/test_scalpel.gd @@ -1,14 +1,17 @@ class_name Scalpel extends Sprite2D +signal cut_started +signal cut_ended + var is_clickable = false var is_picked_up = false var is_dropable = false var is_cutting_possible = false var is_cutting = false -@onready var pickup_area = $PickupArea -@onready var cut_area = $CutArea +@onready var pickup_area: Area2D = $PickupArea +@onready var cut_area: Area2D = $CutArea @onready var feedback_canvas_modulate: FeedbackCanvasModulate = %FeedbackCanvasModulate func _ready(): @@ -70,8 +73,9 @@ func start_cutting(): _scalpel_degrees_default = rotation_degrees rotation_degrees = SCALPEL_ROTATION_CUTTING _on_cut_hurt_timer_timeout() - %CutHurtTimer.start(1) + %CutHurtTimer.start(2) is_cutting = true + cut_started.emit() func stop_cutting(): if not is_cutting: return @@ -79,6 +83,7 @@ func stop_cutting(): rotation_degrees = _scalpel_degrees_default %CutHurtTimer.stop() is_cutting = false + cut_ended.emit() func _on_cut_hurt_timer_timeout():