Add cut hurt mechanic
This commit is contained in:
parent
b38c56b904
commit
25b98a46f8
4 changed files with 167 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="necra-prototypes"
|
||||
run/main_scene="res://prototype_dark_cut.tscn"
|
||||
config/features=PackedStringArray("4.3", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
|
|
|||
7
prototype_dark_cut.gd
Normal file
7
prototype_dark_cut.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
extends Node
|
||||
|
||||
|
||||
|
||||
func _on_patience_bar_value_changed(value):
|
||||
if value <= 0:
|
||||
get_tree().reload_current_scene()
|
||||
|
|
@ -1,11 +1,69 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://be0rqt7sk1da0"]
|
||||
[gd_scene load_steps=11 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"]
|
||||
[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"]
|
||||
|
||||
[node name="PrototypeDarkCut" type="Node2D"]
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pgu75"]
|
||||
bg_color = Color(0.417457, 0, 0.105249, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m114t"]
|
||||
size = Vector2(325.047, 551.953)
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jndi4"]
|
||||
radius = 14.3435
|
||||
height = 142.904
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_qmwrh"]
|
||||
radius = 5.65684
|
||||
|
||||
[node name="PrototypeDarkCut" type="Node"]
|
||||
script = ExtResource("1_vl0qk")
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 1.0
|
||||
offset_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="UI"]
|
||||
layout_mode = 0
|
||||
offset_left = 15.0
|
||||
offset_top = 13.0
|
||||
offset_right = 281.0
|
||||
offset_bottom = 57.0
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Label" type="Label" parent="UI/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Patience:"
|
||||
|
||||
[node name="PatienceBar" type="ProgressBar" parent="UI/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_pgu75")
|
||||
value = 100.0
|
||||
|
||||
[node name="UtilsDropoff" type="Sprite2D" parent="."]
|
||||
position = Vector2(1020.25, 43)
|
||||
scale = Vector2(0.761429, 0.14494)
|
||||
texture = ExtResource("1_7i8d4")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="UtilsDropoff"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="UtilsDropoff/Area2D"]
|
||||
scale = Vector2(1, 1)
|
||||
shape = SubResource("RectangleShape2D_m114t")
|
||||
|
||||
[node name="TestTable" type="Sprite2D" parent="."]
|
||||
position = Vector2(613, 358)
|
||||
|
|
@ -15,11 +73,33 @@ texture = ExtResource("1_7i8d4")
|
|||
position = Vector2(620, 399)
|
||||
texture = ExtResource("2_atjyl")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="TestBody1"]
|
||||
|
||||
[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="TestScalpel" type="Sprite2D" parent="."]
|
||||
position = Vector2(685, 288)
|
||||
position = Vector2(949, 41)
|
||||
rotation = -2.0542
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("3_a4jra")
|
||||
script = ExtResource("4_5ba3g")
|
||||
|
||||
[node name="PickupArea" type="Area2D" parent="TestScalpel"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestScalpel/PickupArea"]
|
||||
scale = Vector2(1, 1)
|
||||
shape = SubResource("CapsuleShape2D_jndi4")
|
||||
|
||||
[node name="CutArea" type="Area2D" parent="TestScalpel"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestScalpel/CutArea"]
|
||||
position = Vector2(9.33812, -65.1214)
|
||||
shape = SubResource("CircleShape2D_qmwrh")
|
||||
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="."]
|
||||
|
||||
|
|
@ -102,3 +182,10 @@ texture = ExtResource("4_frsoy")
|
|||
position = Vector2(666, 318)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("4_frsoy")
|
||||
|
||||
[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"]
|
||||
[connection signal="area_entered" from="TestBody1/Area2D" to="TestScalpel" method="_on_body_area_entered"]
|
||||
[connection signal="area_exited" from="TestBody1/Area2D" to="TestScalpel" method="_on_body_area_exited"]
|
||||
[connection signal="timeout" from="TestScalpel/CutHurtTimer" to="TestScalpel" method="_on_cut_hurt_timer_timeout"]
|
||||
|
|
|
|||
69
test_scalpel.gd
Normal file
69
test_scalpel.gd
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
extends Sprite2D
|
||||
|
||||
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
|
||||
|
||||
func _ready():
|
||||
pickup_area.connect("mouse_entered", func(): is_clickable = true)
|
||||
pickup_area.connect("mouse_exited", func(): is_clickable = false)
|
||||
|
||||
func _input(event: InputEvent):
|
||||
if event is InputEventMouseButton and event.is_pressed():
|
||||
if is_picked_up:
|
||||
if is_dropable:
|
||||
is_picked_up = false
|
||||
elif is_cutting_possible:
|
||||
start_cutting()
|
||||
elif is_clickable:
|
||||
is_picked_up = true
|
||||
elif event is InputEventMouseButton and event.is_released():
|
||||
if is_cutting:
|
||||
stop_cutting()
|
||||
if is_picked_up and event is InputEventMouseMotion:
|
||||
global_position = event.global_position
|
||||
|
||||
|
||||
func _on_dropoff_area_entered(area):
|
||||
if area != pickup_area: return
|
||||
is_dropable = true
|
||||
|
||||
|
||||
func _on_dropoff_area_exited(area):
|
||||
if area != pickup_area: return
|
||||
is_dropable = false
|
||||
|
||||
|
||||
func _on_body_area_entered(area):
|
||||
if area != cut_area: return
|
||||
is_cutting_possible = true
|
||||
|
||||
|
||||
func _on_body_area_exited(area):
|
||||
if area != cut_area: return
|
||||
is_cutting_possible = false
|
||||
stop_cutting()
|
||||
|
||||
func start_cutting():
|
||||
if is_cutting: return
|
||||
print("Start cut")
|
||||
_on_cut_hurt_timer_timeout()
|
||||
%CutHurtTimer.start(1)
|
||||
is_cutting = true
|
||||
|
||||
func stop_cutting():
|
||||
if not is_cutting: return
|
||||
print("Stop cut")
|
||||
%CutHurtTimer.stop()
|
||||
is_cutting = false
|
||||
|
||||
|
||||
func _on_cut_hurt_timer_timeout():
|
||||
# TODO: Check if should hurt
|
||||
%PatienceBar.value = clampi(%PatienceBar.value - 5, 0, 100)
|
||||
print("Splatter")
|
||||
Loading…
Add table
Reference in a new issue