Spikeweed
This commit is contained in:
parent
8f66b9e565
commit
b543631c86
5 changed files with 151 additions and 1 deletions
7
assets/sprites/plants/Spikeweed.tres
Normal file
7
assets/sprites/plants/Spikeweed.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://baqfahxkcvfe1"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_h51va"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
atlas = ExtResource("1_h51va")
|
||||||
|
region = Rect2(201, 37, 49, 22)
|
||||||
14
resources/plants/Spikeweed.tres
Normal file
14
resources/plants/Spikeweed.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_resource type="Resource" script_class="PlantResource" load_steps=4 format=3 uid="uid://cas11tg6chiu4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="1_0bymo"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://baqfahxkcvfe1" path="res://assets/sprites/plants/Spikeweed.tres" id="1_2ol2i"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bdhod5c6o53ha" path="res://scenes/entities/plants/spikeweed.tscn" id="2_iv8de"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_0bymo")
|
||||||
|
Cost = 100
|
||||||
|
Scene = ExtResource("2_iv8de")
|
||||||
|
ReloadTime = 5.0
|
||||||
|
StartReloadTime = 0.0
|
||||||
|
Preview = ExtResource("1_2ol2i")
|
||||||
|
Layer = 1
|
||||||
|
|
@ -1,7 +1,81 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bdhod5c6o53ha"]
|
[gd_scene load_steps=10 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="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"]
|
[ext_resource type="Texture2D" uid="uid://coafh3mjharxo" path="res://assets/sprites/atlases/plants/spikeweed.png" id="2_ffrjr"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/components/plants/AreaAttack.cs" id="3_hqtbm"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/components/plants/behaviours/SpikeweedBehaviour.cs" id="3_uhpn7"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_7bhr0"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_swkxy"]
|
||||||
|
resource_name = "attack"
|
||||||
|
length = 0.666675
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.0833333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.166667, 0.333333, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [3, 5, 7, 9]
|
||||||
|
}
|
||||||
|
tracks/1/type = "method"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Hitbox")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0.166667),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"values": [{
|
||||||
|
"args": [],
|
||||||
|
"method": &"Attack"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_h2f35"]
|
||||||
|
resource_name = "idle"
|
||||||
|
length = 2.50001
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.0833333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.166667, 0.333333, 0.5, 0.666667, 0.833333, 1, 2, 2.16667, 2.33333),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m4h7k"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_7bhr0"),
|
||||||
|
"attack": SubResource("Animation_swkxy"),
|
||||||
|
"idle": SubResource("Animation_h2f35")
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"]
|
||||||
size = Vector2(49, 38)
|
size = Vector2(49, 38)
|
||||||
|
|
@ -13,6 +87,25 @@ texture = ExtResource("2_ffrjr")
|
||||||
hframes = 2
|
hframes = 2
|
||||||
vframes = 10
|
vframes = 10
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" parent="." index="1"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_m4h7k")
|
||||||
|
}
|
||||||
|
autoplay = "idle"
|
||||||
|
|
||||||
|
[node name="Hitbox" parent="." index="2"]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 8
|
||||||
|
script = ExtResource("3_hqtbm")
|
||||||
|
_damage = 2
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
|
||||||
position = Vector2(0.5, 9)
|
position = Vector2(0.5, 9)
|
||||||
shape = SubResource("RectangleShape2D_1di76")
|
shape = SubResource("RectangleShape2D_1di76")
|
||||||
|
|
||||||
|
[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_player")]
|
||||||
|
script = ExtResource("3_uhpn7")
|
||||||
|
_player = NodePath("../AnimationPlayer")
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="Hitbox" to="Behaviour" method="OnHitboxEntered"]
|
||||||
|
[connection signal="area_exited" from="Hitbox" to="Behaviour" method="OnHitboxExited"]
|
||||||
|
|
|
||||||
16
scripts/components/plants/AreaAttack.cs
Normal file
16
scripts/components/plants/AreaAttack.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class AreaAttack : Area2D
|
||||||
|
{
|
||||||
|
[Export] private int _damage;
|
||||||
|
|
||||||
|
public void Attack()
|
||||||
|
{
|
||||||
|
foreach (var zombie in GetOverlappingAreas())
|
||||||
|
{
|
||||||
|
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
||||||
|
zombieData?.TakeDamage(_damage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
scripts/components/plants/behaviours/SpikeweedBehaviour.cs
Normal file
20
scripts/components/plants/behaviours/SpikeweedBehaviour.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class SpikeweedBehaviour : Node
|
||||||
|
{
|
||||||
|
[Export] private AnimationPlayer _player;
|
||||||
|
|
||||||
|
private int _inCount = 0;
|
||||||
|
public void OnHitboxEntered(Area2D _area)
|
||||||
|
{
|
||||||
|
if (_inCount++ == 0)
|
||||||
|
_player.Play("attack");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnHitboxExited(Area2D _area)
|
||||||
|
{
|
||||||
|
if (--_inCount == 0)
|
||||||
|
_player.Play("idle");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue