Potato mine
This commit is contained in:
parent
e2cc168b72
commit
c428bf219d
6 changed files with 245 additions and 0 deletions
7
assets/sprites/plants/potatomine.tres
Normal file
7
assets/sprites/plants/potatomine.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://bhmnt3x5aj1l8"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_qntd0"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_qntd0")
|
||||
region = Rect2(153, 17, 45, 42)
|
||||
14
resources/plants/PotatoMine.tres
Normal file
14
resources/plants/PotatoMine.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Resource" script_class="PlantResource" load_steps=4 format=3 uid="uid://bu25xgjd68gv8"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="1_33j6b"]
|
||||
[ext_resource type="Texture2D" uid="uid://bhmnt3x5aj1l8" path="res://assets/sprites/plants/potatomine.tres" id="1_xk2pg"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5x35v3w2u8dx" path="res://scenes/entities/plants/potato_mine.tscn" id="2_ig2ti"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_33j6b")
|
||||
Cost = 25
|
||||
Scene = ExtResource("2_ig2ti")
|
||||
ReloadTime = 25.0
|
||||
StartReloadTime = 0.0
|
||||
Preview = ExtResource("1_xk2pg")
|
||||
Layer = 1
|
||||
12
scenes/entities/plants/plant_template.tscn
Normal file
12
scenes/entities/plants/plant_template.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b1hjjbdwf1rtc"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/components/plants/RuntimePlantData.cs" id="1_324sd"]
|
||||
|
||||
[node name="PlantTemplate" type="Node2D"]
|
||||
script = ExtResource("1_324sd")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="."]
|
||||
163
scenes/entities/plants/potato_mine.tscn
Normal file
163
scenes/entities/plants/potato_mine.tscn
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://b5x35v3w2u8dx"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/entities/plants/plant_template.tscn" id="1_dj7ul"]
|
||||
[ext_resource type="Texture2D" uid="uid://c77o6ba0mw7a3" path="res://assets/sprites/atlases/plants/potato_mine.png" id="2_sneas"]
|
||||
[ext_resource type="Script" path="res://scripts/components/plants/ExplosionComponent.cs" id="3_2hd5y"]
|
||||
[ext_resource type="Script" path="res://scripts/components/plants/behaviours/PotatomineBehaviour.cs" id="4_twx65"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_lpsw3"]
|
||||
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": [1]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n8bxp"]
|
||||
resource_name = "idle_primed"
|
||||
length = 2.00001
|
||||
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.333333, 0.666667, 1, 1.33333, 1.66667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 3, 6, 9, 12, 15]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_vmabh"]
|
||||
resource_name = "idle_unprimed"
|
||||
length = 4.00001
|
||||
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, 3.75, 3.91667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [1, 7, 1]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ekg7n"]
|
||||
resource_name = "prime"
|
||||
length = 0.583342
|
||||
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.0833333, 0.166667, 0.25, 0.333333, 0.416667, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [2, 5, 8, 11, 14, 17, 20]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_4kofx"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_lpsw3"),
|
||||
"idle_primed": SubResource("Animation_n8bxp"),
|
||||
"idle_unprimed": SubResource("Animation_vmabh"),
|
||||
"prime": SubResource("Animation_ekg7n")
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"]
|
||||
size = Vector2(15, 27)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"]
|
||||
size = Vector2(34, 19)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"]
|
||||
radius = 19.0263
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_wvns6"]
|
||||
radius = 19.0263
|
||||
|
||||
[node name="Potato mine" instance=ExtResource("1_dj7ul")]
|
||||
_maxHP = 100
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
texture = ExtResource("2_sneas")
|
||||
hframes = 3
|
||||
vframes = 7
|
||||
frame = 1
|
||||
|
||||
[node name="AnimationPlayer" parent="." index="1"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_4kofx")
|
||||
}
|
||||
autoplay = "idle_unprimed"
|
||||
|
||||
[node name="Hitbox" parent="." index="2"]
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
|
||||
[node name="Unprimed" type="CollisionShape2D" parent="Hitbox" index="0"]
|
||||
position = Vector2(-0.5, 14.5)
|
||||
shape = SubResource("RectangleShape2D_qfqko")
|
||||
|
||||
[node name="Primed" type="CollisionShape2D" parent="Hitbox" index="1"]
|
||||
position = Vector2(0, 16.5)
|
||||
shape = SubResource("RectangleShape2D_ti2g4")
|
||||
disabled = true
|
||||
|
||||
[node name="Detectionbox" type="Area2D" parent="." index="3"]
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"]
|
||||
position = Vector2(0, 9)
|
||||
shape = SubResource("CircleShape2D_v0g5b")
|
||||
|
||||
[node name="ExplosionBox" type="Area2D" parent="." index="4"]
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ExplosionBox" index="0"]
|
||||
position = Vector2(0, 9)
|
||||
shape = SubResource("CircleShape2D_wvns6")
|
||||
|
||||
[node name="PrimeTimer" type="Timer" parent="." index="5"]
|
||||
wait_time = 15.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="Explosion" type="Node" parent="." index="6" node_paths=PackedStringArray("explosionArea")]
|
||||
script = ExtResource("3_2hd5y")
|
||||
damage = 60
|
||||
explosionArea = NodePath("../ExplosionBox")
|
||||
|
||||
[node name="Behaviour" type="Node" parent="." index="7" node_paths=PackedStringArray("_player", "_hitbox", "_unprimedShape", "_primedShape")]
|
||||
script = ExtResource("4_twx65")
|
||||
_player = NodePath("../AnimationPlayer")
|
||||
_hitbox = NodePath("../Hitbox")
|
||||
_unprimedShape = NodePath("../Hitbox/Unprimed")
|
||||
_primedShape = NodePath("../Hitbox/Primed")
|
||||
|
||||
[node name="ExplosionTimer" type="Timer" parent="Behaviour" index="0"]
|
||||
wait_time = 0.333
|
||||
one_shot = true
|
||||
|
||||
[connection signal="area_entered" from="Detectionbox" to="Behaviour" method="OnAreaEntered"]
|
||||
[connection signal="timeout" from="PrimeTimer" to="Behaviour" method="Prime"]
|
||||
[connection signal="timeout" from="Behaviour/ExplosionTimer" to="Explosion" method="Explode"]
|
||||
21
scripts/components/plants/ExplosionComponent.cs
Normal file
21
scripts/components/plants/ExplosionComponent.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Godot;
|
||||
|
||||
public partial class ExplosionComponent : Node
|
||||
{
|
||||
[Export] private int damage;
|
||||
[Export] private Area2D explosionArea;
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
foreach(var zombie in explosionArea.GetOverlappingAreas())
|
||||
{
|
||||
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
||||
if (zombieData != null)
|
||||
{
|
||||
zombieData.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
GetParent<RuntimePlantData>().Kill();
|
||||
}
|
||||
}
|
||||
28
scripts/components/plants/behaviours/PotatomineBehaviour.cs
Normal file
28
scripts/components/plants/behaviours/PotatomineBehaviour.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Godot;
|
||||
|
||||
public partial class PotatomineBehaviour : Node
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
[Export] private Area2D _hitbox;
|
||||
[Export] private CollisionShape2D _unprimedShape;
|
||||
[Export] private CollisionShape2D _primedShape;
|
||||
|
||||
private bool _primed = false;
|
||||
public void Prime()
|
||||
{
|
||||
_player.Play("prime");
|
||||
_player.Queue("idle_primed");
|
||||
|
||||
_hitbox.Monitorable = false;
|
||||
|
||||
_primed = true;
|
||||
_unprimedShape.Disabled = true;
|
||||
_primedShape.Disabled = false;
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
if (_primed == false) return;
|
||||
GetNode<Timer>("ExplosionTimer").Start();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue