Zondre
This commit is contained in:
parent
c266d22f58
commit
2eb65c3092
24 changed files with 566 additions and 49 deletions
41
scripts/components/zombies/EatBox.cs
Normal file
41
scripts/components/zombies/EatBox.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class EatBox : Area2D
|
||||
{
|
||||
// Rewrite this class completely when field system will be introduced.
|
||||
|
||||
[Export] private int _damage;
|
||||
[Export] private AnimationTree _animationTree;
|
||||
private RuntimePlantData plant;
|
||||
|
||||
|
||||
public void Bite()
|
||||
{
|
||||
plant.TakeDamage(_damage);
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent != null && parent is RuntimePlantData plantData)
|
||||
{
|
||||
plant = plantData;
|
||||
_animationTree.Set("parameters/conditions/eat", true);
|
||||
_animationTree.Set("parameters/conditions/end_eat", false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAreaExited(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent == plant)
|
||||
{
|
||||
plant = null;
|
||||
_animationTree.Set("parameters/conditions/eat", false);
|
||||
_animationTree.Set("parameters/conditions/end_eat", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
scripts/components/zombies/ZombieMover.cs
Normal file
24
scripts/components/zombies/ZombieMover.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class ZombieMover : Node
|
||||
{
|
||||
private float _speed;
|
||||
|
||||
private Node2D _zombie;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_zombie = GetParent<Node2D>();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
_zombie.Position -= _zombie.Transform.X * _speed * (float)delta * Utility.TileWidth;
|
||||
}
|
||||
|
||||
public void SetSpeed(float speed)
|
||||
{
|
||||
_speed = speed;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class BasicZombieBehaviour : Node
|
||||
{
|
||||
[Export] private AnimationTree _animationTree;
|
||||
public void StartEating()
|
||||
{
|
||||
_animationTree.Set("parameters/conditions/eat",true);
|
||||
_animationTree.Set("parameters/conditions/end_eat", false);
|
||||
GD.Print("StartEating");
|
||||
}
|
||||
public void EndEating()
|
||||
{
|
||||
_animationTree.Set("parameters/conditions/eat", false);
|
||||
_animationTree.Set("parameters/conditions/end_eat", true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue