Collision layer rework
This commit is contained in:
parent
c428bf219d
commit
37d74f4880
6 changed files with 28 additions and 9 deletions
|
|
@ -53,8 +53,10 @@ primary_action={
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
2d_physics/layer_1="Reserved"
|
2d_physics/layer_1="Reserved"
|
||||||
2d_physics/layer_2="Plants"
|
2d_physics/layer_2="Plants LD"
|
||||||
2d_physics/layer_3="Zombies"
|
2d_physics/layer_3="Plants Full"
|
||||||
|
2d_physics/layer_4="Zombies LD"
|
||||||
|
2d_physics/layer_5="Zombies Full"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ position = Vector2(0, -44)
|
||||||
texture = ExtResource("2_4pdxh")
|
texture = ExtResource("2_4pdxh")
|
||||||
|
|
||||||
[node name="Hitbox" type="Area2D" parent="."]
|
[node name="Hitbox" type="Area2D" parent="."]
|
||||||
collision_layer = 4
|
collision_layer = 8
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ _sight = NodePath("../Eyesight")
|
||||||
|
|
||||||
[node name="Eyesight" type="Area2D" parent="."]
|
[node name="Eyesight" type="Area2D" parent="."]
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 4
|
collision_mask = 8
|
||||||
script = ExtResource("7_fdkt2")
|
script = ExtResource("7_fdkt2")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Eyesight"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Eyesight"]
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ disabled = true
|
||||||
|
|
||||||
[node name="Detectionbox" type="Area2D" parent="." index="3"]
|
[node name="Detectionbox" type="Area2D" parent="." index="3"]
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 4
|
collision_mask = 8
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"]
|
||||||
position = Vector2(0, 9)
|
position = Vector2(0, 9)
|
||||||
|
|
@ -131,7 +131,7 @@ shape = SubResource("CircleShape2D_v0g5b")
|
||||||
|
|
||||||
[node name="ExplosionBox" type="Area2D" parent="." index="4"]
|
[node name="ExplosionBox" type="Area2D" parent="." index="4"]
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 4
|
collision_mask = 8
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ExplosionBox" index="0"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="ExplosionBox" index="0"]
|
||||||
position = Vector2(0, 9)
|
position = Vector2(0, 9)
|
||||||
|
|
|
||||||
18
scenes/entities/plants/spikeweed.tscn
Normal file
18
scenes/entities/plants/spikeweed.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://bdhod5c6o53ha"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/entities/plants/plant_template.tscn" id="1_vmbvr"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://coafh3mjharxo" path="res://assets/sprites/atlases/plants/spikeweed.png" id="2_ffrjr"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"]
|
||||||
|
size = Vector2(49, 38)
|
||||||
|
|
||||||
|
[node name="Spikeweed" instance=ExtResource("1_vmbvr")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0"]
|
||||||
|
texture = ExtResource("2_ffrjr")
|
||||||
|
hframes = 2
|
||||||
|
vframes = 10
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
|
||||||
|
position = Vector2(0.5, 9)
|
||||||
|
shape = SubResource("RectangleShape2D_1di76")
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
public partial class ExplosionComponent : Node
|
public partial class ExplosionComponent : Area2D
|
||||||
{
|
{
|
||||||
[Export] private int damage;
|
[Export] private int damage;
|
||||||
[Export] private Area2D explosionArea;
|
|
||||||
|
|
||||||
public void Explode()
|
public void Explode()
|
||||||
{
|
{
|
||||||
foreach(var zombie in explosionArea.GetOverlappingAreas())
|
foreach(var zombie in GetOverlappingAreas())
|
||||||
{
|
{
|
||||||
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
||||||
if (zombieData != null)
|
if (zombieData != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue