fix mines
This commit is contained in:
@@ -4,17 +4,20 @@ extends Node2D
|
|||||||
@export var knockback_strength = 4
|
@export var knockback_strength = 4
|
||||||
|
|
||||||
func _on_area_entered(area: Area2D) -> void:
|
func _on_area_entered(area: Area2D) -> void:
|
||||||
|
print_debug("Mine triggered by area: %s" % area)
|
||||||
if self.get_parent().is_in_group("Virus"):
|
if self.get_parent().is_in_group("Virus"):
|
||||||
# Prevent friendly fire
|
# Prevent friendly fire
|
||||||
return
|
return
|
||||||
|
if area.name != "Hurtbox":
|
||||||
|
return
|
||||||
var area_parent = area.get_parent()
|
var area_parent = area.get_parent()
|
||||||
if (area_parent.is_in_group("Virus")):
|
if (area_parent.is_in_group("Virus")):
|
||||||
area_parent.take_hit(damage, self.position.direction_to(area.position) * 50, knockback_strength)
|
area_parent.take_hit(damage, self.position.direction_to(area.position) * 200, knockback_strength)
|
||||||
|
|
||||||
func _on_body_entered(body):
|
func _on_body_entered(body):
|
||||||
if self.get_parent() == body:
|
if self.get_parent() == body:
|
||||||
return
|
return
|
||||||
body.take_hit(damage, self.position.direction_to(body.position) * 50, knockback_strength)
|
body.take_hit(damage, self.position.direction_to(body.position) * 200, knockback_strength)
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout():
|
func _on_timer_timeout():
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://umv7m1lf4x6b"]
|
[gd_scene load_steps=6 format=3 uid="uid://umv7m1lf4x6b"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b3jims0gq4tg5" path="res://CardInjects/Mine/mine.gd" id="1_mj2xh"]
|
[ext_resource type="Script" uid="uid://b3jims0gq4tg5" path="res://CardInjects/Mine/mine.gd" id="1_mj2xh"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dmq8shsoq55dx" path="res://assets/icons/Mine_symbol.png" id="2_80s1i"]
|
[ext_resource type="Texture2D" uid="uid://dmq8shsoq55dx" path="res://assets/icons/Mine_symbol.png" id="2_80s1i"]
|
||||||
@@ -23,6 +23,9 @@ void fragment() {
|
|||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_56tnn"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_56tnn"]
|
||||||
shader = SubResource("Shader_80s1i")
|
shader = SubResource("Shader_80s1i")
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_80s1i"]
|
||||||
|
radius = 135
|
||||||
|
|
||||||
[node name="Mine" type="Node2D"]
|
[node name="Mine" type="Node2D"]
|
||||||
script = ExtResource("1_mj2xh")
|
script = ExtResource("1_mj2xh")
|
||||||
|
|
||||||
@@ -33,9 +36,12 @@ texture = ExtResource("2_80s1i")
|
|||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
shape = SubResource("CircleShape2D_80s1i")
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="Area2D" to="." method="_on_area_entered"]
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
|||||||
Reference in New Issue
Block a user