Add feedback for hurt
This commit is contained in:
parent
1759022dee
commit
c9956661d3
3 changed files with 24 additions and 1 deletions
15
feedback_canvas_modulate.gd
Normal file
15
feedback_canvas_modulate.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class_name FeedbackCanvasModulate
|
||||
extends CanvasModulate
|
||||
|
||||
|
||||
var is_tweening = false
|
||||
|
||||
func show_hurt_feedback():
|
||||
if is_tweening: return
|
||||
is_tweening = true
|
||||
var default_color = color
|
||||
var tween = create_tween()
|
||||
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)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://be0rqt7sk1da0"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://be0rqt7sk1da0"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bicjfwpoa3pma" path="res://test_table.png" id="1_7i8d4"]
|
||||
[ext_resource type="Script" path="res://prototype_dark_cut.gd" id="1_vl0qk"]
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
[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="Script" path="res://feedback_canvas_modulate.gd" id="9_4ghh6"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pgu75"]
|
||||
bg_color = Color(0.417457, 0, 0.105249, 1)
|
||||
|
|
@ -28,6 +29,7 @@ radius = 5.65684
|
|||
script = ExtResource("1_vl0qk")
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -298,6 +300,10 @@ connections = Array[NodePath]([NodePath("../TestStar_915")])
|
|||
[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")
|
||||
|
||||
[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"]
|
||||
[connection signal="area_exited" from="UtilsDropoff/Area2D" to="TestScalpel" method="_on_dropoff_area_exited"]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ var is_cutting = false
|
|||
|
||||
@onready var pickup_area = $PickupArea
|
||||
@onready var cut_area = $CutArea
|
||||
@onready var feedback_canvas_modulate: FeedbackCanvasModulate = %FeedbackCanvasModulate
|
||||
|
||||
func _ready():
|
||||
pickup_area.connect("mouse_entered", func(): is_clickable = true)
|
||||
|
|
@ -82,5 +83,6 @@ func stop_cutting():
|
|||
|
||||
func _on_cut_hurt_timer_timeout():
|
||||
# TODO: Check if should hurt
|
||||
feedback_canvas_modulate.show_hurt_feedback()
|
||||
%PatienceBar.value = clampi(%PatienceBar.value - 5, 0, 100)
|
||||
print("Splatter")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue