mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-03 06:21:16 +00:00
Restored enemy bullets collision
This commit is contained in:
parent
076cff208d
commit
4e09694692
5 changed files with 34 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=9 format=3 uid="uid://v8s3kubgb2qg"]
|
[gd_scene load_steps=10 format=3 uid="uid://v8s3kubgb2qg"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://b4ynnb14mb4uq" path="res://Sprites/Reisen.png" id="1_4w8mj"]
|
[ext_resource type="Texture2D" uid="uid://b4ynnb14mb4uq" path="res://Sprites/Reisen.png" id="1_4w8mj"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Enemy.cs" id="1_lpwdj"]
|
[ext_resource type="Script" path="res://Scripts/Enemy.cs" id="1_lpwdj"]
|
||||||
|
|
@ -18,6 +18,9 @@ radius = 4.0
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_v711r"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_v711r"]
|
||||||
radius = 85.0529
|
radius = 85.0529
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m1rsg"]
|
||||||
|
size = Vector2(8, 12)
|
||||||
|
|
||||||
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("EquippedWeapon") groups=["Destroyable"]]
|
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("EquippedWeapon") groups=["Destroyable"]]
|
||||||
collision_layer = 16
|
collision_layer = 16
|
||||||
collision_mask = 9
|
collision_mask = 9
|
||||||
|
|
@ -34,6 +37,7 @@ visible = false
|
||||||
shape = SubResource("CircleShape2D_8gtts")
|
shape = SubResource("CircleShape2D_8gtts")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||||
|
collision_layer = 16
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
@ -64,6 +68,14 @@ path_postprocessing = 1
|
||||||
debug_enabled = true
|
debug_enabled = true
|
||||||
debug_path_custom_color = Color(1, 0, 0, 1)
|
debug_path_custom_color = Color(1, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="DamageHitbox" type="Area2D" parent="."]
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 9
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageHitbox"]
|
||||||
|
shape = SubResource("RectangleShape2D_m1rsg")
|
||||||
|
|
||||||
[connection signal="area_entered" from="PlayerDetection" to="." method="_on_player_detection_area_entered"]
|
[connection signal="area_entered" from="PlayerDetection" to="." method="_on_player_detection_area_entered"]
|
||||||
[connection signal="area_exited" from="PlayerDetection" to="." method="_on_player_detection_area_exited"]
|
[connection signal="area_exited" from="PlayerDetection" to="." method="_on_player_detection_area_exited"]
|
||||||
[connection signal="velocity_computed" from="NavigationAgent2D" to="." method="_on_navigation_agent_2d_velocity_computed"]
|
[connection signal="velocity_computed" from="NavigationAgent2D" to="." method="_on_navigation_agent_2d_velocity_computed"]
|
||||||
|
[connection signal="area_entered" from="DamageHitbox" to="." method="_on_damage_hitbox_area_entered"]
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ collision_layer = 8
|
||||||
collision_mask = 85
|
collision_mask = 85
|
||||||
script = ExtResource("1_jvxw3")
|
script = ExtResource("1_jvxw3")
|
||||||
Speed = 200.0
|
Speed = 200.0
|
||||||
|
Owner = 1
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ collision_layer = 128
|
||||||
collision_mask = 71
|
collision_mask = 71
|
||||||
script = ExtResource("1_s0j1e")
|
script = ExtResource("1_s0j1e")
|
||||||
Speed = 200.0
|
Speed = 200.0
|
||||||
|
Owner = 2
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ public partial class Bullet : Area2D
|
||||||
[Export]
|
[Export]
|
||||||
public float Damage = 1f;
|
public float Damage = 1f;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public BulletOwner Owner = BulletOwner.None;
|
||||||
|
|
||||||
private Vector2 _direction = Vector2.Right;
|
private Vector2 _direction = Vector2.Right;
|
||||||
|
|
||||||
//public delegate void BulletHitEventHandler(Node Body);
|
//public delegate void BulletHitEventHandler(Node Body);
|
||||||
|
|
@ -87,3 +90,10 @@ public partial class Bullet : Area2D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum BulletOwner
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Player,
|
||||||
|
Enemy
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using Godot;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
public partial class Enemy : CharacterBody2D, IDestructible
|
public partial class Enemy : CharacterBody2D
|
||||||
{
|
{
|
||||||
private InteractionController _cachedPlayer;
|
private InteractionController _cachedPlayer;
|
||||||
private EnemyState _currentState = EnemyState.Idle;
|
private EnemyState _currentState = EnemyState.Idle;
|
||||||
|
|
@ -191,6 +191,14 @@ public partial class Enemy : CharacterBody2D, IDestructible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _on_damage_hitbox_area_entered(Area2D area)
|
||||||
|
{
|
||||||
|
if (area is not Bullet bullet) return;
|
||||||
|
GD.Print("Enemy Received damage");
|
||||||
|
this.Hit(bullet.Damage);
|
||||||
|
bullet.QueueFree();
|
||||||
|
}
|
||||||
|
|
||||||
// Bullets collision
|
// Bullets collision
|
||||||
private void _on_area_entered(Area2D area)
|
private void _on_area_entered(Area2D area)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue