Added more flexible player damage from enemies and cleaned up some code
This commit is contained in:
@@ -17,6 +17,7 @@ height = 2.0
|
||||
radius = 50.0
|
||||
|
||||
[node name="Chasing Glowing Ghost" type="KinematicBody2D" groups=["enemy"]]
|
||||
light_mask = 0
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
script = ExtResource( 4 )
|
||||
@@ -29,19 +30,23 @@ offset = Vector2( 0, 0.5 )
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox_1"]]
|
||||
light_mask = 0
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
position = Vector2( 0, -2.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Player Detector" type="Area2D" parent="."]
|
||||
light_mask = 0
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
@@ -49,11 +54,12 @@ monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Detector"]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Light" type="Light2D" parent="."]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
texture = ExtResource( 2 )
|
||||
texture_scale = 0.5
|
||||
color = Color( 0.984314, 0.94902, 0.211765, 0.392157 )
|
||||
energy = 2.0
|
||||
range_item_cull_mask = 11
|
||||
@@ -63,6 +69,7 @@ scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 2 )
|
||||
offset = Vector2( 5, -35 )
|
||||
range_item_cull_mask = 4
|
||||
shadow_item_cull_mask = 0
|
||||
|
||||
[node name="Occluder" type="LightOccluder2D" parent="."]
|
||||
show_behind_parent = true
|
||||
|
@@ -18,6 +18,7 @@ height = 2.0
|
||||
radius = 60.0
|
||||
|
||||
[node name="Creepy Glowing Ghost" type="KinematicBody2D" groups=["enemy"]]
|
||||
light_mask = 0
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
script = ExtResource( 4 )
|
||||
@@ -35,7 +36,8 @@ light_mask = 0
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox_1"]]
|
||||
light_mask = 0
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
|
||||
@@ -46,6 +48,7 @@ position = Vector2( 0, -2.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Player Detector" type="Area2D" parent="."]
|
||||
light_mask = 0
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
@@ -57,8 +60,8 @@ light_mask = 0
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Light" type="Light2D" parent="."]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
texture = ExtResource( 2 )
|
||||
texture_scale = 0.5
|
||||
color = Color( 0.698039, 0.211765, 0.984314, 0.392157 )
|
||||
energy = 2.0
|
||||
range_item_cull_mask = 11
|
||||
@@ -68,6 +71,7 @@ scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 2 )
|
||||
offset = Vector2( 5, -35 )
|
||||
range_item_cull_mask = 4
|
||||
shadow_item_cull_mask = 0
|
||||
|
||||
[node name="Occluder" type="LightOccluder2D" parent="."]
|
||||
show_behind_parent = true
|
||||
|
@@ -7,7 +7,7 @@
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 12.0
|
||||
|
||||
[node name="Creepy Hand" type="Area2D" groups=["enemy_hitbox"]]
|
||||
[node name="Creepy Hand" type="Area2D" groups=["enemy_projectile_1"]]
|
||||
light_mask = 0
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
collision_layer = 0
|
||||
|
@@ -5,8 +5,8 @@ export var relative_x_tiles: int
|
||||
export var relative_y_tiles: int
|
||||
|
||||
|
||||
func _on_spawn_trap_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
func _on_spawn_trap_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
set_deferred('monitoring', false)
|
||||
|
||||
var enemy: KinematicBody2D = load(enemy_path).instance()
|
||||
|
@@ -14,7 +14,8 @@ monitorable = false
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Tile" type="CollisionShape2D" parent="."]
|
||||
light_mask = 0
|
||||
position = Vector2( 8, 8 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="_on_spawn_trap_area_entered"]
|
||||
[connection signal="body_entered" from="." to="." method="_on_spawn_trap_body_entered"]
|
||||
|
1
Main.gd
1
Main.gd
@@ -68,7 +68,6 @@ func level_select_menu_option(option: String) -> void:
|
||||
|
||||
func free_connected_node(node: Node, connected_function: String) -> void:
|
||||
node.disconnect('complete', self, connected_function)
|
||||
remove_child(node)
|
||||
node.queue_free()
|
||||
return
|
||||
|
||||
|
@@ -65,11 +65,21 @@ func _on_Inventory_update_currency(amount: int) -> void:
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if not 'enemy_hitbox' in area.get_groups():
|
||||
var hit: int = 0
|
||||
|
||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||
hit = 1
|
||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
else:
|
||||
return
|
||||
|
||||
if health_index != 0:
|
||||
health_index -= 1
|
||||
health_index -= hit
|
||||
if health_index < 0:
|
||||
health_index = 0
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
return
|
||||
|
||||
|
Reference in New Issue
Block a user