aloe
This commit is contained in:
parent
435ca455f0
commit
8fdc2a3ed9
7 changed files with 127 additions and 1 deletions
7
assets/sprites/plants/aloe.tres
Normal file
7
assets/sprites/plants/aloe.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://d4btl7vqi4v0q"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_rq51o"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
atlas = ExtResource("1_rq51o")
|
||||||
|
region = Rect2(302, 6, 52, 50)
|
||||||
BIN
resources/animations/plants/aloe.res
Normal file
BIN
resources/animations/plants/aloe.res
Normal file
Binary file not shown.
14
resources/plants/Aloe.tres
Normal file
14
resources/plants/Aloe.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_resource type="Resource" script_class="PlantResource" load_steps=4 format=3 uid="uid://bf7vjtufjc8kt"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d4btl7vqi4v0q" path="res://assets/sprites/plants/aloe.tres" id="1_t4137"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="1_vw2kg"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bw1w8jp0yeypy" path="res://scenes/entities/plants/aloe.tscn" id="2_6a4ia"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_vw2kg")
|
||||||
|
Cost = 75
|
||||||
|
Scene = ExtResource("2_6a4ia")
|
||||||
|
ReloadTime = 15.0
|
||||||
|
StartReloadTime = 0.0
|
||||||
|
Preview = ExtResource("1_t4137")
|
||||||
|
Layer = 1
|
||||||
58
scenes/entities/plants/aloe.tscn
Normal file
58
scenes/entities/plants/aloe.tscn
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
[gd_scene load_steps=8 format=3 uid="uid://bw1w8jp0yeypy"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_n25yi"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b6tyoa5htapir" path="res://assets/sprites/atlases/plants/aloe.png" id="2_iup5p"]
|
||||||
|
[ext_resource type="AnimationLibrary" uid="uid://bgutjc3ruq27s" path="res://resources/animations/plants/aloe.res" id="3_3sp3b"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/components/plants/behaviours/AloeBehaviour.cs" id="4_55asm"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_vknky"]
|
||||||
|
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="AnimationLibrary" id="AnimationLibrary_wlien"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_vknky")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oe0dc"]
|
||||||
|
size = Vector2(22, 32)
|
||||||
|
|
||||||
|
[node name="Aloe" instance=ExtResource("1_n25yi")]
|
||||||
|
_maxHP = 100
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0"]
|
||||||
|
position = Vector2(9, -14)
|
||||||
|
texture = ExtResource("2_iup5p")
|
||||||
|
hframes = 8
|
||||||
|
vframes = 4
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" parent="." index="1"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_wlien"),
|
||||||
|
"aloe": ExtResource("3_3sp3b")
|
||||||
|
}
|
||||||
|
autoplay = "aloe/idle"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
|
||||||
|
shape = SubResource("RectangleShape2D_oe0dc")
|
||||||
|
|
||||||
|
[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_player")]
|
||||||
|
script = ExtResource("4_55asm")
|
||||||
|
_player = NodePath("../AnimationPlayer")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="Behaviour" index="0"]
|
||||||
|
wait_time = 15.0
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Behaviour/Timer" to="Behaviour" method="OnTimeout"]
|
||||||
|
|
@ -11,7 +11,7 @@ public partial class RuntimePlantData : Node2D, IEntity
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private int _maxHP;
|
private int _maxHP;
|
||||||
private int _hp;
|
[Export]private int _hp;
|
||||||
public int Hp => _hp;
|
public int Hp => _hp;
|
||||||
public int MaxHp => _maxHP;
|
public int MaxHp => _maxHP;
|
||||||
public int Line {get; set;}
|
public int Line {get; set;}
|
||||||
|
|
|
||||||
42
scripts/components/plants/behaviours/AloeBehaviour.cs
Normal file
42
scripts/components/plants/behaviours/AloeBehaviour.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Godot;
|
||||||
|
using Newlon.Components.Level;
|
||||||
|
|
||||||
|
namespace Newlon.Components.Plants.Behaviours;
|
||||||
|
|
||||||
|
public partial class AloeBehaviour : Node
|
||||||
|
{
|
||||||
|
[Export] private AnimationPlayer _player;
|
||||||
|
[Export] private float _hpTreshold = 0.25f;
|
||||||
|
private Timer _timer;
|
||||||
|
private bool _charge = true;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_timer = GetNode<Timer>("Timer");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
|
||||||
|
if(_charge && PoolContainer.Instance.EntityField[1].ContainsKey(checkPos) && PoolContainer.Instance.EntityField[1][checkPos] is RuntimePlantData plantData)
|
||||||
|
{
|
||||||
|
if((float)plantData.Hp / (float)plantData.MaxHp < _hpTreshold)
|
||||||
|
{
|
||||||
|
plantData.Heal(3000 + 25 * plantData.MaxHp);
|
||||||
|
_charge = false;
|
||||||
|
_player.Play("aloe/heal");
|
||||||
|
_player.Queue("aloe/idle_used");
|
||||||
|
_timer.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnTimeout()
|
||||||
|
{
|
||||||
|
_charge = true;
|
||||||
|
_player.Play("aloe/recharge");
|
||||||
|
_player.Queue("aloe/idle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ public partial class WallnutBehaviour : Node
|
||||||
|
|
||||||
public void OnHPChanged(int amount)
|
public void OnHPChanged(int amount)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(_data.Hp <= _data.MaxHp*2.0/3.0 && _data.Hp > _data.MaxHp/3.0)
|
if(_data.Hp <= _data.MaxHp*2.0/3.0 && _data.Hp > _data.MaxHp/3.0)
|
||||||
{
|
{
|
||||||
_player.Play("idle_mid");
|
_player.Play("idle_mid");
|
||||||
|
|
@ -22,5 +23,9 @@ public partial class WallnutBehaviour : Node
|
||||||
{
|
{
|
||||||
_player.Play("idle_low");
|
_player.Play("idle_low");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_player.Play("idle_full");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue